summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorTimothy J Fontaine <tjfontaine@gmail.com>2013-10-25 11:26:05 -0700
committerTimothy J Fontaine <tjfontaine@gmail.com>2013-10-25 11:26:05 -0700
commit61ccaf9a974bedf54622a1d6ad6b6ad00f95f5a5 (patch)
tree1dc52d619bd9ad2424bae83d66c837e7eea6ba06 /tools
parentf153d6da450b6ba5c78381e6e90a7ba243657691 (diff)
parent21265e20d3be515733418c5eef395ccec8f5f701 (diff)
downloadandroid-node-v8-61ccaf9a974bedf54622a1d6ad6b6ad00f95f5a5.tar.gz
android-node-v8-61ccaf9a974bedf54622a1d6ad6b6ad00f95f5a5.tar.bz2
android-node-v8-61ccaf9a974bedf54622a1d6ad6b6ad00f95f5a5.zip
Merge remote-tracking branch 'upstream/v0.10'
Conflicts: ChangeLog deps/uv/ChangeLog deps/uv/include/uv-darwin.h deps/uv/src/unix/fsevents.c deps/uv/src/unix/process.c deps/uv/src/version.c doc/api/addons.markdown doc/api/cluster.markdown doc/api/http.markdown lib/http.js lib/tls.js src/node_crypto.cc src/node_http_parser.cc src/node_version.h src/pipe_wrap.cc src/v8abbr.h src/v8ustack.d test/simple/test-http-pipeline-flood.js
Diffstat (limited to 'tools')
-rw-r--r--tools/blog/wp-to-markdown.js189
1 files changed, 0 insertions, 189 deletions
diff --git a/tools/blog/wp-to-markdown.js b/tools/blog/wp-to-markdown.js
deleted file mode 100644
index 65ec2d5b72..0000000000
--- a/tools/blog/wp-to-markdown.js
+++ /dev/null
@@ -1,189 +0,0 @@
-var sax = require('sax');
-var fs = require('fs');
-var parser = sax.parser(false, { lowercase: true });
-var assert = require('assert');
-var mkdirp = require('mkdirp');
-var url = require('url');
-
-var input = fs.createReadStream(process.argv[2]);
-input.on('data', function(c) {
- parser.write(c.toString());
-});
-input.on('end', parser.end.bind(parser));
-
-var post = null;
-var author = null;
-var authors = {};
-mkdirp.sync('out');
-
-parser.onopentag = function (tag) {
- switch (tag.name) {
- case 'wp:author':
- assert(author === null);
- author = {};
- author.text = '';
- return;
-
- case 'wp:author_login':
- assert(author);
- author.field = 'login';
- author.text = '';
- return;
-
- case 'wp:author_display_name':
- assert(author);
- author.field = 'name';
- author.text = '';
- return
-
- case 'wp:author_first_name':
- assert(author);
- author.field = 'first_name';
- author.text = '';
- return;
-
- case 'wp:author_last_name':
- assert(author);
- author.field = 'last_name';
- author.text = '';
- return;
-
- case 'item':
- assert(post === null);
- post = {};
- post.text = '';
- return;
-
- case 'title':
- if (post === null) return;
- post.field = 'title';
- return
-
- case 'pubDate':
- case 'wp:post_date':
- post.field = 'date';
- return;
-
- case 'dc:creator':
- post.field = 'author';
- return;
-
- case 'wp:status':
- post.field = 'status';
- return;
-
- case 'category':
- post.field = 'category';
- return;
-
- case 'content:encoded':
- post.field = 'body';
- return;
-
- case 'link':
- if (post) post.field = 'link';
- return;
-
- default:
- if (post) post.field = null;
- if (author) author.field = null;
- return;
- }
-};
-
-parser.onclosetag = function (tagName, tag) {
- switch (tagName) {
- case 'wp:author':
- assert(author);
- finishAuthor();
- return;
- case 'item':
- assert(post);
- finishPost();
- return;
- default:
- if (post && post.field || author && author.field) finishField();
- return;
- }
-};
-
-parser.ontext = parser.oncdata = function (text) {
- if (author) {
- if (author.field) author.text += text;
- else author.text = '';
- } else if (post) {
- if (post.field) post.text += text;
- else post.field = '';
- }
-};
-
-function finishField() {
- if (post && post.field) {
- post[post.field] = post.text;
- post.field = null;
- post.text = '';
- } else if (author && author.field) {
- author[author.field] = author.text;
- author.field = null;
- author.text = '';
- }
-}
-
-function finishPost() {
- // don't port drafts.
- if (post.status === 'draft') {
- return post = null;
- }
- post.date = new Date(post.date);
-
- if (post.link) {
- post.slug =
- url.parse(post.link)
- .pathname
- .replace(/\/+$/, '')
- .split('/')
- .pop();
- }
- if (!post.slug) {
- post.slug =
- (post.title + '-' + post.date.toISOString())
- .replace(/[^a-z0-9]+/gi, '-')
- .replace(/^-|-$/g, '')
- .toLowerCase();
- }
- post.slug = post.slug || '-';
-
- delete post.text
- delete post.link
- delete post.field
- post.author = authors[post.author] || post.author;
-
- post.body = post.body || '';
-
- // actually write it!
- var output = [];
- Object.keys(post)
- .filter(function (f) { return f !== 'body' }).forEach(function (k) {
- output.push(k + ': ' + post[k]);
- })
- output = output.join('\n') + '\n\n' + post.body.trim() + '\n';
-
- var f = 'out/' + post.category + '/' + post.slug + '.md';
- console.log(f, post.title);
- mkdirp.sync('out/' + post.category)
- fs.writeFileSync(f, output, 'utf8');
-
- post = null;
-}
-
-function finishAuthor () {
- author.name = author.name ||
- (author.first_name + ' ' + author.last_name) ||
- author.login;
- delete author.first_name
- delete author.last_name
- delete author.text
- delete author.field
- authors[author.login] = author.name
- author = null;
-}