author | Tero Marttila <terom@fixme.fi> |
Mon, 16 Feb 2009 01:03:23 +0200 | |
changeset 133 | 088aa2da1340 |
parent 131 | 67f5d2fdca1d |
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 |
|
54
b65a95eb9f6b
implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
5 |
import datetime, calendar, pytz |
51
07ca28f3a9f2
use improved URLConfig/URLType
Tero Marttila <terom@fixme.fi>
parents:
50
diff
changeset
|
6 |
|
46
185504387370
reduce to irclogs.qmsk.net site
Tero Marttila <terom@fixme.fi>
parents:
43
diff
changeset
|
7 |
from qmsk.web import http, template |
40 | 8 |
|
50
f13cf27a360b
implement more LogSource features (logs for date, cleanup last_logs), implement irssi parser, formatter, other misc. stuff
Tero Marttila <terom@fixme.fi>
parents:
49
diff
changeset
|
9 |
import urls, channels, helpers |
53
8103d18907a0
add some user-preferences support (e.g. timezone, time formats)
Tero Marttila <terom@fixme.fi>
parents:
51
diff
changeset
|
10 |
import preferences as prefs |
8103d18907a0
add some user-preferences support (e.g. timezone, time formats)
Tero Marttila <terom@fixme.fi>
parents:
51
diff
changeset
|
11 |
from preferences import preferences |
96
d30c88e89a7e
move the LogSearchIndex open from handlers to log_search, and make it lazy
Tero Marttila <terom@fixme.fi>
parents:
87
diff
changeset
|
12 |
import config, log_search |
42
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
13 |
|
41 | 14 |
# load templates from here |
47 | 15 |
templates = template.TemplateLoader("templates", |
54
b65a95eb9f6b
implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
16 |
_helper_class = helpers.Helpers, |
42
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
17 |
urls = urls, |
73
5a7188bf2894
split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
72
diff
changeset
|
18 |
channel_list = config.LOG_CHANNELS, |
5a7188bf2894
split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
72
diff
changeset
|
19 |
config = config, |
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 |
) |
40 | 21 |
|
108
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
22 |
# return a http.Response for the given text in the given format |
118
f530c158aa07
implement some basic search-targets for message and nickname
Tero Marttila <terom@fixme.fi>
parents:
117
diff
changeset
|
23 |
def _render_type (request, channel, lines, type, full_timestamps=False) : |
108
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
24 |
""" |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
25 |
Render the given LogLines as a http.Response in the given format, which is one of: |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
26 |
html - XXX: not supported |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
27 |
txt - Plaintext |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
28 |
png - PNG image |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
29 |
rss - RSS feed |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
30 |
""" |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
31 |
|
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
32 |
# load related preferences |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
33 |
formatter = request.prefs['formatter'] |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
34 |
|
123
3297596ab606
fix calls to format_rss/format_png to use a keyword argument
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
35 |
kwargs = dict( |
3297596ab606
fix calls to format_rss/format_png to use a keyword argument
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
36 |
full_timestamps = full_timestamps |
3297596ab606
fix calls to format_rss/format_png to use a keyword argument
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
37 |
) |
3297596ab606
fix calls to format_rss/format_png to use a keyword argument
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
38 |
|
108
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
39 |
# we can render in various modes... |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
40 |
if type in ('html', None) : |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
41 |
xxx |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
42 |
|
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
43 |
elif type == 'txt' : |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
44 |
# plaintext |
123
3297596ab606
fix calls to format_rss/format_png to use a keyword argument
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
45 |
lines = formatter.format_txt(lines, **kwargs) |
108
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
46 |
|
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
47 |
# build data |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
48 |
data = '\n'.join(data for line, data in lines) |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
49 |
|
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
50 |
return http.Response(data, 'text/plain') |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
51 |
|
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
52 |
elif type == 'png' : |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
53 |
# PNG image |
123
3297596ab606
fix calls to format_rss/format_png to use a keyword argument
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
54 |
png_data = formatter.format_png(lines, **kwargs) |
108
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
55 |
|
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
56 |
return http.Response(png_data, 'image/png', charset=None) |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
57 |
|
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
58 |
elif type == 'rss' : |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
59 |
# RSS feed |
123
3297596ab606
fix calls to format_rss/format_png to use a keyword argument
Tero Marttila <terom@fixme.fi>
parents:
118
diff
changeset
|
60 |
rss_data = formatter.format_rss(lines, **kwargs) |
108
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
61 |
|
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
62 |
# XXX: fix to render as unicode? |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
63 |
return http.Response(rss_data, 'application/rss+xml', charset=None) |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
64 |
|
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
65 |
else : |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
66 |
raise http.ResponseError("Unrecognized type: %r" % (type, )) |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
67 |
|
115
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
68 |
def _render_date (request, channel, date, lines, type, count, page, max) : |
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
69 |
""" |
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
70 |
Render the given LogLines as a http.Response for channel_date |
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
71 |
""" |
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
72 |
|
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
73 |
# type? |
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
74 |
if type : |
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
75 |
# special type |
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
76 |
return _render_type(request, channel, lines, type) |
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
77 |
|
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
78 |
else : |
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
79 |
# format HTML |
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
80 |
lines = request.prefs['formatter'].format_html(lines) |
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
81 |
|
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
82 |
# render |
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
83 |
return templates.render_to_response("channel_date", |
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
84 |
req = request, |
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
85 |
prefs = request.prefs, |
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
86 |
channel = channel, |
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
87 |
date = date, |
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
88 |
count = count, |
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
89 |
page = page, |
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
90 |
max = max, |
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
91 |
lines = lines, |
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
92 |
|
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
93 |
# for prev/next date |
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
94 |
date_next = channel.source.get_next_date(date), |
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
95 |
date_prev = channel.source.get_prev_date(date), |
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
96 |
) |
108
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
97 |
|
131
67f5d2fdca1d
rename config.PREF_TIMEZONE_FALLBACK, add Cookie expire/path info, and move the hg version stuff into the template/helpers
Tero Marttila <terom@fixme.fi>
parents:
129
diff
changeset
|
98 |
@preferences.handler() |
29
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
99 |
def index (request) : |
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
100 |
""" |
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
101 |
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
|
102 |
""" |
40 | 103 |
|
42
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
104 |
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
|
105 |
req = request, |
131
67f5d2fdca1d
rename config.PREF_TIMEZONE_FALLBACK, add Cookie expire/path info, and move the hg version stuff into the template/helpers
Tero Marttila <terom@fixme.fi>
parents:
129
diff
changeset
|
106 |
prefs = request.prefs, |
42
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
107 |
) |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
108 |
|
59
8ec729c5d998
ugly, but working, preferences editor
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
109 |
# XXX: fix this namespace crap |
8ec729c5d998
ugly, but working, preferences editor
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
110 |
@preferences.handler() |
8ec729c5d998
ugly, but working, preferences editor
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
111 |
def preferences_ (request) : |
8ec729c5d998
ugly, but working, preferences editor
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
112 |
""" |
8ec729c5d998
ugly, but working, preferences editor
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
113 |
Preferences editor |
8ec729c5d998
ugly, but working, preferences editor
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
114 |
""" |
8ec729c5d998
ugly, but working, preferences editor
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
115 |
|
8ec729c5d998
ugly, but working, preferences editor
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
116 |
# POST? |
8ec729c5d998
ugly, but working, preferences editor
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
117 |
if request.is_post() : |
8ec729c5d998
ugly, but working, preferences editor
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
118 |
# update any modified preferences |
8ec729c5d998
ugly, but working, preferences editor
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
119 |
for pref in preferences.pref_list : |
129
67a30d680f60
Autodetect user timezone using Javascript, this makes the Preferences code a bit more complicated in terms of interaction between default/parse/is_default/build/process/etc, but it should work as intended now
Tero Marttila <terom@fixme.fi>
parents:
123
diff
changeset
|
120 |
# get the POST'd value, default = None |
67a30d680f60
Autodetect user timezone using Javascript, this makes the Preferences code a bit more complicated in terms of interaction between default/parse/is_default/build/process/etc, but it should work as intended now
Tero Marttila <terom@fixme.fi>
parents:
123
diff
changeset
|
121 |
post_value = request.get_post(pref.name, None) |
59
8ec729c5d998
ugly, but working, preferences editor
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
122 |
|
129
67a30d680f60
Autodetect user timezone using Javascript, this makes the Preferences code a bit more complicated in terms of interaction between default/parse/is_default/build/process/etc, but it should work as intended now
Tero Marttila <terom@fixme.fi>
parents:
123
diff
changeset
|
123 |
# skip non-specified values |
67a30d680f60
Autodetect user timezone using Javascript, this makes the Preferences code a bit more complicated in terms of interaction between default/parse/is_default/build/process/etc, but it should work as intended now
Tero Marttila <terom@fixme.fi>
parents:
123
diff
changeset
|
124 |
# XXX: this is to not clobber timezone_offset to None |
67a30d680f60
Autodetect user timezone using Javascript, this makes the Preferences code a bit more complicated in terms of interaction between default/parse/is_default/build/process/etc, but it should work as intended now
Tero Marttila <terom@fixme.fi>
parents:
123
diff
changeset
|
125 |
if post_value is None : |
67a30d680f60
Autodetect user timezone using Javascript, this makes the Preferences code a bit more complicated in terms of interaction between default/parse/is_default/build/process/etc, but it should work as intended now
Tero Marttila <terom@fixme.fi>
parents:
123
diff
changeset
|
126 |
continue |
67a30d680f60
Autodetect user timezone using Javascript, this makes the Preferences code a bit more complicated in terms of interaction between default/parse/is_default/build/process/etc, but it should work as intended now
Tero Marttila <terom@fixme.fi>
parents:
123
diff
changeset
|
127 |
|
67a30d680f60
Autodetect user timezone using Javascript, this makes the Preferences code a bit more complicated in terms of interaction between default/parse/is_default/build/process/etc, but it should work as intended now
Tero Marttila <terom@fixme.fi>
parents:
123
diff
changeset
|
128 |
# parse the POST'd value, None -> default |
67a30d680f60
Autodetect user timezone using Javascript, this makes the Preferences code a bit more complicated in terms of interaction between default/parse/is_default/build/process/etc, but it should work as intended now
Tero Marttila <terom@fixme.fi>
parents:
123
diff
changeset
|
129 |
new_value = request.prefs.parse(pref, post_value) |
67a30d680f60
Autodetect user timezone using Javascript, this makes the Preferences code a bit more complicated in terms of interaction between default/parse/is_default/build/process/etc, but it should work as intended now
Tero Marttila <terom@fixme.fi>
parents:
123
diff
changeset
|
130 |
|
67a30d680f60
Autodetect user timezone using Javascript, this makes the Preferences code a bit more complicated in terms of interaction between default/parse/is_default/build/process/etc, but it should work as intended now
Tero Marttila <terom@fixme.fi>
parents:
123
diff
changeset
|
131 |
# update if given and changed |
59
8ec729c5d998
ugly, but working, preferences editor
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
132 |
if new_value != request.prefs[pref] : |
8ec729c5d998
ugly, but working, preferences editor
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
133 |
request.prefs.set(pref.name, new_value) |
8ec729c5d998
ugly, but working, preferences editor
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
134 |
|
8ec729c5d998
ugly, but working, preferences editor
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
135 |
# render |
8ec729c5d998
ugly, but working, preferences editor
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
136 |
return templates.render_to_response("preferences", |
8ec729c5d998
ugly, but working, preferences editor
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
137 |
req = request, |
8ec729c5d998
ugly, but working, preferences editor
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
138 |
prefs = request.prefs, |
8ec729c5d998
ugly, but working, preferences editor
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
139 |
preferences = prefs, |
8ec729c5d998
ugly, but working, preferences editor
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
140 |
) |
8ec729c5d998
ugly, but working, preferences editor
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
141 |
|
42
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
142 |
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
|
143 |
""" |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
144 |
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
|
145 |
""" |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
146 |
|
70
72edbbb414a7
merge channel_view and channel_last, adding a More link to channel_last.tmpl
Tero Marttila <terom@fixme.fi>
parents:
66
diff
changeset
|
147 |
return http.Redirect(urls.channel.build(request, channel=channel)) |
29
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
148 |
|
59
8ec729c5d998
ugly, but working, preferences editor
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
149 |
@preferences.handler(prefs.formatter) |
79 | 150 |
def channel_last (request, channel, count, formatter, type=None) : |
29
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
151 |
""" |
70
72edbbb414a7
merge channel_view and channel_last, adding a More link to channel_last.tmpl
Tero Marttila <terom@fixme.fi>
parents:
66
diff
changeset
|
152 |
The main channel view page, displaying the most recent lines |
29
b06ff4c05d42
start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
153 |
""" |
79 | 154 |
|
50
f13cf27a360b
implement more LogSource features (logs for date, cleanup last_logs), implement irssi parser, formatter, other misc. stuff
Tero Marttila <terom@fixme.fi>
parents:
49
diff
changeset
|
155 |
# get latest events |
f13cf27a360b
implement more LogSource features (logs for date, cleanup last_logs), implement irssi parser, formatter, other misc. stuff
Tero Marttila <terom@fixme.fi>
parents:
49
diff
changeset
|
156 |
lines = channel.source.get_latest(count) |
79 | 157 |
|
108
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
158 |
# type? |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
159 |
if type : |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
160 |
# other format |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
161 |
return _render_type(request, channel, lines, type) |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
162 |
|
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
163 |
else : |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
164 |
# format HTML |
79 | 165 |
lines = formatter.format_html(lines) |
43
fc11c4e86a82
implement channel_view count, the query stuff, css, layout all need some cleanup :(
Tero Marttila <terom@fixme.fi>
parents:
42
diff
changeset
|
166 |
|
108
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
167 |
# render page |
79 | 168 |
return templates.render_to_response("channel_last", |
169 |
req = request, |
|
170 |
prefs = request.prefs, |
|
171 |
channel = channel, |
|
172 |
count = count, |
|
173 |
lines = lines, |
|
174 |
) |
|
40 | 175 |
|
78
85345abbd46a
implement pagination for channel_link
Tero Marttila <terom@fixme.fi>
parents:
77
diff
changeset
|
176 |
@preferences.handler(prefs.formatter, prefs.timezone, prefs.count) |
114
d4848d807fd1
center calendar list, add prev/next date to channel_link, add view-last-x-lines form to channel_last/channel
Tero Marttila <terom@fixme.fi>
parents:
112
diff
changeset
|
177 |
def channel_link (request, channel, timestamp, formatter, timezone, count, type=None) : |
72
5ade0288f2ec
implement line-links as UTC timestamps
Tero Marttila <terom@fixme.fi>
parents:
70
diff
changeset
|
178 |
""" |
5ade0288f2ec
implement line-links as UTC timestamps
Tero Marttila <terom@fixme.fi>
parents:
70
diff
changeset
|
179 |
Display channel_date for specific UTC timestamp |
5ade0288f2ec
implement line-links as UTC timestamps
Tero Marttila <terom@fixme.fi>
parents:
70
diff
changeset
|
180 |
""" |
5ade0288f2ec
implement line-links as UTC timestamps
Tero Marttila <terom@fixme.fi>
parents:
70
diff
changeset
|
181 |
|
5ade0288f2ec
implement line-links as UTC timestamps
Tero Marttila <terom@fixme.fi>
parents:
70
diff
changeset
|
182 |
# convert timestamp to user's timezone |
5ade0288f2ec
implement line-links as UTC timestamps
Tero Marttila <terom@fixme.fi>
parents:
70
diff
changeset
|
183 |
timestamp = timestamp.astimezone(timezone) |
5ade0288f2ec
implement line-links as UTC timestamps
Tero Marttila <terom@fixme.fi>
parents:
70
diff
changeset
|
184 |
|
78
85345abbd46a
implement pagination for channel_link
Tero Marttila <terom@fixme.fi>
parents:
77
diff
changeset
|
185 |
# get correct day's correct page of lines |
85345abbd46a
implement pagination for channel_link
Tero Marttila <terom@fixme.fi>
parents:
77
diff
changeset
|
186 |
page, max, lines = channel.source.get_date_paged(timestamp, count) |
108
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
187 |
|
115
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
188 |
# render channel_date |
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
189 |
return _render_date (request, channel, timestamp, lines, type, count, page, max) |
72
5ade0288f2ec
implement line-links as UTC timestamps
Tero Marttila <terom@fixme.fi>
parents:
70
diff
changeset
|
190 |
|
59
8ec729c5d998
ugly, but working, preferences editor
Tero Marttila <terom@fixme.fi>
parents:
56
diff
changeset
|
191 |
@preferences.handler(prefs.timezone) |
54
b65a95eb9f6b
implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
192 |
def channel_calendar (request, channel, year, month, timezone) : |
51
07ca28f3a9f2
use improved URLConfig/URLType
Tero Marttila <terom@fixme.fi>
parents:
50
diff
changeset
|
193 |
""" |
54
b65a95eb9f6b
implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
194 |
Display a list of avilable logs for some month |
51
07ca28f3a9f2
use improved URLConfig/URLType
Tero Marttila <terom@fixme.fi>
parents:
50
diff
changeset
|
195 |
""" |
07ca28f3a9f2
use improved URLConfig/URLType
Tero Marttila <terom@fixme.fi>
parents:
50
diff
changeset
|
196 |
|
54
b65a95eb9f6b
implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
197 |
# current date as default |
b65a95eb9f6b
implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
198 |
now = timezone.localize(datetime.datetime.now()) |
b65a95eb9f6b
implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
199 |
|
b65a95eb9f6b
implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
200 |
# target year/month |
b65a95eb9f6b
implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
201 |
target = timezone.localize(datetime.datetime( |
b65a95eb9f6b
implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
202 |
year = year if year else now.year, |
b65a95eb9f6b
implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
203 |
month = month if month else now.month, |
b65a95eb9f6b
implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
204 |
day = 1 |
b65a95eb9f6b
implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
205 |
)) |
b65a95eb9f6b
implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
206 |
|
b65a95eb9f6b
implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
207 |
# display calendar |
b65a95eb9f6b
implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
208 |
return templates.render_to_response("channel_calendar", |
b65a95eb9f6b
implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
209 |
req = request, |
62
e7ca94b94a4e
add prefs to render context, and remove old timezone/formatter from it
Tero Marttila <terom@fixme.fi>
parents:
59
diff
changeset
|
210 |
prefs = request.prefs, |
54
b65a95eb9f6b
implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
211 |
channel = channel, |
112
090192b64d7e
add three calendars to the channel_calendar view
Tero Marttila <terom@fixme.fi>
parents:
111
diff
changeset
|
212 |
month = target, |
54
b65a95eb9f6b
implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
53
diff
changeset
|
213 |
) |
51
07ca28f3a9f2
use improved URLConfig/URLType
Tero Marttila <terom@fixme.fi>
parents:
50
diff
changeset
|
214 |
|
117
f0b4097f5781
revert to use %Y-%m-%d for URL dates again
Tero Marttila <terom@fixme.fi>
parents:
116
diff
changeset
|
215 |
@preferences.handler(prefs.count, prefs.timezone) |
f0b4097f5781
revert to use %Y-%m-%d for URL dates again
Tero Marttila <terom@fixme.fi>
parents:
116
diff
changeset
|
216 |
def channel_date (request, channel, date, count, timezone, page=1, type=None) : |
50
f13cf27a360b
implement more LogSource features (logs for date, cleanup last_logs), implement irssi parser, formatter, other misc. stuff
Tero Marttila <terom@fixme.fi>
parents:
49
diff
changeset
|
217 |
""" |
f13cf27a360b
implement more LogSource features (logs for date, cleanup last_logs), implement irssi parser, formatter, other misc. stuff
Tero Marttila <terom@fixme.fi>
parents:
49
diff
changeset
|
218 |
Display all log data for the given date |
f13cf27a360b
implement more LogSource features (logs for date, cleanup last_logs), implement irssi parser, formatter, other misc. stuff
Tero Marttila <terom@fixme.fi>
parents:
49
diff
changeset
|
219 |
""" |
116
81da986f6ed5
fix wrong timezone for channel_date
Tero Marttila <terom@fixme.fi>
parents:
115
diff
changeset
|
220 |
|
81da986f6ed5
fix wrong timezone for channel_date
Tero Marttila <terom@fixme.fi>
parents:
115
diff
changeset
|
221 |
# convert date to user's timezone |
117
f0b4097f5781
revert to use %Y-%m-%d for URL dates again
Tero Marttila <terom@fixme.fi>
parents:
116
diff
changeset
|
222 |
date = timezone.localize(date) |
76
cc3ab2c39ded
fix off-by-one with search paginate, and implement basic pagination for channel_date
Tero Marttila <terom@fixme.fi>
parents:
75
diff
changeset
|
223 |
|
115
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
224 |
|
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
225 |
# print "channel_date: date=%s" % date |
50
f13cf27a360b
implement more LogSource features (logs for date, cleanup last_logs), implement irssi parser, formatter, other misc. stuff
Tero Marttila <terom@fixme.fi>
parents:
49
diff
changeset
|
226 |
|
78
85345abbd46a
implement pagination for channel_link
Tero Marttila <terom@fixme.fi>
parents:
77
diff
changeset
|
227 |
# get that day's events, either paged or not |
76
cc3ab2c39ded
fix off-by-one with search paginate, and implement basic pagination for channel_date
Tero Marttila <terom@fixme.fi>
parents:
75
diff
changeset
|
228 |
if page : |
cc3ab2c39ded
fix off-by-one with search paginate, and implement basic pagination for channel_date
Tero Marttila <terom@fixme.fi>
parents:
75
diff
changeset
|
229 |
page, max, lines = channel.source.get_date_paged(date, count, page) |
cc3ab2c39ded
fix off-by-one with search paginate, and implement basic pagination for channel_date
Tero Marttila <terom@fixme.fi>
parents:
75
diff
changeset
|
230 |
|
cc3ab2c39ded
fix off-by-one with search paginate, and implement basic pagination for channel_date
Tero Marttila <terom@fixme.fi>
parents:
75
diff
changeset
|
231 |
else : |
cc3ab2c39ded
fix off-by-one with search paginate, and implement basic pagination for channel_date
Tero Marttila <terom@fixme.fi>
parents:
75
diff
changeset
|
232 |
lines = channel.source.get_date(date) |
cc3ab2c39ded
fix off-by-one with search paginate, and implement basic pagination for channel_date
Tero Marttila <terom@fixme.fi>
parents:
75
diff
changeset
|
233 |
max = None |
50
f13cf27a360b
implement more LogSource features (logs for date, cleanup last_logs), implement irssi parser, formatter, other misc. stuff
Tero Marttila <terom@fixme.fi>
parents:
49
diff
changeset
|
234 |
|
115
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
235 |
# render channel_date |
751e3fcd11d2
have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents:
114
diff
changeset
|
236 |
return _render_date (request, channel, date, lines, type, count, page, max) |
50
f13cf27a360b
implement more LogSource features (logs for date, cleanup last_logs), implement irssi parser, formatter, other misc. stuff
Tero Marttila <terom@fixme.fi>
parents:
49
diff
changeset
|
237 |
|
73
5a7188bf2894
split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents:
72
diff
changeset
|
238 |
@preferences.handler(prefs.formatter, prefs.count) |
118
f530c158aa07
implement some basic search-targets for message and nickname
Tero Marttila <terom@fixme.fi>
parents:
117
diff
changeset
|
239 |
def channel_search (request, channel, formatter, count, q=None, page=1, max=1, type=None, t=None) : |
36
02d4040d5946
start working on some nify URL parsing
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
240 |
""" |
75
c5ce145fdd70
fix pagination to just use page numbers... less bugs
Tero Marttila <terom@fixme.fi>
parents:
74
diff
changeset
|
241 |
Display the search form for the channel for GET, or do the search for POST. |
36
02d4040d5946
start working on some nify URL parsing
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
242 |
""" |
02d4040d5946
start working on some nify URL parsing
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
243 |
|
75
c5ce145fdd70
fix pagination to just use page numbers... less bugs
Tero Marttila <terom@fixme.fi>
parents:
74
diff
changeset
|
244 |
# calculate skip offset from page/count |
76
cc3ab2c39ded
fix off-by-one with search paginate, and implement basic pagination for channel_date
Tero Marttila <terom@fixme.fi>
parents:
75
diff
changeset
|
245 |
skip = (page - 1) * count |
75
c5ce145fdd70
fix pagination to just use page numbers... less bugs
Tero Marttila <terom@fixme.fi>
parents:
74
diff
changeset
|
246 |
|
63 | 247 |
# got a search query? |
248 |
if q : |
|
118
f530c158aa07
implement some basic search-targets for message and nickname
Tero Marttila <terom@fixme.fi>
parents:
117
diff
changeset
|
249 |
# attribute targets |
f530c158aa07
implement some basic search-targets for message and nickname
Tero Marttila <terom@fixme.fi>
parents:
117
diff
changeset
|
250 |
targets = dict(('search_%s' % target, True) for target in t if target in ('msg', 'nick')) if t else {} |
f530c158aa07
implement some basic search-targets for message and nickname
Tero Marttila <terom@fixme.fi>
parents:
117
diff
changeset
|
251 |
|
74
1ab95857d584
handle the 'no search results' case
Tero Marttila <terom@fixme.fi>
parents:
73
diff
changeset
|
252 |
try : |
1ab95857d584
handle the 'no search results' case
Tero Marttila <terom@fixme.fi>
parents:
73
diff
changeset
|
253 |
# do search |
118
f530c158aa07
implement some basic search-targets for message and nickname
Tero Marttila <terom@fixme.fi>
parents:
117
diff
changeset
|
254 |
lines = log_search.get_index().search_simple(channel, q, count, skip, **targets) |
75
c5ce145fdd70
fix pagination to just use page numbers... less bugs
Tero Marttila <terom@fixme.fi>
parents:
74
diff
changeset
|
255 |
|
c5ce145fdd70
fix pagination to just use page numbers... less bugs
Tero Marttila <terom@fixme.fi>
parents:
74
diff
changeset
|
256 |
# update max? |
c5ce145fdd70
fix pagination to just use page numbers... less bugs
Tero Marttila <terom@fixme.fi>
parents:
74
diff
changeset
|
257 |
if max and page > max : |
c5ce145fdd70
fix pagination to just use page numbers... less bugs
Tero Marttila <terom@fixme.fi>
parents:
74
diff
changeset
|
258 |
max = page |
74
1ab95857d584
handle the 'no search results' case
Tero Marttila <terom@fixme.fi>
parents:
73
diff
changeset
|
259 |
|
1ab95857d584
handle the 'no search results' case
Tero Marttila <terom@fixme.fi>
parents:
73
diff
changeset
|
260 |
except log_search.NoResultsFound : |
108
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
261 |
# no results |
74
1ab95857d584
handle the 'no search results' case
Tero Marttila <terom@fixme.fi>
parents:
73
diff
changeset
|
262 |
lines = None |
36
02d4040d5946
start working on some nify URL parsing
Tero Marttila <terom@fixme.fi>
parents:
29
diff
changeset
|
263 |
|
108
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
264 |
else : |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
265 |
# just display the search form |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
266 |
lines = None |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
267 |
|
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
268 |
# type? |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
269 |
if type and lines : |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
270 |
# special type |
118
f530c158aa07
implement some basic search-targets for message and nickname
Tero Marttila <terom@fixme.fi>
parents:
117
diff
changeset
|
271 |
return _render_type(request, channel, lines, type, full_timestamps=True) |
108
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
272 |
|
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
273 |
else : |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
274 |
# format lines to HTML if any |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
275 |
if lines : |
74
1ab95857d584
handle the 'no search results' case
Tero Marttila <terom@fixme.fi>
parents:
73
diff
changeset
|
276 |
# format |
1ab95857d584
handle the 'no search results' case
Tero Marttila <terom@fixme.fi>
parents:
73
diff
changeset
|
277 |
lines = formatter.format_html(lines, full_timestamps=True) |
63 | 278 |
|
108
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
279 |
# render page |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
280 |
return templates.render_to_response("channel_search", |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
281 |
req = request, |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
282 |
prefs = request.prefs, |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
283 |
channel = channel, |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
284 |
search_query = q, |
118
f530c158aa07
implement some basic search-targets for message and nickname
Tero Marttila <terom@fixme.fi>
parents:
117
diff
changeset
|
285 |
search_targets = t, |
108
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
286 |
count = count, |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
287 |
page = page, |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
288 |
skip = skip, |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
289 |
max = max, |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
290 |
lines = lines, |
d0aca7894fc5
split out helpers._render_type, and add support for ?type= to various other handlers... still needs more work, though
Tero Marttila <terom@fixme.fi>
parents:
96
diff
changeset
|
291 |
) |
63 | 292 |