summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--PythonTBC/settings.py10
-rw-r--r--PythonTBC/urls.py1
-rwxr-xr-xtbc/templates/base.html7
-rw-r--r--tbc/templates/tbc/book-details.html13
4 files changed, 28 insertions, 3 deletions
diff --git a/PythonTBC/settings.py b/PythonTBC/settings.py
index 2849625..5ffd4af 100644
--- a/PythonTBC/settings.py
+++ b/PythonTBC/settings.py
@@ -139,10 +139,14 @@ INSTALLED_APPS = (
'tbc',
'comments',
'south',
+ 'hitcount',
)
-SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'
+# needed for django-hitcount to function properly
+SESSION_SAVE_EVERY_REQUEST = True
+SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'
+SOUTH_MIGRATION_MODULES = {"hitcount": "hitcount.south_migrations"}
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
@@ -171,3 +175,7 @@ LOGGING = {
},
}
}
+HITCOUNT_KEEP_HIT_ACTIVE = { 'minutes': 60 }
+HITCOUNT_HITS_PER_IP_LIMIT = 0 #unlimited
+HITCOUNT_EXCLUDE_USER_GROUP = ( ) # not used
+HITCOUNT_KEEP_HIT_IN_DATABASE = { 'seconds': 10 }
diff --git a/PythonTBC/urls.py b/PythonTBC/urls.py
index c5d3753..698452a 100644
--- a/PythonTBC/urls.py
+++ b/PythonTBC/urls.py
@@ -22,6 +22,7 @@ urlpatterns = patterns('',
url(r'^comments/', include('comments.urls')),
url(r'^', include('tbc.urls', namespace='tbc')),
url(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}),
+ url(r'hitcount/', include('hitcount.urls', namespace='hitcount')),
)
diff --git a/tbc/templates/base.html b/tbc/templates/base.html
index a4a637c..639ce13 100755
--- a/tbc/templates/base.html
+++ b/tbc/templates/base.html
@@ -364,5 +364,10 @@
</script>
<noscript><p><img src="http://analytics.spoken-tutorial.org/piwik.php?idsite=15" style="border:0;" alt="" /></p></noscript>
<!-- End Piwik Code -->
- </body>
+{% block hitcount_javascript %}{% endblock %}
+<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
+{% load staticfiles %}
+{# example of adding your own hitcount-jquery #}
+<script src="{% static 'hitcount/hitcount-jquery.js' %}"></script>
+</body>
</html>
diff --git a/tbc/templates/tbc/book-details.html b/tbc/templates/tbc/book-details.html
index 99c8ba6..470870c 100644
--- a/tbc/templates/tbc/book-details.html
+++ b/tbc/templates/tbc/book-details.html
@@ -1,6 +1,6 @@
{% extends 'base.html' %}
{% load static %}
-
+{% load hitcount_tags %}
{% block script %}
<script>
function redirectToIpynb(notebook)
@@ -77,5 +77,16 @@ function redirectToIpynb(notebook)
</tr>
</table>
+{% get_hit_count_js_variables for book as hitcount %}
+{% get_hit_count for book as total_hits %}
+<div class="row">
+<dl class="dl-horizontal">
+<dt>Total Hits:</dt>
+<dd>{{ total_hits }}</dd>
+</dl>
</div>
+{%endblock%}
+{% block hitcount_javascript %}
+{% insert_hit_count_js_variables for book %}
{% endblock %}
+</div>