Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Vaporbook
committed
Nov 22, 2012
0 parents
commit 8862c17
Showing
6 changed files
with
351 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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. |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
module.exports = require('./lib/epub-tmpl.js'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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; | |||
|
|||
} | |||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,6 @@ | |||
|
|||
var tmpl = require('../lib/epub-tmpl.js'); | |||
|
|||
var html = tmpl.getTemplate('read'); | |||
|
|||
console.log(html); |