mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-24 03:16:40 +00:00
Tidy up use of github, and make error more descriptive
This commit is contained in:
+7
-8
@@ -25,18 +25,17 @@ var buildFunc = function(dir, options) {
|
||||
})
|
||||
.then(function(repoID) {
|
||||
var title = options.title;
|
||||
var githubID = options.github || repoID;
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
if (!title && !githubID) {
|
||||
throw new Error('Needs either a title or a githubID (username/repo).\n'+
|
||||
' If using github, either set repo origin to a github repo or use the -g flag.\n'+
|
||||
' For title, use the -t flag.');
|
||||
} else if (!title) {
|
||||
var parts = githubID.split('/', 2);
|
||||
var user = parts[0], repo = parts[1];
|
||||
|
||||
title = options.title || utils.titleCase(repo);
|
||||
title = utils.titleCase(repo);
|
||||
}
|
||||
|
||||
return generate.folder(
|
||||
|
||||
+12
-9
@@ -21379,9 +21379,6 @@ require([
|
||||
$(document).ready(function() {
|
||||
var $book = state.$book;
|
||||
|
||||
// Initialize storage
|
||||
storage.setBaseKey(state.githubId);
|
||||
|
||||
// Init sidebar
|
||||
sidebar.init();
|
||||
|
||||
@@ -21391,12 +21388,17 @@ require([
|
||||
// Init keyboard
|
||||
keyboard.init();
|
||||
|
||||
// Star and watch count
|
||||
$.getJSON("https://api.github.com/repos/"+state.githubId)
|
||||
.done(function(repo) {
|
||||
$book.find(".count-star span").text(repo.stargazers_count);
|
||||
$book.find(".count-watch span").text(repo.subscribers_count);
|
||||
});
|
||||
if (state.githubId) {
|
||||
// Initialize storage
|
||||
storage.setBaseKey(state.githubId);
|
||||
|
||||
// Star and watch count
|
||||
$.getJSON("https://api.github.com/repos/"+state.githubId)
|
||||
.done(function(repo) {
|
||||
$book.find(".count-star span").text(repo.stargazers_count);
|
||||
$book.find(".count-watch span").text(repo.subscribers_count);
|
||||
});
|
||||
}
|
||||
|
||||
// Bind exercise
|
||||
exercise.init();
|
||||
@@ -21411,5 +21413,6 @@ require([
|
||||
$(".book-body").focus();
|
||||
});
|
||||
});
|
||||
|
||||
define("app", function(){});
|
||||
|
||||
|
||||
@@ -12,7 +12,9 @@
|
||||
{# Cover #}
|
||||
<section id="cover">
|
||||
<h1>{{ title }}</h1>
|
||||
{% if githubId %}
|
||||
<h2>By <a href="{{ githubHost }}{{ githubAuthor }}">@{{ githubAuthor }}</a></h2>
|
||||
{% endif %}
|
||||
</section>
|
||||
|
||||
{# Summary #}
|
||||
@@ -116,4 +118,4 @@
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block javascript %}{% endblock %}
|
||||
{% block javascript %}{% endblock %}
|
||||
|
||||
@@ -2,7 +2,11 @@
|
||||
|
||||
{% block title %}{{ progress.current.title }}{% parent %}{% endblock %}
|
||||
{% block content %}
|
||||
{% if githubId %}
|
||||
<div class="book" data-github="{{ githubId }}" data-level="{{ progress.current.level }}" data-basepath="{{ basePath }}" data-revision="{{ revision }}">
|
||||
{% else %}
|
||||
<div class="book" data-level="{{ progress.current.level }}" data-basepath="{{ basePath }}" data-revision="{{ revision }}">
|
||||
{% endif %}
|
||||
{% include "includes/book/header.html" %}
|
||||
{% include "includes/book/summary.html" %}
|
||||
<div class="book-body" tabindex="-1">
|
||||
@@ -25,4 +29,4 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user