New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tumblr-2-pe-epub

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tumblr-2-pe-epub - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

106

index.js
// Generated by CoffeeScript 1.7.1
(function() {
var Tumblr2Peepub, tumblr;
var Tumblr2Peepub, cheerio, tumblr;
tumblr = require('tumblr');
cheerio = require('cheerio');
Tumblr2Peepub = function(tumblrConfig) {
var allPosts, bookDoc, fetchPosts, that, totalPosts;
var allPosts, bookDoc, fetchPosts, formatPosts, that, totalPosts;
that = this;

@@ -24,3 +26,3 @@ this.tumblrConfig = tumblrConfig;

bookDoc = {
title: res.blog.title,
title: res.blog.title || that.blogUrl,
url: 'http://' + that.blogUrl,

@@ -39,2 +41,85 @@ subtitle: res.blog.description,

};
formatPosts = function(p) {
var $, body, embed_code, exp, pbody, pcap, pdesc, pphotos, pquotesrc, psource, ptext, ptitle, pvideo, regex, title, video_domain, video_url;
if (p.title) {
ptitle = "<h1>" + p.title + "</h1>";
} else {
ptitle = "";
}
if (p.source_url) {
psource = "<p>Source: <a href=\"" + p.source_url + "\">" + p.source_title + "</a></p>";
} else {
psource = "";
}
if (p.body) {
pbody = p.body;
} else {
pbody = "";
}
if (p.text) {
ptext = "<h1><blockquote>“" + p.text + "”</blockquote></h1>";
} else {
ptext = "";
}
if (p.source) {
pquotesrc = "<p>— " + p.source + "</p>";
} else {
pquotesrc = "";
}
if (p.url) {
if (p.title) {
ptitle = "<h1><a href=\"" + p.url + "\">" + p.title + "</a></h1>";
} else {
ptitle = "<h1><a href=\"" + p.url + "\">" + p.url + "</a></h1>";
}
}
if (p.description) {
pdesc = p.description;
} else {
pdesc = "";
}
if (p.player) {
if (p.player[0]["embed_code"]) {
embed_code = p.player[0]["embed_code"];
$ = cheerio.load(embed_code);
video_url = $('iframe').attr('src');
if (video_url) {
if (video_url.indexOf('//') === 0) {
video_url = video_url.replace('//', 'http://');
}
video_domain = video_url.replace('http://', '').replace('https://', '').split(/[/?#]/)[0];
if (video_domain === "") {
video_domain = video_url;
}
pvideo = "<h1><p>Video: <a href=\"" + video_url + "\">" + video_domain + "</a></p></h1>";
}
} else {
pvideo = "";
}
} else {
pvideo = "";
}
if (p.photos) {
pphotos = p.photos.map(function(photo) {
return "<p><img src=\"" + photo.original_size.url + "\" /></p>";
}).join('');
} else {
pphotos = "";
}
if (p.caption) {
pcap = p.caption;
} else {
pcap = "";
}
title = p.date.replace(" GMT", "");
body = ptitle + ptext + pphotos + pvideo + pcap + pbody + pquotesrc + pdesc + psource;
exp = /<iframe.+<\/iframe>/g;
regex = new RegExp(exp);
body = body.replace(regex, '');
return {
title: title,
body: body,
toc: true
};
};
this.fetch = function(tumblrPrefix, cb) {

@@ -57,16 +142,3 @@ this.blogUrl = tumblrPrefix + '.tumblr.com';

bookDoc.cover = photos[photos.length - 1];
bookDoc.pages = posts.map(function(p) {
var body;
if (p.photos) {
body = (p.photos.map(function(photo) {
return "<p><img src=\"" + photo.original_size.url + "\" /></p>";
}).join('')) + p.caption;
} else {
body = p.caption;
}
return {
title: p.caption ? p.caption.replace(/(<([^>]+)>)/ig, "") : "",
body: body
};
}).filter(function(p) {
bookDoc.pages = posts.map(formatPosts).filter(function(p) {
return p.body != null;

@@ -73,0 +145,0 @@ });

7

package.json
{
"name": "tumblr-2-pe-epub",
"version": "0.2.0",
"version": "0.3.0",
"description": "tumblr into pe-epub format",

@@ -12,6 +12,7 @@ "main": "index.js",

"repository": {
"type": "git",
"url": "https://github.com/peoples-e/tumblr-2-pe-epub"
"type": "git",
"url": "https://github.com/peoples-e/tumblr-2-pe-epub"
},
"dependencies": {
"cheerio": "^0.17.0",
"tumblr": "~0.4.1"

@@ -18,0 +19,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