handlers.py
changeset 46 185504387370
parent 43 fc11c4e86a82
child 47 3d59c9eeffaa
equal deleted inserted replaced
45:e94ab812c0c8 46:185504387370
       
     1 """
       
     2     Our URL action handlers
       
     3 """
       
     4 
       
     5 from qmsk.web import http, template
       
     6 
       
     7 import urls, channels
       
     8 
       
     9 # load templates from here
       
    10 templates = template.TemplateLoader("sites/irclogs.qmsk.net/templates",
       
    11     urls            = urls,
       
    12     channel_list    = channels.channel_list,
       
    13 )
       
    14 
       
    15 def index (request) :
       
    16     """
       
    17         The topmost index page, display a list of available channels, perhaps some general stats
       
    18     """
       
    19     
       
    20     return templates.render_to_response("index",
       
    21         req             = request,
       
    22     )
       
    23 
       
    24 def channel_select (request, channel) :
       
    25     """
       
    26         Redirect to the appropriate channel_view
       
    27     """
       
    28    
       
    29     return http.Redirect(urls.channel_view.build(request, channel=channel.id))
       
    30 
       
    31 def channel_view (request, channel, count) :
       
    32     """
       
    33         The main channel view page, display the most important info, and all requisite links
       
    34     """
       
    35 
       
    36     if count == 'all' :
       
    37         xxx
       
    38 
       
    39     else :
       
    40         count = int(count)
       
    41 
       
    42     return templates.render_to_response("channel",
       
    43         req             = request,
       
    44         channel         = channel,
       
    45         count           = count,
       
    46         lines           = channel.source.get_latest(count),
       
    47     )
       
    48 
       
    49     pass
       
    50 
       
    51 def channel_last (request, channel, count, format) :
       
    52     """
       
    53         Display the last x lines of channel messages in various formats
       
    54     """
       
    55 
       
    56     if format == 'txt' :
       
    57         return http.Response('\n'.join(channel.source.get_latest(count)), 'text/plain')
       
    58     
       
    59     else :
       
    60         raise http.ResponseError("Unknown filetype %r" % format)
       
    61 
       
    62 def channel_search (request, channel) :
       
    63     """
       
    64         Display the search form for the channel for GET, or do the search for POST
       
    65     """
       
    66 
       
    67     pass
       
    68