merge channel_view and channel_last, adding a More link to channel_last.tmpl
authorTero Marttila <terom@fixme.fi>
Mon, 09 Feb 2009 13:45:06 +0200
changeset 70 72edbbb414a7
parent 69 1f182913b1f2
child 71 e909bde831e7
merge channel_view and channel_last, adding a More link to channel_last.tmpl
handlers.py
static/irclogs.css
templates/channel.tmpl
templates/channel_last.tmpl
templates/channel_view.tmpl
templates/lines.tmpl
urls.py
--- a/handlers.py	Mon Feb 09 13:19:00 2009 +0200
+++ b/handlers.py	Mon Feb 09 13:45:06 2009 +0200
@@ -63,12 +63,12 @@
         Redirect to the appropriate channel_view
     """
    
-    return http.Redirect(urls.channel_view.build(request, channel=channel))
+    return http.Redirect(urls.channel.build(request, channel=channel))
 
 @preferences.handler(prefs.formatter)
-def channel_view (request, channel, count, formatter) :
+def channel_last (request, channel, count, formatter) :
     """
-        The main channel view page, display the most important info, and all requisite links
+        The main channel view page, displaying the most recent lines
     """
     
     # get latest events
@@ -77,7 +77,7 @@
     # lines
     lines = formatter.format_html(lines)
 
-    return templates.render_to_response("channel_view",
+    return templates.render_to_response("channel_last",
         req             = request,
         prefs           = request.prefs,
         channel         = channel,
@@ -85,22 +85,6 @@
         lines           = lines,
     )
 
-def channel_last (request, channel, count, format) :
-    """
-        Display the last x lines of channel messages in various formats
-    """
-
-    if format == 'txt' :
-        # XXX: formatting
-#        return http.Response('\n'.join(str(channel.source.get_latest(count))), 'text/plain')
-         pass
-
-    elif format == 'html' :
-        pass
-
-    else :
-        raise http.ResponseError("Unknown filetype %r" % format)
-
 @preferences.handler(prefs.timezone)
 def channel_calendar (request, channel, year, month, timezone) :
     """
--- a/static/irclogs.css	Mon Feb 09 13:19:00 2009 +0200
+++ b/static/irclogs.css	Mon Feb 09 13:45:06 2009 +0200
@@ -284,6 +284,15 @@
 }
 
 /* Log lines */
+a.more-link {
+    color: black;
+    text-decoration: none;
+}
+
+a.more-link:hover {
+    text-decoration: underline;
+}
+
 div#lines a {
     color: black;
 }
--- a/templates/channel.tmpl	Mon Feb 09 13:19:00 2009 +0200
+++ b/templates/channel.tmpl	Mon Feb 09 13:45:06 2009 +0200
@@ -6,7 +6,7 @@
     <li><a href="${urls.preferences.build(req)}">Preferences</a></li>
 
     <li>
-        <a href="${urls.channel_view.build(req, channel=channel)}">Channel:</a>
+        <a href="${urls.channel.build(req, channel=channel)}">Channel:</a>
     </li><li class="join-left">
         <form action="${urls.channel_select.build(req)}" method="GET">
             <select name="channel">
@@ -19,7 +19,7 @@
 
 <!--
     <li>
-        <a href="${urls.channel_view.build(req, channel=channel, count=count or None)}">View last:</a>
+        <a href="${urls.channel_last.build(req, channel=channel, count=count or None)}">View last:</a>
     </li><li class="join-left">
         <form action="" method="GET">
             <select name="count">
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/channel_last.tmpl	Mon Feb 09 13:45:06 2009 +0200
@@ -0,0 +1,6 @@
+<%inherit file="channel.tmpl" />
+
+<div id="title">${channel.title} :: Last ${count} lines</div>
+
+<a href="${h.build_url(urls.channel_last, channel=channel, count=count+50)}" class='more-link'>...More...</a>
+<%include file="lines.tmpl" />
--- a/templates/channel_view.tmpl	Mon Feb 09 13:19:00 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-<%inherit file="channel.tmpl" />
-
-<div id="title">${channel.title} :: Last ${count} lines</div>
-
-<%include file="lines.tmpl" />
--- a/templates/lines.tmpl	Mon Feb 09 13:19:00 2009 +0200
+++ b/templates/lines.tmpl	Mon Feb 09 13:45:06 2009 +0200
@@ -1,5 +1,5 @@
 <div id="lines">
-% for line in lines:
+% for index, line in enumerate(lines):
 ${line}
 % endfor
 </div>
--- a/urls.py	Mon Feb 09 13:19:00 2009 +0200
+++ b/urls.py	Mon Feb 09 13:45:06 2009 +0200
@@ -27,14 +27,14 @@
 )
 
 # urls
-index               = url('/',                                                              handlers.index                  )
-preferences         = url('/preferences',                                                   handlers.preferences_           )
-channel_select      = url('/channel_select/?channel:cid',                                   handlers.channel_select         )
-channel_view        = url('/channels/{channel:cid}/?count:int=10',                          handlers.channel_view           )
-channel_last        = url('/channels/{channel:cid}/last/{count:int=100}/{format=html}',     handlers.channel_last           )
-channel_calendar    = url('/channels/{channel:cid}/calendar/{year:int=0}/{month:int=0}',    handlers.channel_calendar       )
-channel_date        = url('/channels/{channel:cid}/date/{date:date}',                       handlers.channel_date           )
-channel_search      = url('/channels/{channel:cid}/search/?q=&count:int=&skip:int=',        handlers.channel_search         )
+index               = url('/',                                                              handlers.index                              )
+preferences         = url('/preferences',                                                   handlers.preferences_                       )
+channel_select      = url('/channel_select/?channel:cid',                                   handlers.channel_select                     )
+channel             = url('/channels/{channel:cid}',                                        handlers.channel_last,      count=20        )
+channel_last        = url('/channels/{channel:cid}/last/{count:int=100}',                   handlers.channel_last                       )
+channel_calendar    = url('/channels/{channel:cid}/calendar/{year:int=0}/{month:int=0}',    handlers.channel_calendar                   )
+channel_date        = url('/channels/{channel:cid}/date/{date:date}',                       handlers.channel_date                       )
+channel_search      = url('/channels/{channel:cid}/search/?q=&count:int=&skip:int=',        handlers.channel_search                     )
 
 # mapper
 mapper = urltree.URLTree(urls)