make it possible to hide chapter word count and duration

This commit is contained in:
daniel-j 2018-07-31 10:27:49 +02:00
parent 9a458b558c
commit b0d7247680
6 changed files with 65 additions and 49 deletions

View file

@ -53,24 +53,26 @@ By default the EPUB will be saved in the current working directory with the file
Options:
-V, --version output the version number
-d, --dir <path> Directory to store ebook in. Is prepended to filename
-t, --title <value> Set the title of the story
-a, --author <value> Set the author of the story
-T, --typogrify Enable typographic fixes (smart quotes, dashes, ellipsis, ordinal)
-c, --no-comments-link Don't add link to online comments
-H, --no-headings Don't add headings to chapters
-b, --no-bars Don't add chapter bars to show reading progress
-r, --no-reading-ease Don't calculate Flesch reading ease
-e, --no-external Don't embed external resources, such as images (breaks EPUB spec)
-n, --no-notes Don't include author notes
-i, --notes-index Create an index with all author notes at the end of the ebook
-p, --paragraphs <style> Select a paragraph style <spaced|indented|indentedall|both> (default: spaced)
-k, --kepubify Add extra <span> elements for Kobo EPUB (KEPUB) format
-j, --join-subjects Join dc:subjects to a single value
-w, --wpm <number> Words per minute. Set to 0 to disable reading time estimations (default: 200)
-C, --cover <url> Set cover image url
-h, --help output usage information
-V, --version output the version number
-d, --dir <path> Directory to store ebook in. Is prepended to filename
-t, --title <value> Set the title of the story
-a, --author <value> Set the author of the story
-T, --typogrify Enable typographic fixes (smart quotes, dashes, ellipsis, ordinal)
-c, --no-comments-link Don't add link to online comments
-H, --no-headings Don't add headings to chapters (includes chapter title, duration and word count)
-W, --no-chapter-word-count Don't add word count to chapter headings
-D, --no-chapter-duration Don't add time to read to chapter headings
-b, --no-bars Don't add chapter bars to show reading progress
-r, --no-reading-ease Don't calculate Flesch reading ease
-e, --no-external Don't embed external resources, such as images (breaks EPUB spec)
-n, --no-notes Don't include author notes
-i, --notes-index Create an index with all author notes at the end of the ebook
-p, --paragraphs <style> Select a paragraph style <spaced|indented|indentedall|both> (default: spaced)
-k, --kepubify Add extra <span> elements for Kobo EPUB (KEPUB) format
-j, --join-subjects Join dc:subjects to a single value
-w, --wpm <number> Words per minute. Set to 0 to disable reading time estimations (default: 200)
-C, --cover <url> Set cover image url
-h, --help output usage information
```
Examples

View file

@ -1,6 +1,6 @@
{
"name": "fimfic2epub",
"version": "1.7.33",
"version": "1.7.34",
"description": "Tool to generate improved EPUB ebooks from Fimfiction stories",
"author": "djazz",
"license": "MIT",
@ -22,16 +22,16 @@
"LICENSE"
],
"dependencies": {
"commander": "^2.15.1",
"commander": "^2.16.0",
"crc-32": "^1.2.0",
"detect-node": "^2.0.3",
"elementtree": "^0.1.7",
"escape-string-regexp": "^1.0.5",
"file-type": "^8.0.0",
"fonteditor-core": "^1.0.2",
"file-type": "^8.1.0",
"fonteditor-core": "^1.0.5",
"html-entities": "^1.2.1",
"html-to-text": "^4.0.0",
"image-size": "^0.6.2",
"image-size": "^0.6.3",
"is-svg": "^3.0.0",
"jszip": "^3.1.5",
"match-words": "^1.0.0",
@ -39,23 +39,23 @@
"mithril-node-render": "^2.3.0",
"node-png": "^0.4.3",
"pretty-data": "^0.40.0",
"request": "^2.86.0",
"request": "^2.87.0",
"sanitize-filename": "^1.6.1",
"syllable": "^3.0.0",
"twemoji": "^2.5.1",
"typogr": "^0.6.7",
"twemoji": "^11.0.0",
"typogr": "^0.6.8",
"url-regex": "^4.1.1",
"zero-fill": "^2.2.3"
},
"devDependencies": {
"autosize": "^4.0.2",
"babel-core": "^6.26.3",
"babel-loader": "^7.1.4",
"babel-loader": "^7.1.5",
"babel-preset-env": "^1.7.0",
"babel-register": "^6.26.0",
"binary-loader": "0.0.1",
"del": "^3.0.0",
"eslint": "^4.19.1",
"eslint": "^5.2.0",
"eslint-plugin-standard": "^3.1.0",
"exports-loader": "^0.7.0",
"file-saver": "^1.3.8",
@ -65,21 +65,21 @@
"gulp-change": "^1.0.0",
"gulp-chmod": "^2.0.0",
"gulp-filter": "^5.1.0",
"gulp-json-editor": "^2.3.0",
"gulp-rename": "^1.2.3",
"gulp-json-editor": "^2.4.2",
"gulp-rename": "^1.4.0",
"gulp-standard": "^11.0.0",
"gulp-util": "^3.0.8",
"gulp-watch": "^5.0.0",
"gulp-zip": "^4.1.0",
"gulp-watch": "^5.0.1",
"gulp-zip": "^4.2.0",
"lazypipe": "^1.0.1",
"raw-loader": "^0.5.1",
"regenerator-runtime": "^0.11.1",
"regenerator-runtime": "^0.12.0",
"removeNPMAbsolutePaths": "^1.0.4",
"run-sequence": "^2.2.1",
"standard": "^11.0.1",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.2",
"webpack": "^4.8.3",
"webpack": "^4.16.3",
"webpack-node-externals": "^1.7.2"
},
"standard": {

View file

@ -95,7 +95,9 @@ class FimFic2Epub extends EventEmitter {
addCommentsLink: true,
includeAuthorNotes: true,
useAuthorNotesIndex: false,
addChapterHeadings: true,
showChapterHeadings: true,
showChapterWordCount: true,
showChapterDuration: true,
includeExternal: true,
paragraphStyle: 'spaced',
kepubify: false,
@ -401,7 +403,9 @@ class FimFic2Epub extends EventEmitter {
chain = chain.then(template.createChapter.bind(null, this, {
title: ch.title,
addHeadings: this.options.addChapterHeadings,
showHeadings: this.options.showChapterHeadings,
showWordCount: this.options.showChapterWordCount,
showDuration: this.options.showChapterDuration,
link: this.options.addCommentsLink ? ch.link : null,
linkNotes: this.options.includeAuthorNotes && this.options.useAuthorNotesIndex && chapter.notes ? 'note_' + zeroFill(3, i + 1) + '.xhtml' : null,
content: content,
@ -418,7 +422,7 @@ class FimFic2Epub extends EventEmitter {
if (this.options.includeAuthorNotes && this.options.useAuthorNotesIndex && chapter.notes) {
chain = chain.then(template.createChapter.bind(null, this, {
title: 'Author\'s Note: ' + ch.title,
addHeadings: true,
showHeadings: true,
content: chapter.notes,
index: i
}, true)).then((html) => {

View file

@ -8,7 +8,9 @@ const args = require('commander')
.option('-a, --author <value>', 'Set the author of the story')
.option('-T, --typogrify', 'Enable typographic fixes (smart quotes, dashes, ellipsis, ordinal)')
.option('-c, --no-comments-link', 'Don\'t add link to online comments')
.option('-H, --no-headings', 'Don\'t add headings to chapters')
.option('-H, --no-headings', 'Don\'t add headings to chapters (includes chapter title, duration and word count)')
.option('-W, --no-chapter-word-count', 'Don\'t add word count to chapter headings')
.option('-D, --no-chapter-duration', 'Don\'t add time to read to chapter headings')
.option('-b, --no-bars', 'Don\'t add chapter bars to show reading progress')
.option('-r, --no-reading-ease', 'Don\'t calculate Flesch reading ease')
.option('-e, --no-external', 'Don\'t embed external resources, such as images (breaks EPUB spec)')
@ -33,7 +35,7 @@ if (outputStdout) {
console.log('Outputting to stdout')
}
// use a mock DOM so we can run mithril on the server
// use a mock DOM so we can run mithril in nodejs
require('mithril/test-utils/browserMock')(global)
const htmlToText = require('./utils').htmlToText
@ -48,7 +50,9 @@ const ffc = new FimFic2Epub(STORY_ID, {
addCommentsLink: !!args.commentsLink,
includeAuthorNotes: !!args.notes,
useAuthorNotesIndex: !!args.notesIndex,
addChapterHeadings: !!args.headings,
showChapterHeadings: !!args.headings,
showChapterWordCount: !!args.chapterWordCount,
showChapterDuration: !!args.chapterDuration,
includeExternal: !!args.external,
paragraphStyle: args.paragraphs,
kepubify: !!args.kepubify,

View file

@ -133,7 +133,9 @@ let dialog = {
this.addCommentsLink = prop(ffc.options.addCommentsLink)
this.includeAuthorNotes = prop(ffc.options.includeAuthorNotes)
this.useAuthorNotesIndex = prop(ffc.options.useAuthorNotesIndex)
this.addChapterHeadings = prop(ffc.options.addChapterHeadings)
this.showChapterHeadings = prop(ffc.options.showChapterHeadings)
this.showChapterWordCount = prop(ffc.options.showChapterWordCount)
this.showChapterDuration = prop(ffc.options.showChapterDuration)
this.includeExternal = prop(ffc.options.includeExternal)
this.kepubify = prop(ffc.options.kepubify)
this.joinSubjects = prop(ffc.options.joinSubjects)
@ -253,9 +255,11 @@ let dialog = {
['indentedall', 'Indent all paragraphs including the first (Modified Traditional)']
], ctrl.paragraphStyle()))
)),
m('tr', m('td.label', ''), m('td', {colspan: 2},
m('tr', m('td.label', {style: 'vertical-align: top;'}, 'Options'), m('td', {colspan: 2},
m(checkbox, {checked: ctrl.typogrify(), onchange: m.withAttr('checked', ctrl.typogrify)}, 'Apply typographic fixes (smart quotes, dashes etc.)'),
m(checkbox, {checked: ctrl.addChapterHeadings(), onchange: m.withAttr('checked', ctrl.addChapterHeadings)}, 'Add chapter headings, with chapter word count and time to read'),
m(checkbox, {checked: ctrl.showChapterHeadings(), onchange: m.withAttr('checked', ctrl.showChapterHeadings)}, 'Add chapter headings'),
m(checkbox, {checked: ctrl.showChapterWordCount(), onchange: m.withAttr('checked', ctrl.showChapterWordCount), disabled: !ctrl.showChapterHeadings()}, 'Include word count in chapter heading'),
m(checkbox, {checked: ctrl.showChapterDuration(), onchange: m.withAttr('checked', ctrl.showChapterDuration), disabled: !ctrl.showChapterHeadings()}, 'Include time to read in chapter heading'),
m(checkbox, {checked: ctrl.addCommentsLink(), onchange: m.withAttr('checked', ctrl.addCommentsLink)}, 'Add link to online comments (at the end of chapters)'),
m(checkbox, {checked: ctrl.includeAuthorNotes(), onchange: m.withAttr('checked', ctrl.includeAuthorNotes)}, 'Include author\'s notes'),
m(checkbox, {checked: ctrl.useAuthorNotesIndex(), onchange: m.withAttr('checked', ctrl.useAuthorNotesIndex), disabled: !ctrl.includeAuthorNotes()}, 'Put all notes at the end of the ebook'),
@ -326,7 +330,9 @@ function createEpub (model) {
ffc.options.addCommentsLink = model.addCommentsLink()
ffc.options.includeAuthorNotes = model.includeAuthorNotes()
ffc.options.useAuthorNotesIndex = model.useAuthorNotesIndex()
ffc.options.addChapterHeadings = model.addChapterHeadings()
ffc.options.showChapterHeadings = model.showChapterHeadings()
ffc.options.showChapterWordCount = model.showChapterWordCount()
ffc.options.showChapterDuration = model.showChapterDuration()
ffc.options.includeExternal = model.includeExternal()
ffc.options.paragraphStyle = model.paragraphStyle()
ffc.options.kepubify = model.kepubify()

View file

@ -66,7 +66,7 @@ function chapterBars (chapters, currentChapter = -1, highlightCurrent = false) {
}
export function createChapter (ffc, ch, isNotesChapter) {
let {content, notes, notesFirst, title, link, linkNotes, index, addHeadings} = ch
let {content, notes, notesFirst, title, link, linkNotes, index, showHeadings, showDuration, showWordCount} = ch
let sections = [
m.trust(content || ''),
@ -91,10 +91,10 @@ export function createChapter (ffc, ch, isNotesChapter) {
m('title', title)
]),
m('body', {'epub:type': 'bodymatter chapter'}, m('div', [
addHeadings ? m('.chapter-title', [
!isNotesChapter ? m('aside.info',
m('span.label', ffc.options.wordsPerMinute ? calcReadingTime(ffc, ffc.storyInfo.chapters[index].realWordCount) : ''),
m('span.label', ffc.storyInfo.chapters[index].realWordCount.toLocaleString('en-GB') + ' words')
showHeadings ? m('.chapter-title', [
!isNotesChapter && (showDuration || showWordCount) ? m('aside.info',
showDuration ? m('span.label', ffc.options.wordsPerMinute ? calcReadingTime(ffc, ffc.storyInfo.chapters[index].realWordCount) : '') : null,
showWordCount ? m('span.label', ffc.storyInfo.chapters[index].realWordCount.toLocaleString('en-GB') + ' words') : null
) : null,
m('header', m('h1', title)),
m('hr.old')