Commits

Anonymous committed 80dd282

Starting default site

  • Participants
  • Parent commits 7bced05

Comments (0)

Files changed (5)

eagproject/eagadmin/templatetags/eagsite.py

 from django import template
-from django.template import TemplateSyntaxError
+from django.template import TemplateSyntaxError, VariableDoesNotExist
 from ..eagadmin.models import pages
 
 register = template.Library()
         self.depth = int(depth)
 
     def render(self, context):
-        item = self.item.resolve(context)
         current = template.Variable('current').resolve(context)
         breadcrumb = template.Variable('breadcrumb').resolve(context)
+        items = []
+        item = None
         try:
+            item = self.item.resolve(context)
             items = pages.get_descendants(item, self.depth)
         except AttributeError:
             item = pages.get_by_slug(str(item))
             if not item:
-                return ''
+                item = pages.get_root()
             items = pages.get_descendants(item, self.depth)
         if not items:
             return ''
         first = items[0]
         level = first.level
         out = []
-        for p in items:
+        for i, p in enumerate(items):
             if level < p.level:
                 out.append('<ul>')
             if level > p.level:
                 out.append('</ul>' * (level - p.level))
 
-            cl = ''
+            cl = []
+            if not i:
+                cl.append('first')
             if p == current:
-                cl = ' class="current"'
+                cl.append('current')
             elif p in breadcrumb:
-                cl = ' class="branch"'
-            out.append('<li%s>' % (cl))
+                cl.append('branch')
+
+            if cl:
+                out.append('<li class="%s">' % (' '.join(cl)))
+            else:
+                out.append('<li>')
 
             target = ''
             if p.get_link_target():
         tag_name, item = args[0], args[1]
         depth = 1
     else:
-        tag_name = args[0]
-        raise TemplateSyntaxError(
-                '%r tag requires at least single param' \
-                % tag_name)
+        item = '""' # makes ListMenuNode to believe is empty str
+        depth = 1
     return ListMenuNode(item, depth)
 register.tag('eagsite_list_menu', list_menu)
 

eagproject/eagtypes.py

     pass
 
 class Text(Page):
-    picture = db.StringProperty()
-    content = db.TextProperty()
+    content = db.TextProperty(required=False)
 
 class TextForm(forms.Form):
-    picture = forms.CharField(widget=PicasaWidget)
     content = forms.CharField(widget=SemiWYSIWYGWidget)
+
+    # If you want to turn on WYSIWYG editor on page load
     #content = forms.CharField(widget=WYSIWYGWidget)
 
 class Link(Page):

eagproject/static/css/style.css

