sites/irclogs.qmsk.net/urls.py
branchsites
changeset 41 9585441a4bfb
parent 39 82df0bb66ca7
child 42 5a72c00c4ae4
equal deleted inserted replaced
40:71ab68f31a1c 41:9585441a4bfb
     2 """
     2 """
     3     URL mapping for the irclogs.qmsk.net site
     3     URL mapping for the irclogs.qmsk.net site
     4 """
     4 """
     5 
     5 
     6 # urltree stuff
     6 # urltree stuff
     7 from urltree import URL, URLTree
     7 from urltree import URLConfig, URL, URLTree
     8 
     8 
     9 # our own handlers
     9 # our own handlers
    10 import handlers
    10 import handlers
    11 
    11 
       
    12 # for types
       
    13 import channels 
       
    14 
       
    15 # our URLConfig
       
    16 url_config = URLConfig(
       
    17     type_dict   = { 
       
    18         # lookup LogChannel
       
    19         'cid': channels.channel_list.lookup 
       
    20     }
       
    21 )
       
    22 
       
    23 # shortcut for building an URL with our url_config
       
    24 def url (*args, **kwargs) :
       
    25     return URL(url_config, *args, **kwargs)
       
    26 
    12 # urls
    27 # urls
    13 index           = URL(  '/',                                                        handlers.index                  )
    28 index           = url('/',                                                              handlers.index                  )
    14 channel_view    = URL(  '/channel/{channel}',                                       handlers.channel_view           )
    29 channel_view    = url('/channels/{channel:cid}',                                        handlers.channel_view           )
    15 channel_last    = URL(  '/channel/{channel}/last/{count:int=100}/{format=html}',    handlers.channel_last           )
    30 channel_last    = url('/channels/{channel:cid}/last/{count:int=100}/{format=html}',     handlers.channel_last           )
    16 channel_search  = URL(  '/channel/{channel}/search',                                handlers.channel_search         )
    31 channel_search  = url('/channels/{channel:cid}/search',                                 handlers.channel_search         )
    17 
    32 
    18 # mapper
    33 # mapper
    19 mapper = URLTree([index, channel_view, channel_last, channel_search])
    34 mapper = URLTree(
       
    35     [index, channel_view, channel_last, channel_search]
       
    36 )
    20 
    37