Permalink
Browse files

Added navbar. Added tests, but they do not run yet.

  • Loading branch information...
1 parent 880e9b6 commit 833a5fc65e78e9565e68d9335668889f204f24f9 @RacingTadpole committed Feb 27, 2013
View
@@ -8,8 +8,9 @@ Some of them use classes appropriate for Twitter Bootstrap, but my intention is
button a Twitter Bootstrap button, with html special characters allowed
text_minimal_markup plain text with an h2 heading, with links and email addresses activated and html special codes allowed, e.g. ©
resizeable_picture a subclass of cms.plugin.picture which allows absolute or % width and height
+navbar a Twitter Bootstrap navbar, with self-calculating links to the home page's children, and quick links for admins
self_calc_pagination shows pagination links where pages after 1 are all the children of page 1 (tailored to Twitter Bootstrap)
-hbar a simple html hbar element
+hbar a simple html <hr> element
spacer adds a .spacer div, which I style as clear:both, to switch off float:left and float:right
facebook_button lots of options allowed
View
No changes.
No changes.
Binary file not shown.
@@ -0,0 +1,26 @@
+from cms.plugin_base import CMSPluginBase
+from cms.plugin_pool import plugin_pool
+from cms.models.pluginmodel import CMSPlugin
+from django.utils.translation import ugettext_lazy as _
+from django.conf import settings
+
+from models import *
+
+bootstrap_module_name = _("Widgets")
+layout_module_name = _("Layout elements")
+generic_module_name = _("Generic")
+meta_module_name = _("Meta elements")
+
+class NavbarPlugin(CMSPluginBase):
+ model = NavbarPluginModel
+ name = _("Navigation bar")
+ module = bootstrap_module_name
+ render_template = "navbar_plugin.html"
+ admin_preview = False
+
+ def render(self, context, instance, placeholder):
+ context['instance'] = instance
+ return context
+
+plugin_pool.register_plugin(NavbarPlugin)
+
Binary file not shown.
@@ -0,0 +1,61 @@
+# -*- coding: utf-8 -*-
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+ def forwards(self, orm):
+ # Adding model 'NavbarPluginModel'
+ db.create_table('cmsplugin_navbarpluginmodel', (
+ ('cmsplugin_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['cms.CMSPlugin'], unique=True, primary_key=True)),
+ ('navbar_type', self.gf('django.db.models.fields.CharField')(default='navbar-fixed-top', max_length=64, blank=True)),
+ ('inverted', self.gf('django.db.models.fields.BooleanField')(default=False)),
+ ('brand', self.gf('django.db.models.fields.CharField')(default='', max_length=80, blank=True)),
+ ('link_to_children', self.gf('django.db.models.fields.BooleanField')(default=True)),
+ ('icon_type', self.gf('django.db.models.fields.CharField')(max_length=24, blank=True)),
+ ))
+ db.send_create_signal('navbar', ['NavbarPluginModel'])
+
+
+ def backwards(self, orm):
+ # Deleting model 'NavbarPluginModel'
+ db.delete_table('cmsplugin_navbarpluginmodel')
+
+
+ models = {
+ 'cms.cmsplugin': {
+ 'Meta': {'object_name': 'CMSPlugin'},
+ 'changed_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+ 'creation_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2013, 2, 27, 0, 0)'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'language': ('django.db.models.fields.CharField', [], {'max_length': '15', 'db_index': 'True'}),
+ 'level': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+ 'lft': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+ 'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.CMSPlugin']", 'null': 'True', 'blank': 'True'}),
+ 'placeholder': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['cms.Placeholder']", 'null': 'True'}),
+ 'plugin_type': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}),
+ 'position': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'}),
+ 'rght': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'}),
+ 'tree_id': ('django.db.models.fields.PositiveIntegerField', [], {'db_index': 'True'})
+ },
+ 'cms.placeholder': {
+ 'Meta': {'object_name': 'Placeholder'},
+ 'default_width': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True'}),
+ 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+ 'slot': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'})
+ },
+ 'navbar.navbarpluginmodel': {
+ 'Meta': {'object_name': 'NavbarPluginModel', 'db_table': "'cmsplugin_navbarpluginmodel'", '_ormbases': ['cms.CMSPlugin']},
+ 'brand': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '80', 'blank': 'True'}),
+ 'cmsplugin_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['cms.CMSPlugin']", 'unique': 'True', 'primary_key': 'True'}),
+ 'icon_type': ('django.db.models.fields.CharField', [], {'max_length': '24', 'blank': 'True'}),
+ 'inverted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+ 'link_to_children': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+ 'navbar_type': ('django.db.models.fields.CharField', [], {'default': "'navbar-fixed-top'", 'max_length': '64', 'blank': 'True'})
+ }
+ }
+
+ complete_apps = ['navbar']
Binary file not shown.
No changes.
Binary file not shown.
@@ -0,0 +1,29 @@
+# Plugin models
+
+from cms.models.pluginmodel import CMSPlugin
+from cms.models.pagemodel import Page
+from django.utils.translation import ugettext_lazy as _
+from django.db import models
+
+class NavbarPluginModel(CMSPlugin):
+ DISPLAY_CHOICES =(("", _("default")),
+ ("navbar-fixed-top", _("fixed to top")),
+ ("navbar-fixed-bottom", _("fixed to bottom")),
+ ("navbar-static-top", _("static top")),
+ )
+ USER_ICON_CHOICES = (("",_("grey")),
+ ("icon-white",_("white")),
+ )
+ navbar_type = models.CharField(_("navbar type"), max_length=64, blank=True, default="navbar-fixed-top", choices=DISPLAY_CHOICES)
+ inverted = models.BooleanField(default=False)
+ brand = models.CharField(max_length=80, default='', blank=True)
+ link_to_children = models.BooleanField(default=True,
+ help_text=_("Show links to all navigable children of the home page. NOTE: You must set the home page's id to 'home' under the advanced settings. Will not work if there is a 'softroot' in your CMS."))
+ icon_type = models.CharField(_("user actions icon type"), max_length=24, blank=True, choices=USER_ICON_CHOICES)
+
+ def __unicode__(self):
+ if self.brand:
+ return self.brand
+ else:
+ return ""
+
Binary file not shown.
@@ -0,0 +1,11 @@
+{% load menu_tags %}
+{% load i18n %}
+{% for child in children %}
+<li class="{% if child.selected %}active{% endif %}{% if child.ancestor %}ancestor{% endif %}{% if child.sibling %}sibling{% endif %}{% if child.descendant %}descendant{% endif %}">
+ <a href="{{ child.attr.redirect_url|default:child.get_absolute_url }}">
+ {{ child.get_menu_title|capfirst }}</a>
+ {% if child.children %}
+ {% show_menu from_level to_level extra_inactive extra_active template "" "" child %}
+ {% endif %}
+</li>
+{% endfor %}
@@ -0,0 +1,30 @@
+{% load menu_tags %}
+{% block navbar %}
+ <div class="navbar {% if instance.inverted %}navbar-inverse {% endif %}{{ instance.navbar_type }}">
+ <div class="navbar-inner">
+ <div class="container">
+ <a class="brand" href="/">{% block pagename %}{{ instance.brand }}{% endblock %}</a>
+ <ul class="nav">
+ {% if not instance.brand %}
+ <li class="{% ifequal request.path_info '/' %}active{% endifequal %}"><a href="/">Home</a></li>
+ {% endif %}
+ {% if instance.link_to_children %}
+ {% show_menu_below_id "home" 0 100 0 100 "menu/toolbar-menu.html" %} {# needs home page to have id 'home'; won't show under a softroot #}
+ {% else %}
+ <li class="{% ifequal request.path_info '/about/' %}active{% endifequal %}"><a href="/about/">About</a></li>
+ <li class="{% ifequal request.path_info '/contact/' %}active{% endifequal %}"><a href="/contact/">Contact</a></li>
+ {% endif %}
+ </ul>
+ {% block navbar_user %}
+ {% if user.is_authenticated and user.is_staff %}
+ <ul class="nav pull-right">
+ <li><a href="/admin/cms/page/{{ request.current_page.id }}"><i class="icon-file {{ instance.icon_type }}"></i></a></li>
+ <li><a href="/admin/"><i class="icon-star {{ instance.icon_type }}"></i></a></li>
+ </ul>
+ {% endif %}
+ {% endblock %}
+ </div>
+ </div>
+ </div>
+ {% endblock %}
+
@@ -0,0 +1,16 @@
+"""
+This file demonstrates writing tests using the unittest module. These will pass
+when you run "manage.py test".
+
+Replace this with more appropriate tests for your application.
+"""
+
+from django.test import TestCase
+
+
+class SimpleTest(TestCase):
+ def test_basic_addition(self):
+ """
+ Tests that 1 + 1 always equals 2.
+ """
+ self.assertEqual(1 + 1, 2)
@@ -0,0 +1 @@
+# Create your views here.
Oops, something went wrong.

0 comments on commit 833a5fc

Please sign in to comment.