author | Tero Marttila <terom@fixme.fi> |
Sun, 08 Feb 2009 02:29:23 +0200 | |
branch | sites |
changeset 42 | 5a72c00c4ae4 |
parent 41 | 9585441a4bfb |
child 43 | fc11c4e86a82 |
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 |
|
41 | 5 |
from lib 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 |
|
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
31 |
def channel_view (request, channel) : |
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 |
|
40 | 36 |
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
|
37 |
req = request, |
41 | 38 |
channel = channel, |
40 | 39 |
) |
40 |
||
29
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
41 |
pass |
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
42 |
|
41 | 43 |
def channel_last (request, channel, count, format) : |
29
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
44 |
""" |
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
45 |
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
|
46 |
""" |
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
47 |
|
41 | 48 |
if format == 'txt' : |
49 |
return http.Response('\n'.join(channel.source.get_latest(count)), 'text/plain') |
|
50 |
||
51 |
else : |
|
52 |
raise http.ResponseError("Unknown filetype %r" % format) |
|
29
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
53 |
|
36
02d4040d5946
start working on some nify URL parsing
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
54 |
def channel_search (request, channel) : |
02d4040d5946
start working on some nify URL parsing
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
55 |
""" |
02d4040d5946
start working on some nify URL parsing
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
56 |
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
|
57 |
""" |
02d4040d5946
start working on some nify URL parsing
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
58 |
|
02d4040d5946
start working on some nify URL parsing
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
59 |
pass |
02d4040d5946
start working on some nify URL parsing
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
60 |