summaryrefslogtreecommitdiffstats
path: root/lib/generate/site/index.js
diff options
context:
space:
mode:
authorShaform <shaform@gmail.com>2014-06-17 22:08:46 +0800
committerShaform <shaform@gmail.com>2014-06-17 22:08:46 +0800
commit6bbefad24e6aa4a5b51b4b21bdf30b73f8cb4d41 (patch)
treed2efbbb62f9746b19b683c11a302c9afe385a2be /lib/generate/site/index.js
parent1f4cf33dd08b439cadb5c649654ecd6d3f4b399d (diff)
parentd6eb8e4c6042262408c3c0b8d67bccecfa4bf882 (diff)
downloadgitbook-6bbefad24e6aa4a5b51b4b21bdf30b73f8cb4d41.zip
gitbook-6bbefad24e6aa4a5b51b4b21bdf30b73f8cb4d41.tar.gz
gitbook-6bbefad24e6aa4a5b51b4b21bdf30b73f8cb4d41.tar.bz2
Merge remote-tracking branch 'upstream/master' into ref_links
Diffstat (limited to 'lib/generate/site/index.js')
-rw-r--r--lib/generate/site/index.js23
1 files changed, 7 insertions, 16 deletions
diff --git a/lib/generate/site/index.js b/lib/generate/site/index.js
index da65152..b59c01c 100644
--- a/lib/generate/site/index.js
+++ b/lib/generate/site/index.js
@@ -2,26 +2,16 @@ var util = require("util");
var path = require("path");
var Q = require("q");
var _ = require("lodash");
-var swig = require('swig');
+var swig = require("../template");
var fs = require("../fs");
var parse = require("../../parse");
var BaseGenerator = require("../generator");
-
+var links = require("../../utils/links");
var indexer = require('./search_indexer');
var Manifest = require('../manifest');
-// Swig filter for returning the count of lines in a code section
-swig.setFilter('lines', function(content) {
- return content.split('\n').length;
-});
-// Swig filter for returning a link to the associated html file of a markdown file
-swig.setFilter('mdLink', function(link) {
- var link = link.replace(".md", ".html");
- if (link == "README.html") link = "index.html";
- return link;
-});
var Generator = function() {
BaseGenerator.apply(this, arguments);
@@ -63,7 +53,6 @@ Generator.prototype._writeTemplate = function(tpl, options, output, interpolate)
var that = this;
interpolate = interpolate || _.identity;
-
return Q()
.then(function(sections) {
return tpl(_.extend({
@@ -163,7 +152,7 @@ Generator.prototype.convertFile = function(content, _input) {
content: page.sections,
basePath: basePath,
- staticBase: path.join(basePath, "gitbook"),
+ staticBase: links.join(basePath, "gitbook"),
}, output, function(html) {
page.content = html;
@@ -199,7 +188,7 @@ Generator.prototype.copyAssets = function() {
path.join(that.options.output, "gitbook")
)
- // Add to cach manifest
+ // Add to cache manifest
.then(function() {
return that.manifest.addFolder(path.join(that.options.output, "gitbook"), "gitbook");
})
@@ -238,7 +227,9 @@ Generator.prototype.writeCacheManifest = function() {
};
Generator.prototype.finish = function() {
- var deferred = this.copyAssets().then(this.writeSearchIndex);
+ var deferred = this.copyAssets()
+ .then(this.copyCover)
+ .then(this.writeSearchIndex);
if (this.options.cache !== false) {
deferred = deferred.then(this.writeCacheManifest);