+* { padding: 0; margin: 0; border: 0 }
+html, body { width: 100%; height: 100%; }
+body { background: #757675; font-family: Verdana, sans-serif; font-size: 10pt; color: #3c3c3c; }
+
+a img { border: 0; }
+
+.lft { float: left; }
+.rht { float: right; }
+.clr { clear: both; }
+
+h1, h2, h3, h4, h5, h6 { font-family: Arial, serif; color: #000; font-weight: normal; }
+h1 { font-size: 18pt; font-weight: normal; margin-bottom: 20pt; }
+#SiteName { font-family: Georgia, serif; font-size: 32pt; }
+
+#Wrapper { padding: 40px 100px 0 100px; }
+
+
+#Content { border: 3px solid #444; background: #fff; padding: 60px 40px 120px 40px; }
+#Footer {}
+
+#Menu { float: right; font-family: Georgia, serif; font-size: 14pt; line-height: 10pt; margin-bottom: 50pt; }
+#Menu a { color: #aeaeae; text-decoration: none; }
+#Menu a:hover { text-decoration: underline; }
+#Menu li.current a { color: #000; border-bottom: 4px solid #000; }
+
+#Menu li { margin-top: 14pt; list-style-type: none; float: left; padding: 0 15pt; border-left: 1px solid #aeaeae; }
+#Menu li.home { padding-left: 0; border-left: 0; }
+
+.text { line-height: 150%; }
+.text p { margin: 0 0 14pt 0; }
+

eagproject/templates/eagsite/base.html

+<!DOCTYPE html>
 <html>
 <head>
   <meta http-equiv="content-type" content="text/html; charset=utf-8">
   {% load eagsite %}{% eagsite_head %}
-  <style>
-    ul li.branch  a{
-      color: #f00;
-    }
-    ul li.current  a{
-      color: #0f0;
-    }
-  </style>
+  <link rel="stylesheet" href="{{ MEDIA_URL }}static/css/style.css" type="text/css" media="screen" charset="utf-8"></link>
 </head>
-<body>
-  <div id="Content">
-    {% block content %}
-    {% endblock %}
+<body class="{{ current.class_name }}">
+  {% eagsite_get_page "" as root %}
+  <div id="Wrapper">
+    <div id="Content">
+      <ul id="Menu">
+        <li class="home {% ifequal current root %}current{% endifequal %}"><a href="{{ root.get_absolute_url }}">Home</a>
+        {% eagsite_list_menu "main-menu" %}
+      </ul>
+      <h1 id="SiteName">Site Name</h1>
+      <div class="clr"></div>
+      {% block content %}{% endblock %}
+    </div>
   </div>
+  <div id="Footer"></div>
 </body>
 </html>

eagproject/templates/eagsite/page.html

 {% extends "eagsite/base.html" %}
-{% load eagsite %}
 {% block content %}
-  {% eagsite_get_page "secret" as secret_page %}
-  {% if secret_page %}
-    <a href="{{ secret_page.get_absolute_url }}">{{ secret_page.menu_title }}</a>
-  {% endif %}
-  {% for page in breadcrumb|slice:"2:" %}
-    {{ page.menu_title }} -&gt;
-  {% endfor %}
-  <ul>{% eagsite_list_menu 'main-menu' 3 %}</ul>
-  {{ current.content|safe }}
-  <img src="{{ current.picture }}" alt="Picture" />
-  <ul>{% eagsite_list_menu 'main-menu' 3 %}</ul>
+<h1>Documentation</h1>
+<div class="text">
+  <p>
+    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus aliquet
+    adipiscing tincidunt. Nullam dolor justo, placerat a ultrices quis, mattis
+    vitae dolor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque
+    sapien neque, fringilla vitae feugiat ut, condimentum eu mi. Etiam ante urna,
+    suscipit cursus aliquam eu, feugiat quis risus. Sed sagittis volutpat dui,
+    quis fringilla mauris tristique eget. Aliquam erat volutpat. Cras eget neque
+    lorem. Nunc in aliquet leo. Morbi sit amet lacus id arcu ultrices bibendum.
+    Duis ut venenatis nulla. Praesent eget felis libero, et interdum enim. Donec
+    varius felis a magna volutpat ac sodales sapien gravida. Sed vel augue dolor.
+  </p>
+  <p>
+    Vestibulum non ornare massa. Etiam sit amet mi quis diam condimentum dictum
+    vitae vel libero. Integer auctor venenatis lorem, nec fringilla eros ornare
+    malesuada. Fusce ac nisl est, faucibus fringilla tellus. Sed vitae sem non
+    orci congue luctus. Duis sodales metus nec nunc porta et adipiscing risus
+    porta. Integer ligula eros, ornare id sollicitudin nec, venenatis vel purus.
+    Nulla quis arcu risus, nec fermentum diam. In gravida nunc non metus pharetra
+    mattis. Pellentesque faucibus tristique rutrum. Mauris nunc ipsum, ultrices
+    vel semper et, scelerisque non lacus. Sed scelerisque pulvinar vehicula. Fusce
+    quis magna quis quam dictum pellentesque id in nulla. Ut vel dolor sapien, non
+    ultricies sem. Nulla facilisi. Maecenas nisl velit, lobortis eu semper et,
+    rutrum eget leo. Nulla lectus lectus, tincidunt vitae viverra eget, dictum sed
+    est. Proin vitae leo dui. Suspendisse sollicitudin bibendum arcu, at congue
+    eros ultrices eget.
+  </p>
+  <p>
+    In tempus erat sed eros scelerisque eu sollicitudin eros ullamcorper. Fusce
+    posuere metus nec libero porttitor fermentum. Donec bibendum consequat nisl.
+    Donec id urna nibh, id euismod diam. Mauris varius ultrices mauris, ac tempor
+    metus rutrum sit amet. Morbi id enim quis est hendrerit scelerisque.
+    Vestibulum viverra blandit sapien ac facilisis. Cras eget neque nisl, id
+    interdum metus. Quisque sit amet nisl a nisl volutpat viverra sit amet ut
+    sapien. Praesent velit est, ullamcorper quis semper ut, porttitor vitae eros.
+    Suspendisse potenti. Proin nec lectus nulla. Ut sem ligula, rhoncus tincidunt
+    venenatis ut, vulputate ut ante. Pellentesque nec est non tellus condimentum
+    consequat. Nam et sapien ut lorem posuere pharetra. Nam non metus sed diam
+    tempus laoreet in nec justo. Cras eu scelerisque lacus. Praesent ac augue in
+    ipsum dictum rhoncus sed vel diam. Pellentesque est velit, sagittis in
+    adipiscing at, mollis sit amet erat.
+  </p>
+</div>
 {% endblock %}