# HG changeset patch # User Tero Marttila # Date 1234054553 -7200 # Node ID fc11c4e86a82231e64ebac0733ea37badf50daaa # Parent 5a72c00c4ae4a1b8733cede79340b632e7eb3ca6 implement channel_view count, the query stuff, css, layout all need some cleanup :( diff -r 5a72c00c4ae4 -r fc11c4e86a82 lib/helpers.py --- a/lib/helpers.py Sun Feb 08 02:29:23 2009 +0200 +++ b/lib/helpers.py Sun Feb 08 02:55:53 2009 +0200 @@ -25,7 +25,7 @@ Returns a short "Validated XHTML & CSS" link text for the given site hostname """ - return 'Validated XHTML 1.0 Strict & CSS 2.1' % dict( + return 'Validated XHTML 1.0 Strict & CSS 2.1' % dict( host = site_host ) diff -r 5a72c00c4ae4 -r fc11c4e86a82 sites/irclogs.qmsk.net/handlers.py --- a/sites/irclogs.qmsk.net/handlers.py Sun Feb 08 02:29:23 2009 +0200 +++ b/sites/irclogs.qmsk.net/handlers.py Sun Feb 08 02:55:53 2009 +0200 @@ -28,14 +28,22 @@ return http.Redirect(urls.channel_view.build(request, channel=channel.id)) -def channel_view (request, channel) : +def channel_view (request, channel, count) : """ The main channel view page, display the most important info, and all requisite links """ + if count == 'all' : + xxx + + else : + count = int(count) + return templates.render_to_response("channel", req = request, channel = channel, + count = count, + lines = channel.source.get_latest(count), ) pass diff -r 5a72c00c4ae4 -r fc11c4e86a82 sites/irclogs.qmsk.net/log_source.py --- a/sites/irclogs.qmsk.net/log_source.py Sun Feb 08 02:29:23 2009 +0200 +++ b/sites/irclogs.qmsk.net/log_source.py Sun Feb 08 02:55:53 2009 +0200 @@ -63,7 +63,7 @@ # read offset # XXX; why -2 ? - offset = self.file.tell() - 2 + size = offset = self.file.tell() - 2 # use this blocksize BLOCKSIZE = 1024 @@ -73,21 +73,25 @@ # read a block at a time, backwards while count > 0 and offset >= 0: - # update offset + # update offset back one block offset -= BLOCKSIZE # normalize to zero if offset < 0 : offset = 0 - # seek backwards one block + # seek to offset self.file.seek(offset) # add the new block to our buffer read_buf = self.file.read(BLOCKSIZE) + # XXX: trim off extra... + if len(read_buf) > BLOCKSIZE : + read_buf = read_buf[:BLOCKSIZE] + # make sure we got the right amount of data - assert len(read_buf) == BLOCKSIZE, "read(%d) -> %d" % (BLOCKSIZE, len(read_buf)) + assert len(read_buf) == BLOCKSIZE, "read(%d) @ %d/%d -> %d" % (BLOCKSIZE, offset, size, len(read_buf)) # add in our previous buf buf = read_buf + buf @@ -99,7 +103,7 @@ buf = buf_lines[0] # add up to count lines to our lines buffer - lines = buf_lines[1:count + 1] + lines + lines = buf_lines[-min(count, len(buf_lines) - 1):] + lines # update count count -= (len(buf_lines) - 1) diff -r 5a72c00c4ae4 -r fc11c4e86a82 sites/irclogs.qmsk.net/templates/channel.tmpl --- a/sites/irclogs.qmsk.net/templates/channel.tmpl Sun Feb 08 02:29:23 2009 +0200 +++ b/sites/irclogs.qmsk.net/templates/channel.tmpl Sun Feb 08 02:55:53 2009 +0200 @@ -17,12 +17,12 @@
  • -
    + View last @@ -38,10 +38,10 @@ -

    ${channel.title} » Last 10 lines

    +

    ${channel.title} » Last ${count} lines

    -% for line in channel.source.get_latest(10) :
    +% for line in lines :
     ${line}
     % endfor
     
    diff -r 5a72c00c4ae4 -r fc11c4e86a82 sites/irclogs.qmsk.net/templates/layout.tmpl --- a/sites/irclogs.qmsk.net/templates/layout.tmpl Sun Feb 08 02:29:23 2009 +0200 +++ b/sites/irclogs.qmsk.net/templates/layout.tmpl Sun Feb 08 02:55:53 2009 +0200 @@ -23,7 +23,7 @@ diff -r 5a72c00c4ae4 -r fc11c4e86a82 sites/irclogs.qmsk.net/urls.py --- a/sites/irclogs.qmsk.net/urls.py Sun Feb 08 02:29:23 2009 +0200 +++ b/sites/irclogs.qmsk.net/urls.py Sun Feb 08 02:55:53 2009 +0200 @@ -27,7 +27,7 @@ # urls index = url('/', handlers.index ) channel_select = url('/channel_select/?channel:cid', handlers.channel_select ) -channel_view = url('/channels/{channel:cid}', handlers.channel_view ) +channel_view = url('/channels/{channel:cid}/?count:str=10', handlers.channel_view ) channel_last = url('/channels/{channel:cid}/last/{count:int=100}/{format=html}', handlers.channel_last ) channel_search = url('/channels/{channel:cid}/search', handlers.channel_search ) diff -r 5a72c00c4ae4 -r fc11c4e86a82 sites/irclogs.qmsk.net/urltree.py --- a/sites/irclogs.qmsk.net/urltree.py Sun Feb 08 02:29:23 2009 +0200 +++ b/sites/irclogs.qmsk.net/urltree.py Sun Feb 08 02:55:53 2009 +0200 @@ -265,6 +265,9 @@ # default None : str, + # string + 'str' : str, + # integer 'int' : int, } @@ -335,8 +338,11 @@ # parse key key = query_item + # type + type = self.config.type_dict[type] + # add to query_args as (type, default) tuple - self.query_args[key] = (self.config.type_dict[type], default) + self.query_args[key] = (type, type(default) if default else default) def get_label_path (self) : """ @@ -359,7 +365,6 @@ kwargs[label_value.label.key] = label_value.value # then parse all query args - # XXX: catch missing arguments for key, value in request.get_args() : # lookup spec type, default = self.query_args[key] @@ -386,6 +391,24 @@ # set key kwargs[key] = value + + # then check all query args + for key, (type, default) in self.query_args.iteritems() : + # skip those already present + if key in kwargs : + continue + + # apply default? + if default is None : + raise URLError("Missing required argument: %r" % (key, )) + + elif default == '' : + # skip empty default + continue + + else : + # set default + kwargs[key] = default # execute the handler return self.handler(request, **kwargs) diff -r 5a72c00c4ae4 -r fc11c4e86a82 static/irclogs.css --- a/static/irclogs.css Sun Feb 08 02:29:23 2009 +0200 +++ b/static/irclogs.css Sun Feb 08 02:55:53 2009 +0200 @@ -112,10 +112,6 @@ * Footer */ div#footer { - /* force to bottom of page */ - position: absolute; - bottom: 0; - width: 100%; padding: 10px 0px 10px;