summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Phillpotts <jphillpotts@scottlogic.co.uk>2014-04-07 10:38:06 +0100
committerJames Phillpotts <jphillpotts@scottlogic.co.uk>2014-04-07 10:38:06 +0100
commit80794997a4ebfc5bf397132ff89ee8c76e99efbe (patch)
tree7b1f922ecb1551c0f8c55ef875a5db9aa90ea2d6
parentec719891a1d652873cb6668d94a141b77adea3df (diff)
downloadgitbook-80794997a4ebfc5bf397132ff89ee8c76e99efbe.zip
gitbook-80794997a4ebfc5bf397132ff89ee8c76e99efbe.tar.gz
gitbook-80794997a4ebfc5bf397132ff89ee8c76e99efbe.tar.bz2
Make use of github optional
-rw-r--r--bin/build.js20
-rw-r--r--lib/generate/index.js8
-rw-r--r--lib/generate/site/index.js4
-rw-r--r--theme/templates/includes/book/header.html5
-rw-r--r--theme/templates/includes/book/summary.html2
5 files changed, 24 insertions, 15 deletions
diff --git a/bin/build.js b/bin/build.js
index 6050b88..9f3ad1d 100644
--- a/bin/build.js
+++ b/bin/build.js
@@ -24,16 +24,20 @@ var buildFunc = function(dir, options) {
return null;
})
.then(function(repoID) {
- var githubID = options.github || repoID;
+ var title = options.title;
- if(!githubID) {
- throw new Error('Needs a githubID (username/repo). Either set repo origin to a github repo or use the -g flag');
- }
+ if (!title) {
+ var githubID = options.github || repoID;
+
+ if(!githubID) {
+ throw new Error('Needs a githubID (username/repo). Either set repo origin to a github repo or use the -g flag');
+ }
- var parts = githubID.split('/', 2);
- var user = parts[0], repo = parts[1];
+ var parts = githubID.split('/', 2);
+ var user = parts[0], repo = parts[1];
- var title = options.title || utils.titleCase(repo);
+ title = options.title || utils.titleCase(repo);
+ }
return generate.folder(
_.extend(options.options || {}, {
@@ -110,4 +114,4 @@ var buildFiles = function(dir, outputFile, options, masterOptions) {
module.exports = {
folder: buildFunc,
files: buildFiles
-}; \ No newline at end of file
+};
diff --git a/lib/generate/index.js b/lib/generate/index.js
index 53ae509..4804548 100644
--- a/lib/generate/index.js
+++ b/lib/generate/index.js
@@ -39,8 +39,8 @@ var generate = function(options) {
theme: path.resolve(__dirname, '../../theme')
});
- if (!options.github || !options.title || !options.input || !options.output) {
- return Q.reject(new Error("Need options: github, title, input, output"));
+ if (!options.title || !options.input || !options.output) {
+ return Q.reject(new Error("Need options: title, input, output"));
}
if (!generators[options.generator]) {
@@ -76,7 +76,7 @@ var generate = function(options) {
// Generate sub-books
.then(function(_langsSummary) {
options.langsSummary = parse.langs(_langsSummary);
-
+
// Generated a book for each valid entry
return Q.all(
_.map(options.langsSummary.list, function(entry) {
@@ -84,7 +84,7 @@ var generate = function(options) {
input: path.join(options.input, entry.path),
output: path.join(options.output, entry.path)
}));
- })
+ })
);
})
diff --git a/lib/generate/site/index.js b/lib/generate/site/index.js
index 1cd63ff..357db93 100644
--- a/lib/generate/site/index.js
+++ b/lib/generate/site/index.js
@@ -47,7 +47,7 @@ Generator.prototype._writeTemplate = function(tpl, options, output) {
title: that.options.title,
description: that.options.description,
- githubAuthor: that.options.github.split("/")[0],
+ githubAuthor: that.options.github ? that.options.github.split("/")[0] : "",
githubId: that.options.github,
githubHost: that.options.githubHost,
@@ -151,4 +151,4 @@ Generator.prototype.finish = function() {
.then(this.writeSearchIndex);
};
-module.exports = Generator; \ No newline at end of file
+module.exports = Generator;
diff --git a/theme/templates/includes/book/header.html b/theme/templates/includes/book/header.html
index 7732b37..5662714 100644
--- a/theme/templates/includes/book/header.html
+++ b/theme/templates/includes/book/header.html
@@ -1,6 +1,8 @@
<div class="book-header">
<!-- Actions Left -->
+ {% if githubId %}
<a href="{{ githubHost }}{{ githubId }}" target="_blank" class="btn pull-left"><i class="fa fa-github-alt"></i></a>
+ {% endif %}
<a href="#" class="btn pull-left toggle-summary"><i class="fa fa-align-justify"></i></a>
<a href="#" class="btn pull-left toggle-search"><i class="fa fa-search"></i></a>
@@ -9,9 +11,10 @@
<a href="#" target="_blank" class="btn pull-right" data-sharing="facebook"><i class="fa fa-facebook"></i></a>
<a href="#" target="_blank" class="btn pull-right" data-sharing="twitter"><i class="fa fa-twitter"></i></a>
+ {% if githubId %}
<a href="{{ githubHost }}{{ githubId }}/stargazers" target="_blank" class="btn pull-right count-star"><i class="fa fa-star-o"></i> Star (<span>-</span>)</a>
<a href="{{ githubHost }}{{ githubId }}/watchers" target="_blank" class="btn pull-right count-watch"><i class="fa fa-eye"></i> Watch (<span>-</span>)</a>
-
+ {% endif %}
<!-- Title -->
<h1><a href="{{ basePath }}/" >{{ title }}</a></h1>
diff --git a/theme/templates/includes/book/summary.html b/theme/templates/includes/book/summary.html
index 485b2ef..cbed38c 100644
--- a/theme/templates/includes/book/summary.html
+++ b/theme/templates/includes/book/summary.html
@@ -3,6 +3,7 @@
<input type="text" placeholder="Search" class="form-control" />
</div>
<ul class="summary">
+ {% if githubId %}
<li>
<a href="{{ githubHost }}{{ githubAuthor }}" target="blank">About the author</a>
</li>
@@ -13,6 +14,7 @@
<a href="{{ githubHost }}{{ githubId }}/edit/master/{{ _input }}" target="blank">Edit and Contribute</a>
</li>
<li class="divider"></li>
+ {% endif %}
<li data-level="0" data-path="index.html">
<a href="{{ basePath }}/"><i class="fa fa-check"></i> Introduction</a>
</li>