summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--PythonTBC/settings.py1
-rw-r--r--PythonTBC/urls.py2
-rw-r--r--requirements.txt1
-rw-r--r--tbc/templates/tbc/book-details.html23
4 files changed, 26 insertions, 1 deletions
diff --git a/PythonTBC/settings.py b/PythonTBC/settings.py
index 46131a9..bd0f0b8 100644
--- a/PythonTBC/settings.py
+++ b/PythonTBC/settings.py
@@ -136,6 +136,7 @@ INSTALLED_APPS = (
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
+ 'hitcount',
'tbc',
'comments',
#'south',
diff --git a/PythonTBC/urls.py b/PythonTBC/urls.py
index 77d166a..9cae5d6 100644
--- a/PythonTBC/urls.py
+++ b/PythonTBC/urls.py
@@ -27,7 +27,7 @@ urlpatterns = [
url(r'^admin-tools/commenting', commentingapp.views.commenting, name = 'commenting'),
url(r'^admin-tools/error_page', tbc_error_page.views.error, name = 'error_page'),
url(r'^admin-tools/broken_page', tbc_error_page.views.broken, name = 'broken_page'),
-
+ url(r'hitcount/', include('hitcount.urls', namespace='hitcount')),
]
diff --git a/requirements.txt b/requirements.txt
index ac72f30..ab8f58a 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -14,3 +14,4 @@ wsgiref==0.1.2
scrapy==1.0.3
django-taggit
django-taggit-templatetags2
+django-hitcount
diff --git a/tbc/templates/tbc/book-details.html b/tbc/templates/tbc/book-details.html
index fc67847..0119117 100644
--- a/tbc/templates/tbc/book-details.html
+++ b/tbc/templates/tbc/book-details.html
@@ -2,6 +2,24 @@
{% load static %}
{% block script %}
+{% load staticfiles %}
+<script src="{% static 'hitcount/jquery.postcsrf.js' %}"></script>
+
+{% load hitcount_tags %}
+{% get_hit_count_js_variables for book as hitcount %}
+<script type="text/javascript">
+jQuery(document).ready(function($) {
+ // use the template tags in our JavaScript call
+ $.postCSRF("{{ hitcount.ajax_url }}", { hitcountPK : "{{ hitcount.pk }}" })
+ .done(function(data){
+ $('<i />').text(data.hit_counted).attr('id','hit-counted-value').appendTo('#hit-counted');
+ $('#hit-response').text(data.hit_message);
+ }).fail(function(data){
+ console.log('POST failed');
+ console.log(data);
+ });
+});
+</script>
<script>
function redirectToIpynb(notebook)
{
@@ -50,6 +68,7 @@ function redirectToIpynb(notebook)
<tr>
<td>Author: &nbsp;&nbsp;</td>
<td>{{ book.author }}</td>
+
</tr>
<tr>
<td>Publisher: &nbsp;&nbsp;</td>
@@ -79,7 +98,11 @@ function redirectToIpynb(notebook)
<td>GitHub: &nbsp;&nbsp;</td>
<td><a href= 'https://github.com/FOSSEE/Python-Textbook-Companions/tree/master/{{ book.title.split|join:"_" }}_by_{{ book.author.split|join:"_" }}' target="_blank">{{ book.title }}</a></td>
</tr>
+<tr>
+ <td>Page Hits: &nbsp;&nbsp;</td>
+<td>{% get_hit_count for book %}</td>
+</tr>
</table>
</div>