implement channel_view count, the query stuff, css, layout all need some cleanup :(
--- 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 <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(
+ 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(
host = site_host
)
--- 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
--- 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)
--- 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 @@
</li>
<li>
- <form action="#" method="GET">
+ <form action="" method="GET">
View last
<select name="count">
- % for count in (10, 20, 50, 100, 'all') :
- <option>${count}</option>
+ % for cc in (10, 20, 50, 100, 'all') :
+ <option${' selected="selected"' if cc == count else ''}>${cc}</option>
% endfor
</select>
@@ -38,10 +38,10 @@
</ul>
</%def>
-<h1>${channel.title} » Last 10 lines</h1>
+<h1>${channel.title} » Last ${count} lines</h1>
<pre>
-% for line in channel.source.get_latest(10) :
+% for line in lines :
${line}
% endfor
</pre>
--- 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 @@
</div>
<div id="footer-center">
- ${h.validation_notice(req.site_host)}
+ <!-- ${h.validation_notice(req.site_host)} -->
</div>
</div>
</body>
--- 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 )
--- 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)
--- 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;