59 return http.Response(rss_data, 'application/rss+xml', charset=None) |
59 return http.Response(rss_data, 'application/rss+xml', charset=None) |
60 |
60 |
61 else : |
61 else : |
62 raise http.ResponseError("Unrecognized type: %r" % (type, )) |
62 raise http.ResponseError("Unrecognized type: %r" % (type, )) |
63 |
63 |
|
64 def _render_date (request, channel, date, lines, type, count, page, max) : |
|
65 """ |
|
66 Render the given LogLines as a http.Response for channel_date |
|
67 """ |
|
68 |
|
69 # type? |
|
70 if type : |
|
71 # special type |
|
72 return _render_type(request, channel, lines, type) |
|
73 |
|
74 else : |
|
75 # format HTML |
|
76 lines = request.prefs['formatter'].format_html(lines) |
|
77 |
|
78 # render |
|
79 return templates.render_to_response("channel_date", |
|
80 req = request, |
|
81 prefs = request.prefs, |
|
82 channel = channel, |
|
83 date = date, |
|
84 count = count, |
|
85 page = page, |
|
86 max = max, |
|
87 lines = lines, |
|
88 |
|
89 # for prev/next date |
|
90 date_next = channel.source.get_next_date(date), |
|
91 date_prev = channel.source.get_prev_date(date), |
|
92 ) |
64 |
93 |
65 def index (request) : |
94 def index (request) : |
66 """ |
95 """ |
67 The topmost index page, display a list of available channels, perhaps some general stats |
96 The topmost index page, display a list of available channels, perhaps some general stats |
68 """ |
97 """ |
141 # convert timestamp to user's timezone |
170 # convert timestamp to user's timezone |
142 timestamp = timestamp.astimezone(timezone) |
171 timestamp = timestamp.astimezone(timezone) |
143 |
172 |
144 # get correct day's correct page of lines |
173 # get correct day's correct page of lines |
145 page, max, lines = channel.source.get_date_paged(timestamp, count) |
174 page, max, lines = channel.source.get_date_paged(timestamp, count) |
146 |
175 |
147 # type? |
176 # render channel_date |
148 if type : |
177 return _render_date (request, channel, timestamp, lines, type, count, page, max) |
149 # special type |
|
150 return _render_type(request, channel, lines, type) |
|
151 |
|
152 else : |
|
153 # format HTML |
|
154 lines = formatter.format_html(lines) |
|
155 |
|
156 # render |
|
157 return templates.render_to_response("channel_date", |
|
158 req = request, |
|
159 prefs = request.prefs, |
|
160 channel = channel, |
|
161 date = timestamp, |
|
162 page = page, |
|
163 count = count, |
|
164 max = max, |
|
165 lines = lines, |
|
166 |
|
167 # for prev/next date |
|
168 date_next = channel.source.get_next_date(timestamp), |
|
169 date_prev = channel.source.get_prev_date(timestamp), |
|
170 ) |
|
171 |
178 |
172 @preferences.handler(prefs.timezone) |
179 @preferences.handler(prefs.timezone) |
173 def channel_calendar (request, channel, year, month, timezone) : |
180 def channel_calendar (request, channel, year, month, timezone) : |
174 """ |
181 """ |
175 Display a list of avilable logs for some month |
182 Display a list of avilable logs for some month |
191 prefs = request.prefs, |
198 prefs = request.prefs, |
192 channel = channel, |
199 channel = channel, |
193 month = target, |
200 month = target, |
194 ) |
201 ) |
195 |
202 |
196 @preferences.handler(prefs.formatter, prefs.timezone, prefs.count) |
203 @preferences.handler(prefs.count) |
197 def channel_date (request, channel, date, formatter, timezone, count, page=1, type=None) : |
204 def channel_date (request, channel, date, count, page=1, type=None) : |
198 """ |
205 """ |
199 Display all log data for the given date |
206 Display all log data for the given date |
200 """ |
207 """ |
201 |
208 |
202 # fix date timezone |
209 # print |
203 date = timezone.localize(date) |
210 # print "channel_date: date=%s" % date |
204 |
211 |
205 # get that day's events, either paged or not |
212 # get that day's events, either paged or not |
206 if page : |
213 if page : |
207 page, max, lines = channel.source.get_date_paged(date, count, page) |
214 page, max, lines = channel.source.get_date_paged(date, count, page) |
208 |
215 |
209 else : |
216 else : |
210 lines = channel.source.get_date(date) |
217 lines = channel.source.get_date(date) |
211 max = None |
218 max = None |
212 |
219 |
213 # type? |
220 # render channel_date |
214 if type : |
221 return _render_date (request, channel, date, lines, type, count, page, max) |
215 # special type |
|
216 return _render_type(request, channel, lines, type) |
|
217 |
|
218 else : |
|
219 # lines |
|
220 lines = formatter.format_html(lines) |
|
221 |
|
222 # render page |
|
223 return templates.render_to_response("channel_date", |
|
224 req = request, |
|
225 prefs = request.prefs, |
|
226 channel = channel, |
|
227 date = date, |
|
228 page = page, |
|
229 count = count, |
|
230 max = max, |
|
231 lines = lines, |
|
232 |
|
233 # for prev/next date |
|
234 date_next = channel.source.get_next_date(date), |
|
235 date_prev = channel.source.get_prev_date(date), |
|
236 ) |
|
237 |
222 |
238 @preferences.handler(prefs.formatter, prefs.count) |
223 @preferences.handler(prefs.formatter, prefs.count) |
239 def channel_search (request, channel, formatter, count, q=None, page=1, max=1, type=None) : |
224 def channel_search (request, channel, formatter, count, q=None, page=1, max=1, type=None) : |
240 """ |
225 """ |
241 Display the search form for the channel for GET, or do the search for POST. |
226 Display the search form for the channel for GET, or do the search for POST. |