From 9864d6408af2baa47c24b7db9c91f9b2db50b529 Mon Sep 17 00:00:00 2001 From: LightAir Date: Tue, 1 Dec 2020 23:49:41 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C=D1=88?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8.=20=D0=94?= =?UTF-8?q?=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20=D1=82=D0=B5=D1=81=D1=82?= =?UTF-8?q?=D1=8B=20=D0=BD=D0=B0=20=D0=BD=D0=BE=D0=B2=D1=8B=D0=B9=20=D1=84?= =?UTF-8?q?=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=BE=D0=BD=D0=B0=D0=BB=20=D0=BE?= =?UTF-8?q?=D1=82=20crackosok?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/index.js | 6 ++--- package.json | 2 +- readme.md | 10 ++++++++- test/expectedOutput/defaultItemTurboFalse.xml | 1 + test/index.js | 22 ++++++++++++++++--- 5 files changed, 33 insertions(+), 8 deletions(-) create mode 100644 test/expectedOutput/defaultItemTurboFalse.xml diff --git a/lib/index.js b/lib/index.js index cc718e4..213efed 100755 --- a/lib/index.js +++ b/lib/index.js @@ -73,7 +73,7 @@ function items(items, channel) { if (item.goals.length > 0) { item.goals.forEach(goal => item_values.push({ - "turbo:goal": { + 'turbo:goal': { _attr: { type: goal.type || 'yandex', 'turbo-goal-id': goal.id, @@ -81,7 +81,7 @@ function items(items, channel) { id: goal.counter_id, } } - })) + })); } item_values.push({'turbo:content': {_cdata: fullContent}}); @@ -143,7 +143,7 @@ function itemData(data) { turboSource: data.turboSource || '', turboTopic: data.turboTopic || '', goals: data.goals || [], - turboEnabled: data.turboEnabled || true, + turboEnabled: data.turboEnabled !== undefined ? data.turboEnabled: true, }; } /** diff --git a/package.json b/package.json index e250584..88bbd54 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "turbo-rss", - "version": "1.1.0", + "version": "1.1.1", "description": "RSS based, feed generator for Yandex turbo", "keywords": [ "yandex", diff --git a/readme.md b/readme.md index aa79ded..1f9fdf5 100644 --- a/readme.md +++ b/readme.md @@ -46,7 +46,7 @@ feed.item(itemOptions); * `turboSource` _optional_ **string** URL страницы-источника, который можно передать в Яндекс.Метрику. * `turboTopic` _optional_ **string** Заголовок страницы, который можно передать в Яндекс.Метрику. * `goals` _optional_ **array** массив типа: { _id_ - внутренний идентификатор цели (turbo-goal-id), _name_ - имя цели, _counter_id_ - id счётчика яндекс-метрики } - + * `turboEnabled`_optional_ **bool** Принудительная установка атрибута "turbo". По умолчанию true. Установка в false позволит скрыть отображение турбо-страницы ###### menu array menu должен содержать массив объектов со следующими опциями: @@ -119,3 +119,11 @@ var xml = feed.xml(); ```sh $ npm test ``` + +## Спасибо + +@jahglow + +@vvmspace + +@crackosok \ No newline at end of file diff --git a/test/expectedOutput/defaultItemTurboFalse.xml b/test/expectedOutput/defaultItemTurboFalse.xml new file mode 100644 index 0000000..aad75c3 --- /dev/null +++ b/test/expectedOutput/defaultItemTurboFalse.xml @@ -0,0 +1 @@ +<![CDATA[title]]>http://example.com/rss.xmlru

undefined]]>
diff --git a/test/index.js b/test/index.js index b74c4dd..2bd6a28 100644 --- a/test/index.js +++ b/test/index.js @@ -1,7 +1,7 @@ -// prova is a wrapper for tape -// use npm run test:browser to run tests in a browser +/* + * use npm test to run tests + */ const test = require('tape'); - const TR = require('..'); const includeFolder = require('include-folder'); @@ -31,6 +31,22 @@ test('default item', function (t) { t.equal(feed.xml(), expectedOutput.defaultItem.trim()); }); +test('default item turbo false', function (t) { + t.plan(1); + let feed = new TR({ + title: 'title', + description: 'description', + link: 'http://example.com/rss.xml', + site_url: 'http://example.com', + }); + + feed.item({ + turboEnabled: false + }); + + t.equal(feed.xml(), expectedOutput.defaultItemTurboFalse.trim()); +}); + test('related item', function (t) { t.plan(1); let feed = new TR({