Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added template tag for copyright, cleaned up

  • Loading branch information...
commit f73afe969d7350a09f2e6c521391ac40aca59a7c 1 parent 3e19c45
David Parker authored
2  settings.py
View
@@ -78,5 +78,5 @@
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
- 'django-skeleton.template_lib',
+ 'django-skeleton.template_libs',
)
19 template_libs/templatetags/templatetags.py
View
@@ -1,9 +1,26 @@
+import datetime
+
from django import template
register = template.Library()
+
+#classes
#filters
-#tags
+#tags
+
+def copyright_tag(year):
+ try:
+ now = datetime.datetime.now().year
+ if year != str(now):
+ return "Copyright " + year + " - " + str(now)
+ else:
+ return "Copyright " + year
+ except UnicodeEncodeError:
+ return ''
+
+register.simple_tag(copyright_tag)
#inclusion tags
+
27 templates/base.html
View
@@ -1,3 +1,4 @@
+{% load templatetags %}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
@@ -10,14 +11,24 @@
</head>
<body>
<div class="container">
- <ul>
- <li><a href="/">index</a></li>
- <li><a href="/admin/">admin</a></li>
- <li><a href="/accounts/login/">login</a></li>
- <li><a href="/accounts/logout/">logout</a></li>
- </ul>
- <h1>{% block h1 %}{% endblock %}</h1>
- <div>{% block content %}{% endblock %}</div>
+ <div class="header">
+ {% if user.is_authenticated %}
+ Hello {{ user.username }}! Not {{user.username}}? Click <a href="/accounts/logout">here</a> to logout.
+ {% endif %}
+ </div>
+ <ul class="navigation">
+ {% block navigation%}
+ <li><a href="/">index</a></li>
+ <li><a href="/admin/">admin</a></li>
+ <li><a href="/accounts/login/">login</a></li>
+ <li><a href="/accounts/logout/">logout</a></li>
+ {% endblock %}
+ </ul>
+ <h1>{% block h1 %}{% endblock %}</h1>
+ <div class="content">{% block content %}{% endblock %}</div>
+ <div class="footer">
+ {% copyright_tag "2005" %} <a href="http://davidwparker.com">david parker</a>
+ </div>
</div>
</body>
</html>
13 urls.py
View
@@ -8,9 +8,12 @@
admin.autodiscover()
-#admin and login/logout
+#defaults -- index, admin, login, logout, profile
urlpatterns = patterns('',
- (r'^admin/(.*)', admin.site.root),
+ (r'^$', direct_to_template, {
+ 'template': 'index.html'
+ }),
+ (r'^admin/(.*)', admin.site.root),
(r'^accounts/login/$', login),
(r'^accounts/logout/$', logout),
(r'^accounts/profile/$', direct_to_template, {
@@ -23,9 +26,3 @@
urlpatterns += patterns('',
(r'^site_media/(.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
)
-
-urlpatterns += patterns('',
- (r'^$', direct_to_template, {
- 'template': 'index.html'
- }),
-)
Please sign in to comment.
Something went wrong with that request. Please try again.