Compare commits

...

36 Commits

Author SHA1 Message Date
Aaron O'Mullan 633e52c4be Bump version to 0.7.1 2014-08-08 15:37:03 -07:00
Aaron O'Mullan 1512bcf808 Update fs-extra to 0.10.0
Fixes potential race condition on copies
2014-08-08 15:31:49 -07:00
Samy Pessé 4e46d088ca Add build for search results 2014-08-05 09:47:08 -07:00
Samy Pessé 388c7ffd32 Merge pull request #396 from codepiano/hold-search-keyword
keep the search result list after user click a link
2014-08-05 09:44:54 -07:00
codepiano 7ba8653935 keep the search result list after user click a link
Record search keyword to LocalStorage, when navigate to a new url,fetch
keyword from LocalStorage, init the search input element,then filter the
sidebar menu.
So User can iterator the result list without type the keyword every
time.
2014-08-05 15:14:10 +08:00
Samy Pessé a4403aad1e Add changes for 0.7.0 2014-08-01 14:01:20 -07:00
Samy Pessé b629b78dba Bump version to 0.7.0 2014-08-01 13:58:36 -07:00
Samy Pessé f62c218735 Fix #278: Add page break between chapters/articles 2014-08-01 13:55:19 -07:00
Aaron O'Mullan 725510028f Use marked-text-renderer@0.1.0 2014-08-01 00:09:45 -07:00
Aaron O'Mullan ad7927242d Add comments to default introduction chapter code
Fixes #388
2014-07-31 08:43:57 -07:00
Aaron O'Mullan 5692bdd229 Merge pull request #386 from codepiano/china-social-network-sharing
add sharing to weibo.com.
2014-07-31 01:41:56 -07:00
codepiano 3402746719 add sharing to weibo.com.
google、facebook and twitter are block by GFW in China,Chinese can
not visit these websites.
add 'weibo' config in option links.sharing,the share link will not be
used by default,users should set the value of 'weibo' to true to turn
on sharing to weibo.com.
2014-07-31 16:31:31 +08:00
Aaron O'Mullan 30a8414b06 Switch to graceful-fs, fix #373 2014-07-30 20:45:33 -07:00
Aaron O'Mullan 9d46899ea7 Replace "marked" with "kramed" 2014-07-30 16:17:47 -07:00
Samy Pessé 58f14fd9ca Fix font settings apply 2014-07-30 11:17:28 -07:00
Samy Pessé b6af14b13e Remove github count stars and watchers 2014-07-30 10:43:10 -07:00
Aaron O'Mullan ba2134c480 Bump version to 0.6.3 2014-07-30 10:23:11 -07:00
Aaron O'Mullan 4705548860 Fix resource normalization in when loading plugins
Fixes #384
2014-07-30 10:17:07 -07:00
Samy Pessé 7d51ae3689 Add changelogs for 0.6.2 2014-07-30 00:26:44 -07:00
Aaron O'Mullan b9360de3e3 Bump version to 0.6.2 2014-07-30 00:22:49 -07:00
Aaron O'Mullan 9f241457bb Fix minor issues with new plugin additions 2014-07-29 23:45:54 -07:00
Aaron O'Mullan 60a7c28e66 Support generating a plugin's book info dynamically 2014-07-29 21:50:26 -07:00
Samy Pessé 5dff9b795e Fix #345: Improve navigation on dark theme 2014-07-29 21:33:47 -07:00
Aaron O'Mullan 0134677e0e Improve path normalization when parsing SUMMARY.md 2014-07-29 20:49:11 -07:00
Aaron O'Mullan 39ef4fa199 Add invalid paths in SUMMARY.md fixture
To test for correct path normalization
2014-07-29 20:46:14 -07:00
Samy Pessé b507a30301 Bump version to 0.6.1 2014-07-23 16:49:57 -07:00
Samy Pessé 539c2d0c57 Update plugin-mathjax@0.0.4 2014-07-23 16:28:38 -07:00
Samy Pessé aa6f3530f9 Fix readme spacing 2014-07-22 23:28:13 -07:00
Samy Pessé 98057af219 Merge pull request #372 from justanotheranonymoususer/patch-1
Update summary.html (fixed an HTML typo)
2014-07-20 14:04:12 -07:00
justanotheranonymoususer bb48c8233c Update summary.html 2014-07-20 23:57:56 +03:00
Aaron O'Mullan 8f14db64df Merge pull request #370 from nightwing/patch-1
Add keyboard shortcut for submitting exercise
2014-07-15 21:33:58 -07:00
Harutyun Amirjanyan 37d40dc66c Add keyboard shortcut for submitting exercise 2014-07-16 08:07:22 +04:00
Samy Pessé 6c96680cca Merge pull request #366 from shaform/ignore
Ignore config files by default in fs.list
2014-07-14 10:08:29 -07:00
Shaform 4e475857d5 Ignore config files by default in fs.list 2014-07-13 08:40:23 -07:00
Samy Pessé f8ff0453dd Merge pull request #359 from jcouyang/patch-1
add jsbin embedded plugin
2014-07-12 07:02:18 -07:00
Jichao Ouyang cd382dc8fc add jsbin embedded support 2014-07-12 21:42:52 +08:00
26 changed files with 276 additions and 162 deletions
+15
View File
@@ -1,5 +1,20 @@
# Release notes
## 0.7.1
- Update `fs-extra` to `0.10.0` (fixes potential race conditions)
## 0.7.0
- Add page break in ebook (pdf, epub, mobi) between chapters/articles
- Start using kramed instead of marked
- Fix display of inline math
- Switch to graceful-fs to fix EMFILE errors
- Add sharing to weibo.com
## 0.6.2
- Support generating a plugin's book info dynamically
- Improve navigation on dark theme
- Improve path normalization when parsing SUMMARY.md
## 0.6.0
- Generate header id the same as github
- Custom links can be added at top of sidebar
+5 -4
View File
@@ -92,10 +92,10 @@ Here are the options that can be stored in this file:
"issues": null,
"contribute": null,
// Custom links at top of sidebar
"custom": {
"Custom link name": "https://customlink.com"
},
// Custom links at top of sidebar
"custom": {
"Custom link name": "https://customlink.com"
},
// Sharing links
"sharing": {
@@ -259,6 +259,7 @@ Plugins can used to extend your book's functionality. Read [GitbookIO/plugin](ht
* [Bootstrap JavaScript plugins](https://github.com/mrpotes/gitbook-plugin-bootstrapjs): Use the [Bootstrap JavaScript plugins](http://getbootstrap.com/javascript) in your online GitBook
* [Piwik Open Analytics](https://github.com/emmanuel-keller/gitbook-plugin-piwik): Piwik Open Analytics tracking for your book
* [Heading Anchors](https://github.com/rlmv/gitbook-plugin-anchors): Add linkable Github-style anchors to headings
* [JSBin](https://github.com/jcouyang/gitbook-plugin-jsbin): Ebedded jsbin frame into your book
#### Debugging
+5 -2
View File
@@ -4,7 +4,7 @@ var Q = require("q");
var _ = require("lodash");
var exec = require('child_process').exec;
var fs = require("fs");
var fs = require('graceful-fs');
var parse = require("../../parse");
var BaseGenerator = require("../page");
var stringUtils = require("../../utils/string");
@@ -35,9 +35,12 @@ Generator.prototype.finish = function() {
"--title": that.options.title,
"--comments": that.options.description,
"--authors": that.options.author,
"--chapter": "descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter ')]",
"--chapter-mark": "pagebreak",
"--level1-toc": "descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter-1 ')]",
"--level2-toc": "descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter-2 ')]",
"--level3-toc": "descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter-3 ')]"
"--level3-toc": "descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter-3 ')]",
"--no-chapters-in-toc": true
};
if (format == "pdf") {
+6 -1
View File
@@ -1,5 +1,5 @@
var Q = require("q");
var fs = require("fs");
var fs = require('graceful-fs');
var fsExtra = require("fs-extra");
var Ignore = require("fstream-ignore");
@@ -30,6 +30,11 @@ var getFiles = function(path) {
'*.pdf',
'*.epub',
'*.mobi',
// Skip config files
'.ignore',
'.bookignore',
'book.json',
], '__custom_stuff');
// Push each file to our list
+2 -2
View File
@@ -14,13 +14,13 @@ var BaseGenerator = function(options) {
};
BaseGenerator.prototype.callHook = function(name, data) {
return this.plugins.hook(name, this, data);
return this.plugins.hook(name, data);
};
BaseGenerator.prototype.loadPlugins = function() {
var that = this;
return Plugin.fromList(this.options.plugins, this.options.input)
return Plugin.fromList(this.options.plugins, this.options.input, this)
.then(function(_plugins) {
that.plugins = _plugins;
+150 -78
View File
@@ -10,11 +10,15 @@ var pkg = require("../../package.json");
var RESOURCES = ["js", "css"];
var Plugin = function(name, root) {
var Plugin = function(name, root, generator) {
this.name = name;
this.root = root;
this.packageInfos = {};
this.infos = {};
this.generator = generator;
// Bind methods
_.bindAll(this);
_.each([
"gitbook-plugin-"+name,
@@ -43,28 +47,67 @@ Plugin.prototype.load = function(name, baseDir) {
}
};
// Return resources
Plugin.prototype.getResources = function(resource) {
if (!this.infos.book || !this.infos.book[resource]) {
return [];
Plugin.prototype.normalizeResource = function(resource) {
// Parse the resource path
var parsed = url.parse(resource);
// This is a remote resource
// so we will simply link to using it's URL
if (parsed.protocol) {
return {
"url": resource
};
}
return _.chain(this.infos.book[resource])
.map(function(resource) {
var parsed = url.parse(resource);
if (parsed.protocol) return {"url": resource}
else return { "path": this.name+"/"+resource };
}.bind(this))
.value();
// This will be copied over from disk
// and shipped with the book's build
return { "path": this.name+"/"+resource };
};
// Return resources
Plugin.prototype._getResources = function() {
var book = this.infos.book;
// Nothing specified, fallback to default
if (!book) {
return Q({});
}
// Dynamic function
if(typeof book === "function") {
// Call giving it the context of our generator
return Q().then(book.bind(this.generator));
}
// Plain data object
return Q(_.cloneDeep(book));
};
// Normalize resources and return them
Plugin.prototype.getResources = function() {
var that = this;
return this._getResources()
.then(function(resources) {
_.each(RESOURCES, function(resourceType) {
resources[resourceType] = (resources[resourceType] || []).map(that.normalizeResource);
});
return resources;
});
};
// Test if it's a valid plugin
Plugin.prototype.isValid = function() {
return (
this.packageInfos
&& this.packageInfos.name
&& this.packageInfos.engines
&& this.packageInfos.engines.gitbook
&& semver.satisfies(pkg.version, this.packageInfos.engines.gitbook)
this.packageInfos &&
this.packageInfos.name &&
this.packageInfos.engines &&
this.packageInfos.engines.gitbook &&
semver.satisfies(pkg.version, this.packageInfos.engines.gitbook)
);
};
@@ -74,7 +117,10 @@ Plugin.prototype.resolveFile = function(filename) {
};
// Resolve file path
Plugin.prototype.callHook = function(name, context, data) {
Plugin.prototype.callHook = function(name, data) {
// Our generator will be the context to apply
var context = this.generator;
var hookFunc = this.infos.hooks? this.infos.hooks[name] : null;
data = data || {};
@@ -86,18 +132,20 @@ Plugin.prototype.callHook = function(name, context, data) {
});
};
// Has assets
Plugin.prototype.hasAssets = function(out) {
return (this.infos.book && this.infos.book.assets);
};
// Copy plugin assets fodler
Plugin.prototype.copyAssets = function(out) {
if (!this.hasAssets()) return Q();
return fs.copy(
this.resolveFile(this.infos.book.assets),
out
);
var that = this;
return this.getResources().get('assets')
.then(function(assets) {
// Assets are undefined
if(!assets) return false;
return fs.copy(
that.resolveFile(assets),
out
).then(_.constant(true));
}, _.constant(false));
};
@@ -114,7 +162,7 @@ Plugin.normalizeNames = function(names) {
return name.length > 0 && name[0] == "-";
})
.map(function(name) {
return name.slice(1)
return name.slice(1);
})
.value();
@@ -133,69 +181,93 @@ Plugin.normalizeNames = function(names) {
};
// Extract data from a list of plugin
Plugin.fromList = function(names, root) {
Plugin.fromList = function(names, root, generator) {
var failed = [];
// Load plugins
var plugins = _.map(names, function(name) {
var plugin = new Plugin(name, root);
var plugin = new Plugin(name, root, generator);
if (!plugin.isValid()) failed.push(name);
return plugin;
});
if (_.size(failed) > 0) return Q.reject(new Error("Error loading plugins: "+failed.join(",")));
// Get all resources
var resources = _.chain(RESOURCES)
.map(function(resource) {
return [
resource,
_.chain(plugins)
.map(function(plugin) {
return plugin.getResources(resource);
})
.flatten()
.value()
];
})
.object()
.value();
resources.html = {}
// The raw resources extracted from each plugin
var pluginResources;
_.each(plugins, function(plugin) {
if (!plugin.infos.book || !plugin.infos.book.html) return;
var html = plugin.infos.book.html || {};
_.each(html, function(code, key) {
if (!_.isFunction(code)) code = _.constant(code);
if (!resources.html[key]) resources.html[key] = [];
resources.html[key].push(code);
// Get resources of plugins
return Q.all(_.map(plugins, function(plugin) {
return plugin.getResources();
}))
// Extract resources out
// css, js, etc ...
.then(function(resources) {
pluginResources = resources;
// Group by resource types
return _.chain(RESOURCES)
.map(function(resourceType) {
// Get resources from all the plugins for this current type
return [
// Key
resourceType,
// Value
_.chain(resources)
.pluck(resourceType)
.compact()
.flatten()
.value()
];
})
});
return Q({
'list': plugins,
'resources': resources,
'hook': function(name, context, data) {
return _.reduce(plugins, function(prev, plugin) {
return prev.then(function(ret) {
return plugin.callHook(name, context, ret);
})
}, Q(data));
},
'template': function(name) {
var withTpl = _.find(plugins, function(plugin) {
return (plugin.infos.templates
&& plugin.infos.templates[name]);
.object()
.value();
})
// Extract html snippets
.then(function(resources) {
// Map of html resources by name added by each plugin
resources.html = pluginResources.reduce(function(accu, resource) {
var html = (resource && resource.html) || {};
_.each(html, function(code, key) {
// Turn into function if not one already
if (!_.isFunction(code)) code = _.constant(code);
// Append
accu[key] = (accu[key] || []).concat([code]);
});
if (!withTpl) return null;
return withTpl.resolveFile(withTpl.infos.templates[name]);
},
'html': function(tag, context, options) {
return _.map(resources.html[tag] || [], function(code) {
return code.call(context, options);
}).join("\n");
}
return accu;
}, {});
return resources;
})
// Return big multi-plugin object
.then(function(resources) {
return {
'list': plugins,
'resources': resources,
'hook': function(name, data) {
return _.reduce(plugins, function(prev, plugin) {
return prev.then(function(ret) {
return plugin.callHook(name, ret);
});
}, Q(data));
},
'template': function(name) {
var withTpl = _.find(plugins, function(plugin) {
return (
plugin.infos.templates &&
plugin.infos.templates[name]
);
});
if (!withTpl) return null;
return withTpl.resolveFile(withTpl.infos.templates[name]);
},
'html': function(tag, context, options) {
return _.map(resources.html[tag] || [], function(code) {
return code.call(context, options);
}).join("\n");
}
};
});
};
+4 -4
View File
@@ -198,16 +198,16 @@ Generator.prototype.copyAssets = function() {
.then(function() {
return Q.all(
_.map(that.plugins.list, function(plugin) {
if (!plugin.hasAssets()) return Q();
var pluginAssets = path.join(that.options.output, "gitbook/plugins/", plugin.name);
return plugin.copyAssets(pluginAssets)
.then(function() {
.then(function(copiedStuff) {
// Nothing was copied
if(!copiedStuff) { return; }
return that.manifest.addFolder(pluginAssets, "gitbook/plugins/"+plugin.name);
});
})
);
})
});
};
// Dump search index to disk
+4 -4
View File
@@ -2,7 +2,7 @@ var Q = require("q");
var _ = require("lodash");
var lunr = require('lunr');
var marked = require('marked');
var kramed = require('kramed');
var textRenderer = require('marked-text-renderer');
@@ -28,14 +28,14 @@ Indexer.prototype.text = function(nodes) {
// Copy section
var section = _.toArray(nodes);
// marked's Render expects this, we don't use it yet
// kramed's Render expects this, we don't use it yet
section.links = {};
var options = _.extend({}, marked.defaults, {
var options = _.extend({}, kramed.defaults, {
renderer: this.renderer
});
return marked.parser(section, options);
return kramed.parser(section, options);
};
Indexer.prototype.addSection = function(path, section) {
+1 -1
View File
@@ -1,4 +1,4 @@
var fs = require('fs');
var fs = require('graceful-fs');
var path = require('path');
module.exports = function(code, folder) {
+2 -2
View File
@@ -1,5 +1,5 @@
var _ = require('lodash');
var marked = require('marked');
var kramed = require('kramed');
// Split a page up into sections (lesson, exercises, ...)
function splitSections(nodes) {
@@ -88,7 +88,7 @@ function sectionId(section, idx) {
function lexPage(src) {
// Lex file
var nodes = marked.lexer(src);
var nodes = kramed.lexer(src);
return _.chain(splitSections(nodes))
.map(function(section, idx) {
+3 -3
View File
@@ -1,5 +1,5 @@
var _ = require('lodash');
var marked = require('marked');
var kramed = require('kramed');
var hljs = require('highlight.js');
var lex = require('./lex');
@@ -18,7 +18,7 @@ function render(section, _options) {
section.links = links;
// Build options using defaults and our custom renderer
var options = _.extend({}, marked.defaults, {
var options = _.extend({}, kramed.defaults, {
renderer: renderer(null, _options),
// Synchronous highlighting with highlight.js
@@ -36,7 +36,7 @@ function render(section, _options) {
}
});
return marked.parser(section, options);
return kramed.parser(section, options);
}
function quizQuestion(node) {
+3 -3
View File
@@ -1,5 +1,5 @@
var _ = require('lodash');
var marked = require('marked');
var kramed = require('kramed');
var textRenderer = require('marked-text-renderer');
function extractFirstNode(nodes, nType) {
@@ -18,7 +18,7 @@ function parseReadme(src) {
var renderer = textRenderer();
// Parse content
nodes = marked.lexer(src);
nodes = kramed.lexer(src);
title = extractFirstNode(nodes, "heading") || '';
description = extractFirstNode(nodes, "paragraph") || '';
@@ -28,7 +28,7 @@ function parseReadme(src) {
return _.unescape(text.replace(/(\r\n|\n|\r)/gm, ""));
},
function(text) {
return marked.parse(text, _.extend({}, marked.defaults, {
return kramed.parse(text, _.extend({}, kramed.defaults, {
renderer: renderer
}));
}
+2 -2
View File
@@ -6,7 +6,7 @@ var codeInclude = require('./code_include');
var path = require('path');
var marked = require('marked');
var kramed = require('kramed');
var rendererId = 0;
@@ -21,7 +21,7 @@ function GitBookRenderer(options, extra_options) {
this.id = rendererId++;
this.quizIndex = 0;
}
inherits(GitBookRenderer, marked.Renderer);
inherits(GitBookRenderer, kramed.Renderer);
GitBookRenderer.prototype._unsanitized = function(href) {
var prot = '';
+10 -6
View File
@@ -1,5 +1,5 @@
var _ = require('lodash');
var marked = require('marked');
var kramed = require('kramed');
// Utility function for splitting a list into groups
@@ -43,7 +43,7 @@ function listSplit(nodes, start_type, end_type) {
}
// Get the biggest list
// out of a list of marked nodes
// out of a list of kramed nodes
function filterList(nodes) {
return _.chain(nodes)
.toArray()
@@ -64,7 +64,7 @@ function filterList(nodes) {
// supports extracting links
function parseTitle(src, nums) {
// Check if it's a link
var matches = marked.InlineLexer.rules.link.exec(src);
var matches = kramed.InlineLexer.rules.link.exec(src);
var level = nums.join('.');
@@ -81,8 +81,10 @@ function parseTitle(src, nums) {
title: matches[1],
level: level,
// Replace .md references with .html
path: matches[2].replace(/\\/g, '/'),
// Normalize path
// 1. Convert Window's "\" to "/"
// 2. Remove leading "/" if exists
path: matches[2].replace(/\\/g, '/').replace(/^\/+/, ''),
};
}
@@ -100,6 +102,7 @@ function parseChapter(nodes, nums) {
function defaultChapterList(chapterList) {
var first = _.first(chapterList);
// Check if introduction node was specified in SUMMARY.md
if (first) {
var chapter = parseChapter(first, [0]);
@@ -109,13 +112,14 @@ function defaultChapterList(chapterList) {
}
}
// It wasn't specified, so add in default
return [
[ { type: 'text', text: '[Introduction](README.md)' } ]
].concat(chapterList);
}
function listGroups(src) {
var nodes = marked.lexer(src);
var nodes = kramed.lexer(src);
// Get out groups of lists
return listSplit(
+6 -5
View File
@@ -1,20 +1,21 @@
{
"name": "gitbook",
"version": "0.6.0",
"version": "0.7.1",
"homepage": "http://www.gitbook.io/",
"description": "Library and cmd utility to generate GitBooks",
"main": "lib/index.js",
"dependencies": {
"q": "1.0.1",
"lodash": "2.4.1",
"marked": "0.3.2",
"marked-text-renderer": "0.0.1",
"kramed": "0.4.0",
"marked-text-renderer": "0.1.0",
"lunr": "0.5.2",
"swig": "1.3.2",
"send": "0.2.0",
"fstream-ignore": "0.0.7",
"commander": "2.2.0",
"fs-extra": "0.8.1",
"graceful-fs": "3.0.2",
"fs-extra": "0.10.0",
"highlight.js": "8.0.0",
"tmp": "0.0.23",
"semver": "2.2.1",
@@ -22,7 +23,7 @@
"resolve": "0.6.3",
"tiny-lr-fork": "0.0.5",
"gitbook-plugin": "0.0.2",
"gitbook-plugin-mathjax": "0.0.3",
"gitbook-plugin-mathjax": "0.0.4",
"gitbook-plugin-livereload": "0.0.1"
},
"devDependencies": {
+2 -2
View File
@@ -3,8 +3,8 @@
* [Chapter 1](chapter-1/README.md)
* [Article 1](chapter-1/ARTICLE1.md)
* [Article 2](chapter-1/ARTICLE2.md)
* [article 1.2.1](chapter-1/ARTICLE-1-2-1.md)
* [article 1.2.2](chapter-1/ARTICLE-1-2-2.md)
* [article 1.2.1](\chapter-1\ARTICLE-1-2-1.md)
* [article 1.2.2](/chapter-1/ARTICLE-1-2-2.md)
* [Chapter 2](chapter-2/README.md)
* [Chapter 3](chapter-3/README.md)
* [Chapter 4](chapter-4/README.md)
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+9 -1
View File
@@ -18,6 +18,14 @@ define([
editor.setTheme("ace/theme/tomorrow");
editor.getSession().setUseWorker(false);
editor.getSession().setMode("ace/mode/javascript");
editor.commands.addCommand({
name: "submit",
bindKey: "Ctrl-Return|Cmd-Return",
exec: function() {
$exercise.find(".action-submit").click();
}
});
// Submit: test code
$exercise.find(".action-submit").click(function(e) {
@@ -52,4 +60,4 @@ define([
init: init,
prepare: prepareExercise
};
});
});
+7 -23
View File
@@ -6,10 +6,10 @@ define([
"core/progress",
"core/exercise",
"core/quiz",
"core/loading"
], function($, URL, events, state, progress, exercises, quiz, loading) {
"core/loading",
"core/search"
], function($, URL, events, state, progress, exercises, quiz, loading, search) {
var prev, next;
var githubCountStars, githubCountWatch;
var usePushState = (typeof history.pushState !== "undefined");
@@ -56,6 +56,8 @@ define([
// Update state
state.update($("html"));
// recover search keyword
search.recover();
preparePage();
})
.fail(function (e) {
@@ -63,11 +65,6 @@ define([
}));
};
var updateGitHubCounts = function() {
$(".book-header .count-star span").text(githubCountStars);
$(".book-header .count-watch span").text(githubCountWatch);
};
var updateNavigationPosition = function() {
var bodyInnerWidth, pageWrapperWidth;
@@ -95,20 +92,6 @@ define([
// Focus on content
$pageWrapper.focus();
// Update GitHub count
if (state.githubId) {
if (githubCountStars) {
updateGitHubCounts();
} else {
$.getJSON("https://api.github.com/repos/"+state.githubId)
.done(function(repo) {
githubCountStars = repo.stargazers_count;
githubCountWatch = repo.subscribers_count;
updateGitHubCounts();
});
}
}
// Send to mixpanel
events.trigger("page.change");
};
@@ -166,4 +149,5 @@ define([
goNext: goNext,
goPrev: goPrev
};
});
});
+18 -2
View File
@@ -81,18 +81,34 @@ define([
}
if (q.length == 0) {
sidebar.filter(null);
storage.remove("keyword");
} else {
var results = search(q);
sidebar.filter(
_.pluck(results, "path")
);
storage.set("keyword", q);
}
})
};
// filter sidebar menu with current search keyword
var recoverSearch = function() {
var keyword = storage.get("keyword", "");
if(keyword.length > 0) {
if(!isSearchOpen()){
toggleSearch();
}
sidebar.filter(_.pluck(search(keyword), "path"));
}
$(".book-search input").val(keyword);
};
return {
init: init,
search: search,
toggle: toggleSearch
toggle: toggleSearch,
recover:recoverSearch
};
});
});
+4 -1
View File
@@ -13,6 +13,9 @@ define([
},
"google-plus": function($el) {
window.open("https://plus.google.com/share?url="+encodeURIComponent(url))
},
"weibo": function($el) {
window.open("http://service.weibo.com/share/share.php?content=utf-8&url="+encodeURIComponent(url)+"&title="+encodeURIComponent(title))
}
};
@@ -30,4 +33,4 @@ define([
return {
init: init
};
});
});
+6 -6
View File
@@ -103,27 +103,27 @@
}
&.font-size-0 {
.book-body {
.book-body .page-inner section {
font-size:@s-font-size;
}
}
&.font-size-1 {
.book-body {
.book-body .page-inner section {
font-size:@m-font-size;
}
}
&.font-size-2 {
.book-body {
.book-body .page-inner section {
font-size:@l-font-size;
}
}
&.font-size-3 {
.book-body {
&.font-size-3{
.book-body .page-inner section {
font-size:@xl-font-size;
}
}
&.font-size-4 {
.book-body {
.book-body .page-inner section {
font-size:@xxl-font-size;
}
}
+7 -3
View File
@@ -49,10 +49,14 @@
}
}
.book.color-theme-1 .book-body {
.navigation:hover{
}
}
.book.color-theme-2 .book-body {
.navigation:hover{
.navigation {
color: rgba(255, 255, 255, 0.4);
&:hover {
color: rgba(255, 255, 255, 0.9);
}
}
}
+2 -4
View File
@@ -21,10 +21,8 @@
{% if options.links.sharing.twitter !== false %}
<a href="#" target="_blank" class="btn pull-right twitter-sharing-link sharing-link" data-sharing="twitter" aria-label="Share on Twitter"><i class="fa fa-twitter"></i></a>
{% endif %}
{% if githubId %}
<a href="{{ githubHost }}{{ githubId }}/stargazers" target="_blank" class="btn pull-right count-star hidden-xs"><i class="fa fa-star-o"></i> Star (<span>-</span>)</a>
<a href="{{ githubHost }}{{ githubId }}/watchers" target="_blank" class="btn pull-right count-watch hidden-xs"><i class="fa fa-eye"></i> Watch (<span>-</span>)</a>
{% if options.links.sharing.weibo === true %}
<a href="#" target="_blank" class="btn pull-right twitter-sharing-link sharing-link" data-sharing="weibo" aria-label="Share on Weibo"><i class="fa fa-weibo"></i></a>
{% endif %}
<!-- Title -->
+1 -1
View File
@@ -48,7 +48,7 @@
{% if options.links.issues !== false && (options.links.issues || githubId) %}
{% set _divider = true %}
<li>
<a href="{{ options.links.issues|default(githubHost+githubId+"/issues") }}" target="blank"class="issues-link">Questions and Issues</a>
<a href="{{ options.links.issues|default(githubHost+githubId+"/issues") }}" target="blank" class="issues-link">Questions and Issues</a>
</li>
{% endif %}