Commits

Matthew Schinckel  committed a96b581

Initial import

  • Participants

Comments (0)

Files changed (5)

File menus/__init__.py

Empty file added.

File menus/templates/menu/item.html

+<a href="{{ url }}" id="{{ element_id }}" class="{{ active }}">{{ text }}</a>

File menus/templatetags/__init__.py

Empty file added.

File menus/templatetags/menu_item.py

+from django import template
+register = template.Library()
+from django.core.urlresolvers import reverse
+
+def menu_item(context, url, text=None, classes=None):
+    if url.startswith("url:"):
+        url = reverse(url[4:], args=[])
+    if context.has_key('page_url'):
+        page_url = context['page_url']
+    elif context.has_key('flatpage'):
+        page_url = context['flatpage'].url
+    elif context.has_key('request'):
+        page_url = context['request'].path
+    
+    return {
+        'url': url,
+        'active': "active" if page_url == url else "",
+        'text': text or "",
+        'classes': classes or "",
+    }
+
+
+#register.inclusion_tag('website/link.html', takes_context=True)(link)
+register.inclusion_tag('menu/item.html', takes_context=True)(menu_item)
+from distutils.core import setup
+
+setup(
+    name = "django-menus",
+    version = "0.1",
+    description = "Menu helpers for django projects",
+    url = "http://bitbucket.org/schinckel/django-menus/",
+    author = "Matthew Schinckel",
+    author_email = "matt@schinckel.net",
+    packages = [
+        "menus",
+    ],
+    classifiers = [
+        'Programming Language :: Python',
+        'License :: Other/Proprietary License',
+        'Operating System :: OS Independent',
+        'Framework :: Django',
+    ],
+)