From a4804519c01b19c6e52b059cc365df2838d2612b Mon Sep 17 00:00:00 2001 From: Daniel J Date: Wed, 22 Jun 2016 15:43:25 +0200 Subject: [PATCH] some polishing --- gulpfile.babel.js | 18 +++++++++++++++--- packchrome.sh | 2 +- src/main.js | 13 +++++-------- src/style.styl | 10 ++++++++-- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 1ae03fc..e975065 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -12,7 +12,7 @@ import filter from 'gulp-filter' import jsonedit from 'gulp-json-editor' import zip from 'gulp-zip' -import { execFile } from 'child_process' +import { execFile, exec } from 'child_process' // script import standard from 'gulp-standard' @@ -62,7 +62,7 @@ function webpackTask (callback) { chunks: false, chunkModules: false })) - callback() + sequence(['pack:firefox', 'pack:chrome', 'pack:safari'], callback) }) } @@ -103,7 +103,7 @@ gulp.task('watch', (done) => { // creates extensions for chrome and firefox gulp.task('pack', (done) => { - sequence('default', ['pack:firefox', 'pack:chrome'], done) + sequence('default', ['pack:firefox', 'pack:chrome', 'pack:safari'], done) }) gulp.task('pack:firefox', () => { @@ -113,6 +113,7 @@ gulp.task('pack:firefox', () => { .pipe(manifest) .pipe(jsonedit(function (json) { if (json.content_scripts) { + // tweak the manifest so Firefox can read it json.applications = { gecko: { id: 'fimfic2epub@mozilla.org' @@ -137,3 +138,14 @@ gulp.task('pack:chrome', (done) => { done() }) }) + +gulp.task('pack:safari', (done) => { + exec('cp -r extension/ fimfic2epub.safariextension', [], (error, stdout, stderr) => { + // gutil.log('[pack:chrome]', stdout) + if (error || stderr) { + done(new gutil.PluginError('pack:safari', stderr, {showStack: false})) + return + } + done() + }) +}) diff --git a/packchrome.sh b/packchrome.sh index 78d1334..b40aecb 100755 --- a/packchrome.sh +++ b/packchrome.sh @@ -1,6 +1,6 @@ #!/bin/bash -CHROME=`command -v chrome || command -v chromium` +CHROME=`command -v chrome || command -v chromium || command -v "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"` rm -f extension.crx diff --git a/src/main.js b/src/main.js index 379c520..ec2d554 100644 --- a/src/main.js +++ b/src/main.js @@ -33,7 +33,9 @@ let tidyOptions = { 'alt-text': 'Image', 'wrap': '0', 'quiet': 'yes', - 'show-warnings': 0 + 'show-warnings': 0, + 'newline': 'LF', + 'tidy-mark': 'no' } let mimeMap = { @@ -42,13 +44,8 @@ let mimeMap = { 'image/gif': 'Images/*.gif' } -// const STORY_ID = 180690 // bbcode test tags -// const STORY_ID = 931 // pink eyes -// const STORY_ID = 119190 // fallout equestria const STORY_ID = document.location.pathname.match(/^\/story\/(\d*)/)[1] -let apiUrl = 'https://www.fimfiction.net/api/story.php?story=' + STORY_ID - let storyInfo let remoteResources = new Map() let chapterContent = [] @@ -210,7 +207,7 @@ function downloadStory () { console.log('Fetching story metadata...') - fetchRemote(apiUrl, function (raw, type) { + fetchRemote('https://www.fimfiction.net/api/story.php?story=' + STORY_ID, function (raw, type) { let data try { data = JSON.parse(raw) @@ -236,7 +233,7 @@ function downloadStory () { fetchChapters(function () { fetchRemoteFiles(zip, function () { remoteResources.forEach((r, url) => { - if (r.chapter && r.originalUrl && r.dest) { + if (typeof r.chapter !== 'undefined' && r.originalUrl && r.dest) { chapterContent[r.chapter] = chapterContent[r.chapter].replace( new RegExp(escapeStringRegexp(r.originalUrl), 'g'), r.dest diff --git a/src/style.styl b/src/style.styl index f982ea9..99153f1 100644 --- a/src/style.styl +++ b/src/style.styl @@ -74,6 +74,12 @@ blockquote { margin-bottom: 1.0em; } -#toc [hidden] { - display: none; +#toc { + ol { + list-style-type: none; + } + + [hidden] { + display: none; + } }