author | Tero Marttila <terom@fixme.fi> |
Sun, 08 Feb 2009 02:55:53 +0200 | |
branch | sites |
changeset 184 | a3d9aa76790d |
parent 183 | 8c8d082c4657 |
permissions | -rw-r--r-- |
170
532c595efa1a
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
1 |
""" |
532c595efa1a
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
2 |
Our URL action handlers |
532c595efa1a
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
3 |
""" |
532c595efa1a
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
4 |
|
182 | 5 |
from lib import http, template |
181 | 6 |
|
183
8c8d082c4657
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
182
diff
changeset
|
7 |
import urls, channels |
8c8d082c4657
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
182
diff
changeset
|
8 |
|
182 | 9 |
# load templates from here |
183
8c8d082c4657
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
182
diff
changeset
|
10 |
templates = template.TemplateLoader("sites/irclogs.qmsk.net/templates", |
8c8d082c4657
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
182
diff
changeset
|
11 |
urls = urls, |
8c8d082c4657
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
182
diff
changeset
|
12 |
channel_list = channels.channel_list, |
8c8d082c4657
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
182
diff
changeset
|
13 |
) |
181 | 14 |
|
170
532c595efa1a
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
15 |
def index (request) : |
532c595efa1a
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
16 |
""" |
532c595efa1a
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 |
532c595efa1a
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
18 |
""" |
181 | 19 |
|
183
8c8d082c4657
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
182
diff
changeset
|
20 |
return templates.render_to_response("index", |
8c8d082c4657
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
182
diff
changeset
|
21 |
req = request, |
8c8d082c4657
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
182
diff
changeset
|
22 |
) |
8c8d082c4657
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
182
diff
changeset
|
23 |
|
8c8d082c4657
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
182
diff
changeset
|
24 |
def channel_select (request, channel) : |
8c8d082c4657
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
182
diff
changeset
|
25 |
""" |
8c8d082c4657
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
182
diff
changeset
|
26 |
Redirect to the appropriate channel_view |
8c8d082c4657
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
182
diff
changeset
|
27 |
""" |
8c8d082c4657
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
182
diff
changeset
|
28 |
|
8c8d082c4657
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
182
diff
changeset
|
29 |
return http.Redirect(urls.channel_view.build(request, channel=channel.id)) |
170
532c595efa1a
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
30 |
|
184
a3d9aa76790d
implement channel_view count, the query stuff, css, layout all need some cleanup :(
Tero Marttila <terom@fixme.fi>
parents:
183
diff
changeset
|
31 |
def channel_view (request, channel, count) : |
170
532c595efa1a
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
32 |
""" |
532c595efa1a
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 |
532c595efa1a
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
34 |
""" |
532c595efa1a
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
35 |
|
184
a3d9aa76790d
implement channel_view count, the query stuff, css, layout all need some cleanup :(
Tero Marttila <terom@fixme.fi>
parents:
183
diff
changeset
|
36 |
if count == 'all' : |
a3d9aa76790d
implement channel_view count, the query stuff, css, layout all need some cleanup :(
Tero Marttila <terom@fixme.fi>
parents:
183
diff
changeset
|
37 |
xxx |
a3d9aa76790d
implement channel_view count, the query stuff, css, layout all need some cleanup :(
Tero Marttila <terom@fixme.fi>
parents:
183
diff
changeset
|
38 |
|
a3d9aa76790d
implement channel_view count, the query stuff, css, layout all need some cleanup :(
Tero Marttila <terom@fixme.fi>
parents:
183
diff
changeset
|
39 |
else : |
a3d9aa76790d
implement channel_view count, the query stuff, css, layout all need some cleanup :(
Tero Marttila <terom@fixme.fi>
parents:
183
diff
changeset
|
40 |
count = int(count) |
a3d9aa76790d
implement channel_view count, the query stuff, css, layout all need some cleanup :(
Tero Marttila <terom@fixme.fi>
parents:
183
diff
changeset
|
41 |
|
181 | 42 |
return templates.render_to_response("channel", |
183
8c8d082c4657
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
182
diff
changeset
|
43 |
req = request, |
182 | 44 |
channel = channel, |
184
a3d9aa76790d
implement channel_view count, the query stuff, css, layout all need some cleanup :(
Tero Marttila <terom@fixme.fi>
parents:
183
diff
changeset
|
45 |
count = count, |
a3d9aa76790d
implement channel_view count, the query stuff, css, layout all need some cleanup :(
Tero Marttila <terom@fixme.fi>
parents:
183
diff
changeset
|
46 |
lines = channel.source.get_latest(count), |
181 | 47 |
) |
48 |
||
170
532c595efa1a
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
49 |
pass |
532c595efa1a
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
50 |
|
182 | 51 |
def channel_last (request, channel, count, format) : |
170
532c595efa1a
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
52 |
""" |
532c595efa1a
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 |
532c595efa1a
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
54 |
""" |
532c595efa1a
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
55 |
|
182 | 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) |
|
170
532c595efa1a
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
61 |
|
177
578eab5dafdc
start working on some nify URL parsing
Tero Marttila <terom@fixme.fi>
parents:
170
diff
changeset
|
62 |
def channel_search (request, channel) : |
578eab5dafdc
start working on some nify URL parsing
Tero Marttila <terom@fixme.fi>
parents:
170
diff
changeset
|
63 |
""" |
578eab5dafdc
start working on some nify URL parsing
Tero Marttila <terom@fixme.fi>
parents:
170
diff
changeset
|
64 |
Display the search form for the channel for GET, or do the search for POST |
578eab5dafdc
start working on some nify URL parsing
Tero Marttila <terom@fixme.fi>
parents:
170
diff
changeset
|
65 |
""" |
578eab5dafdc
start working on some nify URL parsing
Tero Marttila <terom@fixme.fi>
parents:
170
diff
changeset
|
66 |
|
578eab5dafdc
start working on some nify URL parsing
Tero Marttila <terom@fixme.fi>
parents:
170
diff
changeset
|
67 |
pass |
578eab5dafdc
start working on some nify URL parsing
Tero Marttila <terom@fixme.fi>
parents:
170
diff
changeset
|
68 |