start prototyping some site-based code sites
authorTero Marttila <terom@fixme.fi>
Sat, 07 Feb 2009 06:05:10 +0200
branchsites
changeset 29 b06ff4c05d42
parent 28 b68145b5ce24
child 30 a86a25a9f75b
start prototyping some site-based code
lib/helpers.py
lib/site.py
sites/irclogs.qmsk.net/__init__.py
sites/irclogs.qmsk.net/handlers.py
sites/irclogs.qmsk.net/templates/index.tmpl
sites/irclogs.qmsk.net/urls.py
templates/layout.tmpl
--- a/lib/helpers.py	Sat Feb 07 05:12:57 2009 +0200
+++ b/lib/helpers.py	Sat Feb 07 06:05:10 2009 +0200
@@ -13,6 +13,13 @@
 
     return time.strftime(config.DATETIME_FMT)
 
+def copyright_year () :
+    """
+        Returns the current year
+    """
+
+    return time.strftime("%Y")
+
 def breadcrumb (trail, links=True) :
     """
         Returns a nicely formatted breadcrumb tail, optinally with links
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/site.py	Sat Feb 07 06:05:10 2009 +0200
@@ -0,0 +1,14 @@
+"""
+    Per-site stuff
+"""
+
+SITE_DIR = "sites"
+
+class Site (object) :
+    """
+        A site is a website and its configuration
+    """
+
+    pass
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sites/irclogs.qmsk.net/__init__.py	Sat Feb 07 06:05:10 2009 +0200
@@ -0,0 +1,7 @@
+"""
+    The irclogs.qmsk.net site is an IRC log browser
+"""
+
+# the URL mapper
+from urls import url_mapper
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sites/irclogs.qmsk.net/handlers.py	Sat Feb 07 06:05:10 2009 +0200
@@ -0,0 +1,25 @@
+"""
+    Our URL action handlers
+"""
+
+def index (request) :
+    """
+        The topmost index page, display a list of available channels, perhaps some general stats
+    """
+
+    pass
+
+def channel_view (request, channel) :
+    """
+        The main channel view page, display the most important info, and all requisite links
+    """
+
+    pass
+
+def channel_last (request, channel, lines, type='html') :
+    """
+        Display the last x lines of channel messages in various formats
+    """
+
+    pass
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sites/irclogs.qmsk.net/templates/index.tmpl	Sat Feb 07 06:05:10 2009 +0200
@@ -0,0 +1,2 @@
+Index page template
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sites/irclogs.qmsk.net/urls.py	Sat Feb 07 06:05:10 2009 +0200
@@ -0,0 +1,22 @@
+
+"""
+    URL mapping for the irclogs.qmsk.net site
+"""
+
+# our own handlers
+import handlers
+
+# library stuff
+from lib.map import Mapping, map, mapre
+
+def url_mapper () :
+    """
+        Construct and return the Mapping object
+    """
+
+    return Mapping(
+        map(    '/',                                        handlers.index                  ),
+        map(    '/channel/%s',                              handlers.channel_view           ),
+        mapre(  r'^/channel/(\w+)/last/(\d+)(\.\w+)?',      handlers.channel_last           ),
+    )
+
--- a/templates/layout.tmpl	Sat Feb 07 05:12:57 2009 +0200
+++ b/templates/layout.tmpl	Sat Feb 07 06:05:10 2009 +0200
@@ -44,7 +44,7 @@
                 </div>
                
                 <div id="footer-left">
-                    &copy; 2009 Tero Marttila
+                    &copy; ${h.copyright_year()} Tero Marttila
                 </div>
                 
                 <div id="footer-center">