mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-16 23:55:20 +00:00
Make use of github optional
This commit is contained in:
+13
-9
@@ -24,17 +24,21 @@ 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];
|
||||
|
||||
title = options.title || utils.titleCase(repo);
|
||||
}
|
||||
|
||||
var parts = githubID.split('/', 2);
|
||||
var user = parts[0], repo = parts[1];
|
||||
|
||||
var title = options.title || utils.titleCase(repo);
|
||||
|
||||
return generate.folder(
|
||||
_.extend(options.options || {}, {
|
||||
input: dir,
|
||||
@@ -110,4 +114,4 @@ var buildFiles = function(dir, outputFile, options, masterOptions) {
|
||||
module.exports = {
|
||||
folder: buildFunc,
|
||||
files: buildFiles
|
||||
};
|
||||
};
|
||||
|
||||
@@ -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)
|
||||
}));
|
||||
})
|
||||
})
|
||||
);
|
||||
})
|
||||
|
||||
|
||||
@@ -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;
|
||||
module.exports = Generator;
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user