summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2014-03-31 12:51:27 -0700
committerSamy Pessé <samypesse@gmail.com>2014-03-31 12:51:27 -0700
commitd44fd91181a844d6fb6d22cfe3da611aa7b783e3 (patch)
tree2f71e7c7fc3565d9ec047da5596aa8ceefec567f
parent264a506e8b3039b89fe0aa1d8e8f3f33cc360cff (diff)
downloadgitbook-d44fd91181a844d6fb6d22cfe3da611aa7b783e3.zip
gitbook-d44fd91181a844d6fb6d22cfe3da611aa7b783e3.tar.gz
gitbook-d44fd91181a844d6fb6d22cfe3da611aa7b783e3.tar.bz2
Get watcher and stargazer count using github api
-rw-r--r--templates/includes/book/header.html13
1 files changed, 11 insertions, 2 deletions
diff --git a/templates/includes/book/header.html b/templates/includes/book/header.html
index 2fd0cb0..7cd16c9 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="/star/{{ githubId }}" class="btn pull-right count-star"><i class="fa fa-star-o"></i> Star (<span>-</span>)</a>
+ <a href="/watch/{{ githubId }}" 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