display: inline;
}
-body #page #headerbar #menu ul li {
+body #page #headerbar #menu ul li,
+body #page #headerbar #menu ul li a,
+body #page #headerbar #menu ul li a:visited {
display: inline;
- padding-left: 1em;
- padding-right: 1em;
margin: 0;
color: #9a9a9a;
font-weight: bold;
+ text-decoration: none;
+}
+
+body #page #headerbar #menu ul li {
+ padding-left: 1em;
+ padding-right: 1em;
}
-body #page #headerbar #menu ul li:hover {
+body #page #headerbar #menu ul li:hover,
+body #page #headerbar #menu ul li a:hover {
color: #ffffff;
}
--- /dev/null
+from content.models import Document, Folder
+import operator
+
+def content_menu(request):
+ items = Document.objects.filter(folder__isnull=True, islive__exact=True)
+ menu_items = []
+ for item in items:
+ if item.slug != 'index':
+ menu_items.append(
+ {
+ 'title': item.title,
+ 'url': item.get_basic_url(),
+ }
+ )
+ folders = Folder.objects.filter(folder__isnull=True)
+ for folder in folders:
+ try:
+ item = Document.objects.filter(folder__exact=folder, islive__exact=True, slug__exact='index')
+ menu_items.append(
+ {
+ 'title': folder.title,
+ 'url': folder.get_basic_url(),
+ }
+ )
+ except:
+ pass
+
+ menu_items.sort(cmp=lambda x,y: cmp(x['title'].lower(), y['title'].lower()))
+
+ return {
+ 'content_menu': menu_items,
+ }
doc.islive = False
doc.save()
+ def get_basic_url(self):
+ folders = []
+ curfolder = self.folder
+ while curfolder != None:
+ folders.append(curfolder.slug)
+ curfolder = curfolder.parent
+
+ folders.reverse()
+ folderstring = "/".join(folders)
+ if folderstring != u'':
+ folderstring = "%s/" %(folderstring,)
+
+ return "%s%s/" %(folderstring, self.slug)
+
class Admin:
pass
def __unicode__(self):
return u'%s' %(self.title)
+ def get_basic_url(self):
+ folders = []
+ curfolder = self
+ while curfolder != None:
+ folders.append(curfolder.slug)
+ curfolder = curfolder.parent
+
+ folders.reverse()
+ folderstring = "/".join(folders)
+ if folderstring != u'':
+ folderstring = "%s/" %(folderstring,)
+
+ return "%s/" %(folderstring)
+
class Admin:
pass
'django.core.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
- 'generic.context_processors.media'
+ 'generic.context_processors.media',
+ 'content.context_processors.content_menu',
)
# Uncomment this for admin:
(r'^$', 'content.views.document_view', {'slug': 'index'}),
(r'^admin/', include('django.contrib.admin.urls')),
- (r'^content/(?P<slug>[^/]+)/$', 'content.views.document_view'),
- (r'^content/(?P<folders>.*)/(?P<slug>[^/]+)/$', 'content.views.document_view'),
- (r'^content/$', 'content.views.document_view', {'slug': 'index'}),
+ (r'^(?:content/|)(?P<slug>[^/]+)/$', 'content.views.document_view'),
+ (r'^(?:content/|)(?P<folders>.*)/(?P<slug>[^/]+)/$', 'content.views.document_view'),
(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': MEDIA_ROOT, 'show_indexes': True}),
)
<h1>SommitRealWeird</h1>
</div>
<div id="menu">
- {% block meny %}
+ {% block menu %}
<ul>
- <li>Home</li>
- <li>Development</li>
- <li>Links</li>
- <li>People</li>
- <li>CSS Examples</li>
+ <li><a href="/">Home</a></li>
+ {% for item in content_menu %}
+ <li><a href="/{{ item.url }}">{{ item.title }}</a></li>
+ {% endfor %}
<li>Photos</li>
<li>Blog</li>
</ul>