Skip to content

Commit

Permalink
v1.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-j committed Jun 23, 2016
1 parent f4c0b59 commit b43e315
Show file tree
Hide file tree
Showing 8 changed files with 363 additions and 363 deletions.
2 changes: 1 addition & 1 deletion extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "fimfic2epub",
"short_name": "ff2epub",
"description": "Improved EPUB exporter for Fimfiction",
"version": "1.0.2",
"version": "1.0.3",

"icons": {
"128": "icon-128.png"
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "fimfic2epub.js",
"name": "fimfic2epub",
"private": true,
"version": "1.0.1",
"version": "1.0.3",
"description": "",
"author": "djazz",
"scripts": {
Expand Down
36 changes: 36 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

export const NS = {
OPF: 'http://www.idpf.org/2007/opf',
OPS: 'http://www.idpf.org/2007/ops',
DC: 'http://purl.org/dc/elements/1.1/',
DAISY: 'http://www.daisy.org/z3986/2005/ncx/',
XHTML: 'http://www.w3.org/1999/xhtml',
SVG: 'http://www.w3.org/2000/svg',
XLINK: 'http://www.w3.org/1999/xlink'
}

export const tidyOptions = {
'indent': 'auto',
'numeric-entities': 'yes',
'output-xhtml': 'yes',
'alt-text': 'Image',
'wrap': '0',
'quiet': 'yes',
'show-warnings': 0,
'newline': 'LF',
'tidy-mark': 'no'
}

export const mimeMap = {
'image/jpeg': 'Images/*.jpg',
'image/png': 'Images/*.png',
'image/gif': 'Images/*.gif'
}

export const containerXml = `<?xml version="1.0" encoding="UTF-8"?>
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<rootfiles>
<rootfile full-path="content.opf" media-type="application/oebps-package+xml"/>
</rootfiles>
</container>
`
23 changes: 3 additions & 20 deletions src/eventPage.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,11 @@
/* global chrome, safari */

function fetch (url, cb, type) {
if (url.indexOf('//') === 0) {
url = 'http:' + url
}
let x = new XMLHttpRequest()
x.open('get', url, true)
if (type) {
x.responseType = type
}
x.onload = function () {
cb(x.response, x.getResponseHeader('content-type'))
}
x.onerror = function () {
console.error('error')
cb(null)
}
x.send()
}
import fetch from './fetch'

if (typeof safari !== 'undefined') {
safari.application.addEventListener('message', function (ev) {
let url = ev.message
fetch(url, function (buffer, type) {
fetch(url, (buffer, type) => {
console.log('Fetched ' + url + ' (' + type + ')')
ev.target.page.dispatchMessage('remote', {
input: url,
Expand All @@ -35,7 +18,7 @@ if (typeof safari !== 'undefined') {
let onMessage = chrome.extension.onMessage ? chrome.extension.onMessage : chrome.runtime.onMessage

onMessage.addListener(function (request, sender, sendResponse) {
fetch(request, function (blob, type) {
fetch(request, (blob, type) => {
sendResponse(URL.createObjectURL(blob), type)
}, 'blob')
return true
Expand Down
19 changes: 19 additions & 0 deletions src/fetch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

export default function fetch (url, cb, type) {
if (url.indexOf('//') === 0) {
url = 'http:' + url
}
let x = new XMLHttpRequest()
x.open('get', url, true)
if (type) {
x.responseType = type
}
x.onload = function () {
cb(x.response, x.getResponseHeader('content-type'))
}
x.onerror = function () {
console.error('error')
cb(null)
}
x.send()
}
Loading

0 comments on commit b43e315

Please sign in to comment.