implement channel_view count, the query stuff, css, layout all need some cleanup :(
1.1 --- a/lib/helpers.py Sun Feb 08 02:29:23 2009 +0200
1.2 +++ b/lib/helpers.py Sun Feb 08 02:55:53 2009 +0200
1.3 @@ -25,7 +25,7 @@
1.4 Returns a short "Validated XHTML & CSS" link text for the given site hostname
1.5 """
1.6
1.7 - return 'Validated <a href="http://validator.w3.org/check?uri=%(host)s">XHTML 1.0 Strict</a> & <a href="http://jigsaw.w3.org/css-validator/validator?uri=%(host)s">CSS 2.1</a>' % dict(
1.8 + return 'Validated <a href="http://validator.w3.org/check?uri=http://%(host)s">XHTML 1.0 Strict</a> & <a href="http://jigsaw.w3.org/css-validator/validator?uri=http://%(host)s">CSS 2.1</a>' % dict(
1.9 host = site_host
1.10 )
1.11
2.1 --- a/sites/irclogs.qmsk.net/handlers.py Sun Feb 08 02:29:23 2009 +0200
2.2 +++ b/sites/irclogs.qmsk.net/handlers.py Sun Feb 08 02:55:53 2009 +0200
2.3 @@ -28,14 +28,22 @@
2.4
2.5 return http.Redirect(urls.channel_view.build(request, channel=channel.id))
2.6
2.7 -def channel_view (request, channel) :
2.8 +def channel_view (request, channel, count) :
2.9 """
2.10 The main channel view page, display the most important info, and all requisite links
2.11 """
2.12
2.13 + if count == 'all' :
2.14 + xxx
2.15 +
2.16 + else :
2.17 + count = int(count)
2.18 +
2.19 return templates.render_to_response("channel",
2.20 req = request,
2.21 channel = channel,
2.22 + count = count,
2.23 + lines = channel.source.get_latest(count),
2.24 )
2.25
2.26 pass
3.1 --- a/sites/irclogs.qmsk.net/log_source.py Sun Feb 08 02:29:23 2009 +0200
3.2 +++ b/sites/irclogs.qmsk.net/log_source.py Sun Feb 08 02:55:53 2009 +0200
3.3 @@ -63,7 +63,7 @@
3.4
3.5 # read offset
3.6 # XXX; why -2 ?
3.7 - offset = self.file.tell() - 2
3.8 + size = offset = self.file.tell() - 2
3.9
3.10 # use this blocksize
3.11 BLOCKSIZE = 1024
3.12 @@ -73,21 +73,25 @@
3.13
3.14 # read a block at a time, backwards
3.15 while count > 0 and offset >= 0:
3.16 - # update offset
3.17 + # update offset back one block
3.18 offset -= BLOCKSIZE
3.19
3.20 # normalize to zero
3.21 if offset < 0 :
3.22 offset = 0
3.23
3.24 - # seek backwards one block
3.25 + # seek to offset
3.26 self.file.seek(offset)
3.27
3.28 # add the new block to our buffer
3.29 read_buf = self.file.read(BLOCKSIZE)
3.30
3.31 + # XXX: trim off extra...
3.32 + if len(read_buf) > BLOCKSIZE :
3.33 + read_buf = read_buf[:BLOCKSIZE]
3.34 +
3.35 # make sure we got the right amount of data
3.36 - assert len(read_buf) == BLOCKSIZE, "read(%d) -> %d" % (BLOCKSIZE, len(read_buf))
3.37 + assert len(read_buf) == BLOCKSIZE, "read(%d) @ %d/%d -> %d" % (BLOCKSIZE, offset, size, len(read_buf))
3.38
3.39 # add in our previous buf
3.40 buf = read_buf + buf
3.41 @@ -99,7 +103,7 @@
3.42 buf = buf_lines[0]
3.43
3.44 # add up to count lines to our lines buffer
3.45 - lines = buf_lines[1:count + 1] + lines
3.46 + lines = buf_lines[-min(count, len(buf_lines) - 1):] + lines
3.47
3.48 # update count
3.49 count -= (len(buf_lines) - 1)
4.1 --- a/sites/irclogs.qmsk.net/templates/channel.tmpl Sun Feb 08 02:29:23 2009 +0200
4.2 +++ b/sites/irclogs.qmsk.net/templates/channel.tmpl Sun Feb 08 02:55:53 2009 +0200
4.3 @@ -17,12 +17,12 @@
4.4 </li>
4.5
4.6 <li>
4.7 - <form action="#" method="GET">
4.8 + <form action="" method="GET">
4.9 View last
4.10
4.11 <select name="count">
4.12 - % for count in (10, 20, 50, 100, 'all') :
4.13 - <option>${count}</option>
4.14 + % for cc in (10, 20, 50, 100, 'all') :
4.15 + <option${' selected="selected"' if cc == count else ''}>${cc}</option>
4.16 % endfor
4.17 </select>
4.18
4.19 @@ -38,10 +38,10 @@
4.20 </ul>
4.21 </%def>
4.22
4.23 -<h1>${channel.title} » Last 10 lines</h1>
4.24 +<h1>${channel.title} » Last ${count} lines</h1>
4.25
4.26 <pre>
4.27 -% for line in channel.source.get_latest(10) :
4.28 +% for line in lines :
4.29 ${line}
4.30 % endfor
4.31 </pre>
5.1 --- a/sites/irclogs.qmsk.net/templates/layout.tmpl Sun Feb 08 02:29:23 2009 +0200
5.2 +++ b/sites/irclogs.qmsk.net/templates/layout.tmpl Sun Feb 08 02:55:53 2009 +0200
5.3 @@ -23,7 +23,7 @@
5.4 </div>
5.5
5.6 <div id="footer-center">
5.7 - ${h.validation_notice(req.site_host)}
5.8 + <!-- ${h.validation_notice(req.site_host)} -->
5.9 </div>
5.10 </div>
5.11 </body>
6.1 --- a/sites/irclogs.qmsk.net/urls.py Sun Feb 08 02:29:23 2009 +0200
6.2 +++ b/sites/irclogs.qmsk.net/urls.py Sun Feb 08 02:55:53 2009 +0200
6.3 @@ -27,7 +27,7 @@
6.4 # urls
6.5 index = url('/', handlers.index )
6.6 channel_select = url('/channel_select/?channel:cid', handlers.channel_select )
6.7 -channel_view = url('/channels/{channel:cid}', handlers.channel_view )
6.8 +channel_view = url('/channels/{channel:cid}/?count:str=10', handlers.channel_view )
6.9 channel_last = url('/channels/{channel:cid}/last/{count:int=100}/{format=html}', handlers.channel_last )
6.10 channel_search = url('/channels/{channel:cid}/search', handlers.channel_search )
6.11
7.1 --- a/sites/irclogs.qmsk.net/urltree.py Sun Feb 08 02:29:23 2009 +0200
7.2 +++ b/sites/irclogs.qmsk.net/urltree.py Sun Feb 08 02:55:53 2009 +0200
7.3 @@ -265,6 +265,9 @@
7.4 # default
7.5 None : str,
7.6
7.7 + # string
7.8 + 'str' : str,
7.9 +
7.10 # integer
7.11 'int' : int,
7.12 }
7.13 @@ -335,8 +338,11 @@
7.14 # parse key
7.15 key = query_item
7.16
7.17 + # type
7.18 + type = self.config.type_dict[type]
7.19 +
7.20 # add to query_args as (type, default) tuple
7.21 - self.query_args[key] = (self.config.type_dict[type], default)
7.22 + self.query_args[key] = (type, type(default) if default else default)
7.23
7.24 def get_label_path (self) :
7.25 """
7.26 @@ -359,7 +365,6 @@
7.27 kwargs[label_value.label.key] = label_value.value
7.28
7.29 # then parse all query args
7.30 - # XXX: catch missing arguments
7.31 for key, value in request.get_args() :
7.32 # lookup spec
7.33 type, default = self.query_args[key]
7.34 @@ -386,6 +391,24 @@
7.35
7.36 # set key
7.37 kwargs[key] = value
7.38 +
7.39 + # then check all query args
7.40 + for key, (type, default) in self.query_args.iteritems() :
7.41 + # skip those already present
7.42 + if key in kwargs :
7.43 + continue
7.44 +
7.45 + # apply default?
7.46 + if default is None :
7.47 + raise URLError("Missing required argument: %r" % (key, ))
7.48 +
7.49 + elif default == '' :
7.50 + # skip empty default
7.51 + continue
7.52 +
7.53 + else :
7.54 + # set default
7.55 + kwargs[key] = default
7.56
7.57 # execute the handler
7.58 return self.handler(request, **kwargs)
8.1 --- a/static/irclogs.css Sun Feb 08 02:29:23 2009 +0200
8.2 +++ b/static/irclogs.css Sun Feb 08 02:55:53 2009 +0200
8.3 @@ -112,10 +112,6 @@
8.4 * Footer
8.5 */
8.6 div#footer {
8.7 - /* force to bottom of page */
8.8 - position: absolute;
8.9 - bottom: 0;
8.10 -
8.11 width: 100%;
8.12 padding: 10px 0px 10px;
8.13