John Mulligan avatar John Mulligan committed d0dd076

add tagglobal page handler

Comments (0)

Files changed (4)

muyhomepage2/app/configuration.py

 
 from muyhomepage2.pagehandlers.standard import StandardHandler
 from muyhomepage2.pagehandlers.tagsummary import TagSummaryHandler
+from muyhomepage2.pagehandlers.tagglobal import TagGlobalHandler
 
 
 DEFAULT_HANDLERS = {
     'standard': StandardHandler,
     'blog': StandardHandler,
     'tagsummary': TagSummaryHandler,
-    'tagglobal': StandardHandler,
+    'tagglobal': TagGlobalHandler,
     'software': StandardHandler,
     'atom': StandardHandler,
     'rss2': StandardHandler,
         return StandardHandler
     
     def always_rebuild(self):
-        return ['tagsummary']
+        return ['tagsummary', 'tagglobal', 'atom', 'rss2', 'blog']
 

muyhomepage2/pagehandlers/tagglobal.py

+
+from muyhomepage2.pagehandlers import handler
+from muyhomepage2.text import wikirst
+from muyhomepage2 import util
+
+MIN = 100
+MAX = 300
+
+class TagGlobalHandler(handler.PageHandler):
+    def content(self):
+        return wikirst.format(self.page.body)
+
+    def template(self):
+        return 'tagglobal.html'
+
+    def extension(self, website, config):
+        tmap = dict(website.tagmap)
+        tagcount = len(tmap)
+        tagpct = dict((tag, scale(len(tmap[tag]), tagcount, MIN, MAX))
+            for tag in tmap)
+        tagcloud = [(tagpct[tag], util.encodetitle(tag), tag) for tag in sorted(tmap)]
+        def _pinfo(page):
+            url = './%s' % handler.PageHandler(page).finalname()
+            return (url, page.title)
+        tagdetails = [(util.encodetitle(tag), tag, [_pinfo(p) for p in pages])
+            for tag, pages in sorted(tmap.iteritems())]
+        return {
+            'tagcount': tagcount,
+            'tagcloud': tagcloud,
+            'tagdetails': tagdetails,
+            }
+
+def scale(num, total, min, max):
+    num = float(num)
+    return int((((num - 1) / total) * (max - min)) + min)

skins/default/base.html

       <h4>hotspots</h4>
       <div class="ebox-content">
       <ul class="altlist">
-        <li class="even"><a href="/">home</a></li>
-        <li class="odd"><a href="/rss.xml">rss feed</a></li>
-        <li class="even"><a href="/atom.xml">atom feed</a> </li>
-        <li class="odd"><a href="/best-of-comments.html">best of comments</a></li>
-        <li class="even"><a href="/webpage-status.html">site status</a></li>
-        <li class="odd"><a href="/static/booklist.html">my book list</a></li>
-        <li class="even"><a href="/static/jm-resume-2009.0.pdf">my resume</a></li>
+        <li class="even"><a href="./">home</a></li>
+        <li class="odd"><a href="./rss.xml">rss feed</a></li>
+        <li class="even"><a href="./atom.xml">atom feed</a> </li>
+        <li class="odd"><a href="./best-of-comments.html">best of comments</a></li>
+        <li class="even"><a href="./webpage-status.html">site status</a></li>
+        <li class="odd"><a href="./static/booklist.html">my book list</a></li>
+        <li class="even"><a href="./static/jm-resume-2009.0.pdf">my resume</a></li>
       </ul>
       </div>
     </div>

skins/default/tagglobal.html

+{% extends "base.html" %}
+
+{% block main %}
+<div id="page-content">
+  <h2>{{current.page.title}}</h2>
+  <p>
+    A total of <em>{{ext.tagcount}}</em> tags have been used.
+  </p>
+  <div>{{current.content()}}</div>
+  
+  <ul id="tags-listing">
+  {% for scale, link, tag in ext.tagcloud %}
+    <li><a style="font-size:{{scale}}%;" href="#{{link}}">{{tag}}</a></li>
+  {% endfor %}
+  </ul>
+
+  <ul id="tags-listing-links">
+    {% for link, tag, pages in ext.tagdetails %}
+    <li><a name="{{link}}"></a><span>{{tag}}</span>
+        <ul class="altlist">
+        {% for purl, ptitle in pages %}
+            <li class="xxx"><a href="{{purl}}">{{ptitle}}</a></li>
+        {% endfor %}
+        </ul>
+    </li>
+    {% endfor %}
+  </ul>
+
+  <ul class="tidbits">
+    </li>
+    <li>
+        Created: <span class="value">{{current.created}}</span>
+    </li>
+    <li>
+        Modified: <span class="value">{{current.modified}}</span>
+    </li>
+  </ul>
+</div>
+{% endblock %}
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.