Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Vaporbook committed Nov 22, 2012
0 parents commit 8862c17
Show file tree
Hide file tree
Showing 6 changed files with 351 additions and 0 deletions.
Empty file added .gitignore
Empty file.
11 changes: 11 additions & 0 deletions README.md
@@ -0,0 +1,11 @@
epub-tmpl
===========

# What It Does

Provides reading system templates, single HTML file templates for viewing Epub content in the browser. These can be called selectively based on the type of Epub, type of content it carries, or as a fixed feature of a larger reading system


# Design

The design of this module is dependent on a few assumptions: the reading systems here are meant to be fast, compact, lightweight, and heavily optimized for single file usage. The configuration for particular epub content is meant to be injected into the template. All CSS, Javascript and graphical assets should be packaged within this file. Assets can be worked with in separate files but the final template must be a single html file, minified, with a single line on its own for configuration injection.
308 changes: 308 additions & 0 deletions html/read/index.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions index.js
@@ -0,0 +1 @@
module.exports = require('./lib/epub-tmpl.js');
25 changes: 25 additions & 0 deletions lib/epub-tmpl.js
@@ -0,0 +1,25 @@

var fs = require('fs');
var templateDir = __dirname + '/../html';
var externalTemplates;

module.exports.getTemplate = function getTemplate(name) {

if(externalTemplates[name]=='undefined') {
var template = fs.readFileSync(templateDir + '/' + name + '/index.html');
return template.toString();
} else {
return externalTemplates[name];
}

}

module.exports.addTemplate = function addTemplate(name, html) {

// adds a template without adding to filesystem. useful
// for using 3rd party or non oss templates

externalTemplates[name] = html;

}

6 changes: 6 additions & 0 deletions test.js
@@ -0,0 +1,6 @@

var tmpl = require('../lib/epub-tmpl.js');

var html = tmpl.getTemplate('read');

console.log(html);

0 comments on commit 8862c17

Please sign in to comment.