Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

turbo-rss

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

turbo-rss - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

.eslintrc.json

107

lib/index.js

@@ -5,4 +5,10 @@ 'use strict';

function ifTruePush(bool, array, data) {
if (bool) {
/**
* Check first argument. If true - push last argument to second argument
* @param condition
* @param array
* @param data
*/
function ifTruePush(condition, array, data) {
if (condition) {
array.push(data);

@@ -12,21 +18,36 @@ }

function generateXML(data) {
/**
* @param related
* @param itemValues
*/
function addRelated(related, itemValues) {
ifTruePush(related, itemValues, {
'yandex:related': related.map(
function (rel) {
return {
link: [{
_attr: {
'url': rel.link,
'img': rel.image_url
}
}, rel.text]
};
}
)
});
}
let channel = [];
channel.push({title: {_cdata: data.title}});
channel.push({link: data.link || 'http://github.com/LightAir/turbo-rss'});
channel.push({description: {_cdata: data.description || data.title}});
channel.push({language: 'ru'});
data.items.forEach(function (item) {
/**
* Items processing
* @param items
* @param channel
*/
function items(items, channel) {
items.forEach(function (item) {
let item_values = [];
item_values.push({_attr: {'turbo': 'true'}});
item_values.push({link: item.url});
item_values.push({'turbo:source': item.url});
ifTruePush(item.date, item_values, {pubDate: new Date(item.date).toGMTString()});
ifTruePush(item.date, item_values, {pubDate: new Date(item.date).toUTCString()});
ifTruePush(item.author, item_values, {author: item.author});

@@ -49,15 +70,25 @@

if (typeof item.related !== "undefined") {
ifTruePush(item.related, item_values, {
'yandex:related': item.related.map(
function (related) {
return '<link url="' + related.link + '" img="' + related.image_url + '">' + related.text + '</link>';
}
).join('')
});
if (typeof item.related !== 'undefined') {
addRelated(item.related, item_values);
}
channel.push({item: item_values});
});
}
/**
* @param data
* @returns {{rss: *[]}}
*/
function generateXML(data) {
let channel = [];
channel.push({title: {_cdata: data.title}});
channel.push({link: data.link || 'http://github.com/LightAir/turbo-rss'});
channel.push({description: {_cdata: data.description || data.title}});
channel.push({language: 'ru'});
items(data.items, channel);
let _attr = {

@@ -78,2 +109,8 @@ 'xmlns:yandex': 'http://news.yandex.ru',

/**
* Base function
* @param options
* @param items
* @constructor
*/
function YTurbo(options, items) {

@@ -87,14 +124,14 @@ options = options || {};

this.item = function (options) {
options = options || {};
this.item = function (data) {
data = data || {};
let item = {
title: options.title || 'No title',
description: options.description || '',
image_url: options.image_url,
url: options.url,
author: options.author,
date: options.date || options.pubDate,
content: options.content,
menu: options.menu,
related: options.related
title: data.title || 'No title',
description: data.description || '',
image_url: data.image_url,
url: data.url,
author: data.author,
date: data.date || data.pubDate,
content: data.content,
menu: data.menu,
related: data.related
};

@@ -101,0 +138,0 @@

{
"name": "turbo-rss",
"version": "1.0.5",
"version": "1.0.6",
"description": "RSS based, feed generator for Yandex turbo",

@@ -59,2 +59,3 @@ "keywords": [

"devDependencies": {
"eslint": "^4.19.1",
"folderify": "^1.1.0",

@@ -61,0 +62,0 @@ "grunt": "^0.4.5",

@@ -5,5 +5,6 @@ ## WIP

[![Maintainability](https://api.codeclimate.com/v1/badges/6525d2aabf20185b68b6/maintainability)](https://codeclimate.com/github/LightAir/turbo-rss/maintainability)
[![Build Status](https://travis-ci.org/LightAir/turbo-rss.svg)](https://travis-ci.org/LightAir/turbo-rss)
![npm](https://img.shields.io/npm/v/npm.svg)
![Packagist](https://img.shields.io/packagist/l/doctrine/orm.svg)
[![npm](https://img.shields.io/badge/npm%20package-1.0.5-blue.svg?longCache=true&style=flat)](https://www.npmjs.com/package/turbo-rss)
![license](https://img.shields.io/packagist/l/doctrine/orm.svg?longCache=true&style=flat)

@@ -10,0 +11,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc