author | Tero Marttila <terom@fixme.fi> |
Sun, 08 Feb 2009 03:23:25 +0200 | |
changeset 46 | 185504387370 |
parent 43 | sites/irclogs.qmsk.net/handlers.py@fc11c4e86a82 |
child 47 | 3d59c9eeffaa |
permissions | -rw-r--r-- |
29
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
1 |
""" |
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
2 |
Our URL action handlers |
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
3 |
""" |
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
4 |
|
46
185504387370
reduce to irclogs.qmsk.net site
Tero Marttila <terom@fixme.fi>
parents:
43
diff
changeset
|
5 |
from qmsk.web import http, template |
40 | 6 |
|
42
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
7 |
import urls, channels |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
8 |
|
41 | 9 |
# load templates from here |
42
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
10 |
templates = template.TemplateLoader("sites/irclogs.qmsk.net/templates", |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
11 |
urls = urls, |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
12 |
channel_list = channels.channel_list, |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
13 |
) |
40 | 14 |
|
29
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
15 |
def index (request) : |
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
16 |
""" |
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
17 |
The topmost index page, display a list of available channels, perhaps some general stats |
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
18 |
""" |
40 | 19 |
|
42
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
20 |
return templates.render_to_response("index", |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
21 |
req = request, |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
22 |
) |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
23 |
|
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
24 |
def channel_select (request, channel) : |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
25 |
""" |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
26 |
Redirect to the appropriate channel_view |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
27 |
""" |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
28 |
|
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
29 |
return http.Redirect(urls.channel_view.build(request, channel=channel.id)) |
29
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
30 |
|
43
fc11c4e86a82
implement channel_view count, the query stuff, css, layout all need some cleanup :(
Tero Marttila <terom@fixme.fi>
parents:
42
diff
changeset
|
31 |
def channel_view (request, channel, count) : |
29
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
32 |
""" |
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
33 |
The main channel view page, display the most important info, and all requisite links |
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
34 |
""" |
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
35 |
|
43
fc11c4e86a82
implement channel_view count, the query stuff, css, layout all need some cleanup :(
Tero Marttila <terom@fixme.fi>
parents:
42
diff
changeset
|
36 |
if count == 'all' : |
fc11c4e86a82
implement channel_view count, the query stuff, css, layout all need some cleanup :(
Tero Marttila <terom@fixme.fi>
parents:
42
diff
changeset
|
37 |
xxx |
fc11c4e86a82
implement channel_view count, the query stuff, css, layout all need some cleanup :(
Tero Marttila <terom@fixme.fi>
parents:
42
diff
changeset
|
38 |
|
fc11c4e86a82
implement channel_view count, the query stuff, css, layout all need some cleanup :(
Tero Marttila <terom@fixme.fi>
parents:
42
diff
changeset
|
39 |
else : |
fc11c4e86a82
implement channel_view count, the query stuff, css, layout all need some cleanup :(
Tero Marttila <terom@fixme.fi>
parents:
42
diff
changeset
|
40 |
count = int(count) |
fc11c4e86a82
implement channel_view count, the query stuff, css, layout all need some cleanup :(
Tero Marttila <terom@fixme.fi>
parents:
42
diff
changeset
|
41 |
|
40 | 42 |
return templates.render_to_response("channel", |
42
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
43 |
req = request, |
41 | 44 |
channel = channel, |
43
fc11c4e86a82
implement channel_view count, the query stuff, css, layout all need some cleanup :(
Tero Marttila <terom@fixme.fi>
parents:
42
diff
changeset
|
45 |
count = count, |
fc11c4e86a82
implement channel_view count, the query stuff, css, layout all need some cleanup :(
Tero Marttila <terom@fixme.fi>
parents:
42
diff
changeset
|
46 |
lines = channel.source.get_latest(count), |
40 | 47 |
) |
48 |
||
29
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
49 |
pass |
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
50 |
|
41 | 51 |
def channel_last (request, channel, count, format) : |
29
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
52 |
""" |
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
53 |
Display the last x lines of channel messages in various formats |
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
54 |
""" |
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
55 |
|
41 | 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) |
|
29
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
61 |
|
36
02d4040d5946
start working on some nify URL parsing
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
62 |
def channel_search (request, channel) : |
02d4040d5946
start working on some nify URL parsing
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
63 |
""" |
02d4040d5946
start working on some nify URL parsing
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
64 |
Display the search form for the channel for GET, or do the search for POST |
02d4040d5946
start working on some nify URL parsing
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
65 |
""" |
02d4040d5946
start working on some nify URL parsing
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
66 |
|
02d4040d5946
start working on some nify URL parsing
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
67 |
pass |
02d4040d5946
start working on some nify URL parsing
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
68 |