Commits

John Mulligan committed 21c4fd9

add tidbits macro and tagicon macro

add stub for icon selecting function

  • Participants
  • Parent commits 5ba1358

Comments (0)

Files changed (6)

File muyhomepage2/app/build.py

             self._jenv = jinja2.Environment(loader=self.templateloader())
         return self._jenv
 
+    def besticon(self, tags):
+        return None
+
 
 def build(config):
     website = site.Site()

File muyhomepage2/pagehandlers/handler.py

     def content(self):
         raise NotImplementedError('PageHandler.content')
 
+    @property
+    def tags(self):
+        return sorted(self.page.tags)
+
     def finalname(self):
         if 'x-force-file-name' in self.page.headers:
             return self.page.headers['x-force-file-name']

File muyhomepage2/site.py

 
 import os
+from muyhomepage2 import util
 from muyhomepage2 import page
 from muyhomepage2 import metadata
 
                 tmap.setdefault(tag, []).append(page)
         return tmap
 
+    def taglink(self, tag):
+        for page in self.pages:
+            if page.title == ('Tag:%s' % tag):
+                return './%s.html' % util.encodetitle(page.title)
+        return None
+
+
 
 def write_site_pages(wsite, filename):
     pdata = ((p.filename, p.contentcode, p.title, p.action)

File skins/default/base.html

   </div>
 
   <!-- begin main content section -->
-  <div id="page-main">{% block main %}{% endblock %}
+  <div id="page-main">
+  {% block main %}
+  {% macro tidbits(_current) %}
+    <ul class="tidbits">
+      <li>
+          <a href="mailto:phglogistonjohn+web@gmail.com?={{_current.page.title}}">
+              Comment on {{_current.page.title}}
+          </a>
+      </li>
+      <li>
+          <!-- repeat tidbits -->
+      </li>
+    </ul>
+  {% endmacro %}
+  {% endblock %}
   </div>
   <!-- end main content section -->
 

File skins/default/components.html

+
+{% macro tidbits(curr, ws) %}
+<!-- SUBSECTION BEGIN(tidbits) -->
+<ul class="tidbits">
+  <li>
+      <a href="mailto:phglogistonjohn+web@gmail.com?={{curr.page.title}}">
+          Comment on {{curr.page.title}}
+      </a>
+  </li>
+  <li>Created: <span class="value">{{curr.createdon}}</span></li>
+  <li>Modified: <span class="value">{{curr.modifiedon}}</span></li>
+  <li>
+    <a href="./all-tags.html">Tags</a>:
+    <span class="value">
+      {% for tag in curr.tags %}
+        <span class="pagetag">{% if ws.taglink(tag) -%}
+        <a href="{{ws.taglink(tag)}}">{{tag}}</a>{% else -%}
+        {{tag}}{% endif -%}
+        </span>{% if not loop.last -%},{% endif %}
+      {% endfor %}
+    </span>
+  </li>
+
+</ul>
+<!-- SUBSECTION END(tidbits) -->
+{% endmacro %}
+
+{% macro tagicon(curr, conf) %}
+<!-- SUBSECTION BEGIN(tagicon) -->
+{% if conf.besticon(curr.tags) %}
+<div class="tagicon">
+   {% set tag, icon = conf.besticon(curr.tags) %}
+  <img src="{{icon}}" alt="{{tag}}"></img>
+  <div class="caption">{{tag}}</div>
+</div>
+{% endif %}
+<!-- SUBSECTION END(tagicon) -->
+{% endmacro %}

File skins/default/page.html

 {% extends "base.html" %}
+{% import "components.html" as components %}
 
 {% block main %}
 <div id="page-content">
   <h2>{{current.page.title}}</h2>
+  {{ components.tagicon(current, config) }}
+
   <div></div>
   <div class="written-text">
     {{current.content()}}
   </div>
   <div></div>
 
-  <ul class="tidbits">
-    <li>
-        <a href="mailto:phglogistonjohn+web@gmail.com?={{current.page.title}}">
-            Comment on {{current.page.title}}
-        </a>
-    </li>
-    <li>
-        <!-- repeat tidbits -->
-    </li>
-  </ul>
+  {{ components.tidbits(current, site) }}
 </div>
 {% endblock %}