mirror of
https://github.com/daniel-j/fimfic2epub.git
synced 2024-06-02 10:34:32 +12:00
Add Fimfiction category/subject. Add version number to EPUB metadata.
This commit is contained in:
parent
e32517e9dc
commit
8801ee398a
|
@ -49,6 +49,9 @@ webpackConfig.forEach((c) => {
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
c.plugins.push(new webpack.DefinePlugin({
|
||||||
|
FIMFIC2EPUB_VERSION: JSON.stringify(require('./package.json').version)
|
||||||
|
}))
|
||||||
})
|
})
|
||||||
|
|
||||||
const wpCompiler = webpack(webpackConfig)
|
const wpCompiler = webpack(webpackConfig)
|
||||||
|
|
|
@ -63,6 +63,7 @@
|
||||||
"standard": {
|
"standard": {
|
||||||
"env": {
|
"env": {
|
||||||
"browser": true
|
"browser": true
|
||||||
}
|
},
|
||||||
|
"globals": ["FIMFIC2EPUB_VERSION"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,14 +36,14 @@ module.exports = class FimFic2Epub {
|
||||||
return sanitize(storyInfo.title + ' by ' + storyInfo.author.name + '.epub')
|
return sanitize(storyInfo.title + ' by ' + storyInfo.author.name + '.epub')
|
||||||
}
|
}
|
||||||
|
|
||||||
static fetchStoryInfo (storyId) {
|
static fetchStoryInfo (storyId, raw = false) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
storyId = FimFic2Epub.getStoryId(storyId)
|
storyId = FimFic2Epub.getStoryId(storyId)
|
||||||
let url = 'https://www.fimfiction.net/api/story.php?story=' + storyId
|
let url = 'https://www.fimfiction.net/api/story.php?story=' + storyId
|
||||||
fetchRemote(url, (raw, type) => {
|
fetchRemote(url, (content, type) => {
|
||||||
let data
|
let data
|
||||||
try {
|
try {
|
||||||
data = JSON.parse(raw)
|
data = JSON.parse(content)
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
if (!data) {
|
if (!data) {
|
||||||
reject('Unable to fetch story info')
|
reject('Unable to fetch story info')
|
||||||
|
@ -54,6 +54,10 @@ module.exports = class FimFic2Epub {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let story = data.story
|
let story = data.story
|
||||||
|
if (raw) {
|
||||||
|
resolve(story)
|
||||||
|
return
|
||||||
|
}
|
||||||
// this is so the metadata can be cached.
|
// this is so the metadata can be cached.
|
||||||
if (!story.chapters) story.chapters = []
|
if (!story.chapters) story.chapters = []
|
||||||
delete story.likes
|
delete story.likes
|
||||||
|
@ -64,7 +68,9 @@ module.exports = class FimFic2Epub {
|
||||||
story.chapters.forEach((ch) => {
|
story.chapters.forEach((ch) => {
|
||||||
delete ch.views
|
delete ch.views
|
||||||
})
|
})
|
||||||
resolve(data.story)
|
// Add version number
|
||||||
|
story.FIMFIC2EPUB_VERSION = FIMFIC2EPUB_VERSION
|
||||||
|
resolve(story)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,10 +116,11 @@ export function createOpf (ffc) {
|
||||||
m('dc:source', ffc.storyInfo.url),
|
m('dc:source', ffc.storyInfo.url),
|
||||||
m('dc:language', 'en'),
|
m('dc:language', 'en'),
|
||||||
m('meta', {name: 'cover', content: 'cover'}),
|
m('meta', {name: 'cover', content: 'cover'}),
|
||||||
m('meta', {property: 'dcterms:modified'}, new Date(ffc.storyInfo.date_modified * 1000).toISOString().replace('.000', ''))
|
m('meta', {property: 'dcterms:modified'}, new Date(ffc.storyInfo.date_modified * 1000).toISOString().replace('.000', '')),
|
||||||
|
m('dc:subject', 'Fimfiction')
|
||||||
].concat(ffc.categories.map((tag) =>
|
].concat(ffc.categories.map((tag) =>
|
||||||
m('dc:subject', tag.name)
|
m('dc:subject', tag.name)
|
||||||
))),
|
), m('meta', {name: 'fimfic2epub version', content: FIMFIC2EPUB_VERSION}))),
|
||||||
|
|
||||||
m('manifest', [
|
m('manifest', [
|
||||||
m('item', {id: 'ncx', href: 'toc.ncx', 'media-type': 'application/x-dtbncx+xml'}),
|
m('item', {id: 'ncx', href: 'toc.ncx', 'media-type': 'application/x-dtbncx+xml'}),
|
||||||
|
|
Loading…
Reference in a new issue