# HG changeset patch # User Tero Marttila # Date 1234151069 -7200 # Node ID 5667d2bbdc50b0a86c98606ee8772cff4894d049 # Parent b65a95eb9f6bd87fbb5751d219ba956c7b8ead5b improve calendar further diff -r b65a95eb9f6b -r 5667d2bbdc50 handlers.py --- a/handlers.py Mon Feb 09 04:39:24 2009 +0200 +++ b/handlers.py Mon Feb 09 05:44:29 2009 +0200 @@ -31,7 +31,7 @@ Redirect to the appropriate channel_view """ - return http.Redirect(urls.channel_view.build(request, channel=channel.id)) + return http.Redirect(urls.channel_view.build(request, channel=channel)) @preferences.handler(prefs.Formatter, prefs.Timezone) def channel_view (request, channel, count, formatter, timezone) : diff -r b65a95eb9f6b -r 5667d2bbdc50 helpers.py --- a/helpers.py Mon Feb 09 04:39:24 2009 +0200 +++ b/helpers.py Mon Feb 09 05:44:29 2009 +0200 @@ -54,4 +54,48 @@ # construct current date return date == self.ctx['timezone'].localize(datetime.datetime.now()).date() - + + def prev_month_year (self, month) : + """ + Returns the year of the month before the given one + """ + + if month.month == 1 : + return month.year - 1 + + else : + return month.year + + def next_month_year (self, month) : + """ + Returns the year of the month after the given one + """ + + if month.month == 12 : + return month.year + 1 + + else : + return month.year + + def prev_month (self, month) : + """ + Returns the month before the given one + """ + + if month.month == 1 : + return 12 + + else : + return month.month - 1 + + def next_month (self, month) : + """ + Returns the month after the given one + """ + + if month.month == 12 : + return 1 + + else : + return month.month + 1 + diff -r b65a95eb9f6b -r 5667d2bbdc50 log_formatter.py --- a/log_formatter.py Mon Feb 09 04:39:24 2009 +0200 +++ b/log_formatter.py Mon Feb 09 05:44:29 2009 +0200 @@ -2,7 +2,8 @@ Format LogLines into some other representation """ -from qmsk.web import helpers +# for escape +import cgi from log_line import LogTypes @@ -88,7 +89,7 @@ # format using IrssiTextFormatter for line in self.format_txt(lines) : # escape HTML - yield helpers.escape(line) + yield cgi.escape(line) # close pre yield "" diff -r b65a95eb9f6b -r 5667d2bbdc50 log_source.py --- a/log_source.py Mon Feb 09 04:39:24 2009 +0200 +++ b/log_source.py Mon Feb 09 05:44:29 2009 +0200 @@ -351,9 +351,12 @@ # open both of them f_begin = self._get_logfile_date(d_begin) f_end = self._get_logfile_date(d_end) - + # chain together the two sources - return itertools.chain(f_begin.read_from(dtz_begin), f_end.read_until(dtz_end)) + return itertools.chain( + f_begin.read_from(dtz_begin), + f_end.read_until(dtz_end) if f_end else [] + ) def get_month_days (self, month) : """ diff -r b65a95eb9f6b -r 5667d2bbdc50 static/irclogs.css --- a/static/irclogs.css Mon Feb 09 04:39:24 2009 +0200 +++ b/static/irclogs.css Mon Feb 09 05:44:29 2009 +0200 @@ -130,7 +130,82 @@ */ /* Calendar */ +table.calendar { + +} + +table.calendar th { + background-color: #c8c8c8; +} + +table.calendar td { + margin: 1px; + + + text-align: center; +} + +table.calendar tr.month-header th { + +} + +table.calendar tr.month-header a { + display: block; + + color: inherit; + text-decoration: none; + + padding: 3px; + padding-left: 8px; + padding-right: 8px; + + font-size: x-large; +} + +table.calendar tr.month-header a:hover { + background-color: #b5b5b5; +} + +table.calendar tr.month-header span { + margin-top: 5px; +} + +table.calendar a.prev-month { + float: left; +} + +table.calendar a.next-month { + float: right; +} + +table.calendar tr.week-header th { + width: 14% +} + +table.calendar td { + padding: 2px; +} + +table.calendar td a { + display: block; + padding: 2px; + + background-color: #e0e0e0; + text-decoration: none; + + color: inherit; +} + +table.calendar td.empty { + color: #d0d0d0; +} + +table.calendar td a:hover { + background-color: #d0d0d0; +} + table.calendar td#today { font-weight: bold; } + diff -r b65a95eb9f6b -r 5667d2bbdc50 templates/channel.tmpl --- a/templates/channel.tmpl Mon Feb 09 04:39:24 2009 +0200 +++ b/templates/channel.tmpl Mon Feb 09 05:44:29 2009 +0200 @@ -30,7 +30,7 @@ -
  • Browse by Date
  • +
  • Browse by Date
  • diff -r b65a95eb9f6b -r 5667d2bbdc50 templates/channel_calendar.tmpl --- a/templates/channel_calendar.tmpl Mon Feb 09 04:39:24 2009 +0200 +++ b/templates/channel_calendar.tmpl Mon Feb 09 05:44:29 2009 +0200 @@ -3,11 +3,15 @@ <%def name="month_table(cal, month, dates)"> ## table header - month name - - + + ## month header - weekday names - + % for weekday in cal.iterweekdays() : % endfor @@ -23,12 +27,8 @@ % else : ## build date <% date = h.build_date(month, day) %> - ## is it today? - % if day and h.is_today(date) : -
    ${h.fmt_month(month)}
    + » + « + ${h.fmt_month(month)} +
    ${h.fmt_weekday(weekday)}\ - % else : - \ - % endif + ## render cell + \ ## link to logs for this day? % if date in dates : ${day}\