Compare commits

...

16 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
18 changed files with 81 additions and 64 deletions
+10
View File
@@ -1,5 +1,15 @@
# 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
+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") {
+1 -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");
+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 = '';
+6 -4
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('.');
@@ -102,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]);
@@ -111,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(
+5 -4
View File
@@ -1,20 +1,21 @@
{
"name": "gitbook",
"version": "0.6.3",
"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",
+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
+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;
}
}
+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 -->