diff options
-rw-r--r-- | lib/generate/index.js | 1 | ||||
-rw-r--r-- | templates/includes/book/header.html | 13 | ||||
-rw-r--r-- | templates/includes/book/summary.html | 2 | ||||
-rw-r--r-- | test.js | 15 |
4 files changed, 28 insertions, 3 deletions
diff --git a/lib/generate/index.js b/lib/generate/index.js index c265be3..73d1079 100644 --- a/lib/generate/index.js +++ b/lib/generate/index.js @@ -48,6 +48,7 @@ var generate = function(root, output, options) { root: root, output: output, locals: { + githubAuthor: options.github.split("/")[0], githubId: options.github, title: options.title, summary: summary diff --git a/templates/includes/book/header.html b/templates/includes/book/header.html index 2fd0cb0..c1b6518 100644 --- a/templates/includes/book/header.html +++ b/templates/includes/book/header.html @@ -4,8 +4,8 @@ <a href="#" class="btn pull-left toggle-summary"><i class="fa fa-align-justify"></i> Summary</a> <!-- Actions Right --> - <a href="/star/{{ githubId }}" class="btn pull-right"><i class="fa fa-star-o"></i> Star (0)</a> - <a href="/watch/{{ githubId }}" class="btn pull-right"><i class="fa fa-eye"></i> Watch (0)</a> + <a href="https://github.com/{{ githubId }}/stargazers" target="_blank" class="btn pull-right count-star"><i class="fa fa-star-o"></i> Star (<span>-</span>)</a> + <a href="https://github.com/{{ githubId }}/watchers" target="_blank" class="btn pull-right count-watch"><i class="fa fa-eye"></i> Watch (<span>-</span>)</a> <!-- Title --> @@ -14,9 +14,18 @@ <script> $(document).ready(function() { var $book = $(".book"); + + // Toggle summary $book.find(".book-header .toggle-summary").click(function(e) { e.preventDefault(); $book.toggleClass("with-summary"); }); + + // Star and watch count + $.getJSON("https://api.github.com/repos/{{ githubId }}") + .done(function(repo) { + $book.find(".count-star span").text(repo.stargazers_count); + $book.find(".count-watch span").text(repo.subscribers_count); + }); }); </script>
\ No newline at end of file diff --git a/templates/includes/book/summary.html b/templates/includes/book/summary.html index 99c226c..52eeb2f 100644 --- a/templates/includes/book/summary.html +++ b/templates/includes/book/summary.html @@ -4,7 +4,7 @@ <a href="{{ basePath }}/README.html">Introduction</a> </li> <li> - <a href="https://github.com/{{ owner }}" target="blank">About the author</a> + <a href="https://github.com/{{ githubAuthor }}" target="blank">About the author</a> </li> <li class="divider"></li> {% for item in summary.chapters %} @@ -0,0 +1,15 @@ +var path = require("path"); +var generate = require("./lib/generate"); + +generate.folder( + path.resolve(__dirname, "../jsbook"), + path.resolve("../output"), + { + title: "Javascript", + github: "GitbookIO/javascript" + } +).then(function(output) { + console.log(output) +}, function(err) { + console.log(err.stack, err); +})
\ No newline at end of file |