-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathgh-book-local.js
74 lines (72 loc) · 3.86 KB
/
gh-book-local.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Generated by CoffeeScript 1.3.3
(function() {
require(['gh-book/app', 'gh-book/store'], function(Store) {
var CALLBACK_DELAY, CH1_ID, CH1_PATH, CH2_ID, CH2_PATH, NAV_PATH, OPF_ID, OPF_LANGUAGE, OPF_PATH, OPF_TITLE, wrap, _pullDir, _pullFile, _pushFile;
CALLBACK_DELAY = 0;
OPF_ID = '12345';
OPF_TITLE = 'Github EPUB Editor';
OPF_LANGUAGE = 'en';
OPF_PATH = 'book.opf';
NAV_PATH = 'navigation.html';
CH1_PATH = 'background.html';
CH2_PATH = 'introduction.html';
CH1_ID = 'id-1-background';
CH2_ID = 'id-2-intro';
window.FILES = {};
FILES['META-INF/container.xml'] = "<?xml version='1.0' encoding='UTF-8'?>\n<container xmlns=\"urn:oasis:names:tc:opendocument:xmlns:container\" version=\"1.0\">\n <rootfiles>\n <rootfile full-path=\"" + OPF_PATH + "\" media-type=\"application/oebps-package+xml\"/>\n </rootfiles>\n</container>";
FILES[OPF_PATH] = "<?xml version=\"1.0\"?>\n<package version=\"3.0\"\n xml:lang=\"en\"\n xmlns=\"http://www.idpf.org/2007/opf\"\n unique-identifier=\"pub-id\">\n <metadata xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n <dc:identifier\n id=\"pub-id\">" + OPF_ID + "</dc:identifier>\n <meta refines=\"#pub-id\"\n property=\"identifier-type\"\n scheme=\"xsd:string\">uuid</meta>\n\n <dc:language>" + OPF_LANGUAGE + "</dc:language>\n <dc:title>" + OPF_TITLE + "</dc:title>\n\n </metadata>\n\n <manifest>\n <item id=\"id-navigation\"\n properties=\"nav\"\n href=\"" + NAV_PATH + "\"\n media-type=\"application/xhtml+xml\"/>\n <item id=\"" + CH2_ID + "\"\n href=\"" + CH2_PATH + "\"\n media-type=\"application/xhtml+xml\"/>\n <item id=\"" + CH1_ID + "\"\n href=\"" + CH1_PATH + "\"\n media-type=\"application/xhtml+xml\"/>\n </manifest>\n <spine>\n <itemref idref=\"" + CH1_ID + "\"/>\n <itemref idref=\"" + CH2_ID + "\"/>\n </spine>\n</package>";
FILES[NAV_PATH] = "<p>Example Navigation</p>\n<nav>\n <ol>\n <li><a href=\"" + CH1_PATH + "\">Background Information</a></li>\n <li><a href=\"" + CH2_PATH + "\">Introduction to gh-book</a></li>\n <li>\n <span>Chapter 1</span>\n <ol>\n <li><a href=\"section.html\">Section 1</a></li>\n </ol>\n </li>\n </ol>\n</nav>";
FILES[CH1_PATH] = '<h1>Background</h1>';
FILES[CH2_PATH] = '<h1>Introduction</h1>';
FILES['background.json'] = JSON.stringify({
title: 'Background Module Title'
});
_pushFile = function(path, text, commitText, cb) {
console.log("Saving " + path);
FILES[path] = text;
return cb(null);
};
_pullFile = function(path, cb) {
if (path in FILES) {
console.log("Loading " + path);
return cb(null, FILES[path]);
} else {
console.log("LOAD PROBLEM: COULD NOT FIND " + path);
return cb('COULD_NOT_FIND_FILE');
}
};
_pullDir = function(path, cb) {
var dirFiles, name;
dirFiles = (function() {
var _i, _len, _ref, _results;
_ref = Object.keys(FILES);
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
name = _ref[_i];
_results.push({
name: name
});
}
return _results;
})();
return cb(null, dirFiles);
};
wrap = function(fn) {
return function() {
var args;
args = arguments;
if (0 === CALLBACK_DELAY) {
fn.apply(Store, args);
}
if (CALLBACK_DELAY) {
return setTimeout((function() {
return fn.apply(Store, args);
}), CALLBACK_DELAY);
}
};
};
Store._pushFile = wrap(_pushFile);
Store._pullFile = wrap(_pullFile);
return Store._pullDir = wrap(_pullDir);
});
}).call(this);