sites/irclogs.qmsk.net/handlers.py
branchsites
changeset 41 9585441a4bfb
parent 40 71ab68f31a1c
child 42 5a72c00c4ae4
equal deleted inserted replaced
40:71ab68f31a1c 41:9585441a4bfb
     1 """
     1 """
     2     Our URL action handlers
     2     Our URL action handlers
     3 """
     3 """
     4 
     4 
     5 from lib import template
     5 from lib import http, template
     6 
     6 
       
     7 # load templates from here
     7 templates = template.TemplateLoader("sites/irclogs.qmsk.net/templates")
     8 templates = template.TemplateLoader("sites/irclogs.qmsk.net/templates")
     8 
     9 
     9 def index (request) :
    10 def index (request) :
    10     """
    11     """
    11         The topmost index page, display a list of available channels, perhaps some general stats
    12         The topmost index page, display a list of available channels, perhaps some general stats
    17     """
    18     """
    18         The main channel view page, display the most important info, and all requisite links
    19         The main channel view page, display the most important info, and all requisite links
    19     """
    20     """
    20 
    21 
    21     return templates.render_to_response("channel",
    22     return templates.render_to_response("channel",
    22         channel_name        = channel,
    23         channel         = channel,
    23     )
    24     )
    24 
    25 
    25     pass
    26     pass
    26 
    27 
    27 def channel_last (request, channel, lines, type) :
    28 def channel_last (request, channel, count, format) :
    28     """
    29     """
    29         Display the last x lines of channel messages in various formats
    30         Display the last x lines of channel messages in various formats
    30     """
    31     """
    31 
    32 
    32     pass
    33     if format == 'txt' :
       
    34         return http.Response('\n'.join(channel.source.get_latest(count)), 'text/plain')
       
    35     
       
    36     else :
       
    37         raise http.ResponseError("Unknown filetype %r" % format)
    33 
    38 
    34 def channel_search (request, channel) :
    39 def channel_search (request, channel) :
    35     """
    40     """
    36         Display the search form for the channel for GET, or do the search for POST
    41         Display the search form for the channel for GET, or do the search for POST
    37     """
    42     """