--- a/helpers.py Wed Feb 11 22:56:43 2009 +0200
+++ b/helpers.py Wed Feb 11 23:22:13 2009 +0200
@@ -2,7 +2,8 @@
Some additional helpers
"""
-import datetime, calendar
+import datetime
+import calendar as _calendar
import qmsk.web.helpers
@@ -17,7 +18,10 @@
set = set
# reference to calendar instance
- calendar = calendar.Calendar()
+ calendar = _calendar.Calendar()
+
+ # list of (month_num, month_name) for the months in the year
+ months = list(enumerate(_calendar.month_name))[1:]
def tz_name (self, tz) :
"""
@@ -38,7 +42,7 @@
Formats an abbreviated weekday name
"""
- return calendar.day_abbr[wday]
+ return _calendar.day_abbr[wday]
def build_date (self, month, mday) :
"""
@@ -198,15 +202,17 @@
return max(values)
- def select_options (self, key_values, selected_key) :
+ def select_options (self, key_values, selected_key=None) :
"""
- Render a series of <option> tags for <select>
+ Render a series of <option> tags for <select>.
+
+ The given key_values is an iterable of (key, value) pairs, key may be None if it's the same as value.
"""
return '\n'.join(
'\t<option%s%s>%s</option>' % (
- ' value="%s"' % key if key != value else '',
- ' selected="selected"' if key == selected_key else '',
+ ' value="%s"' % key if key is not None else '',
+ ' selected="selected"' if (key if key is not None else value) == selected_key else '',
value
) for key, value in key_values
)
--- a/static/irclogs.css Wed Feb 11 22:56:43 2009 +0200
+++ b/static/irclogs.css Wed Feb 11 23:22:13 2009 +0200
@@ -152,18 +152,14 @@
background-color: #c8c8c8;
}
-table.calendar td {
- margin: 1px;
-
-
- text-align: center;
-}
-
+/* month header */
table.calendar tr.month-header th {
}
-table.calendar tr.month-header a {
+table.calendar tr.month-header a,
+table.calendar span.prev-month,
+table.calendar span.next-month {
display: block;
color: inherit;
@@ -176,6 +172,12 @@
font-size: x-large;
}
+table.calendar th.this-month a.next-month,
+table.calendar span.prev-month,
+table.calendar span.next-month {
+ color: #d5d5d5;
+}
+
table.calendar tr.month-header a:hover {
background-color: #b5b5b5;
}
@@ -184,25 +186,24 @@
margin-top: 5px;
}
-table.calendar a.prev-month {
+table.calendar .prev-month {
float: left;
}
-table.calendar a.next-month {
+table.calendar .next-month {
float: right;
}
-table.calendar th.this-month a.next-month {
- color: #d5d5d5;
-}
-
-
+/* week header */
table.calendar tr.week-header th {
width: 14%
}
+/* cells */
table.calendar td {
padding: 2px;
+ margin: 1px;
+ text-align: center;
}
table.calendar td a {
@@ -214,7 +215,7 @@
color: inherit;
}
-
+
table.calendar td.empty {
color: #d0d0d0;
}
--- a/templates/channel_calendar.tmpl Wed Feb 11 22:56:43 2009 +0200
+++ b/templates/channel_calendar.tmpl Wed Feb 11 23:22:13 2009 +0200
@@ -1,6 +1,6 @@
<%inherit file="channel.tmpl" />
-<%def name="month_table(month)">
+<%def name="month_table(month, is_center=True)">
## the set of available days
<% log_dates = h.set(channel.source.get_month_days(month)) %>
## the calendar table
@@ -8,9 +8,22 @@
## table header - month name
<tr class="month-header">
<th colspan="7"${' class="this-month"' if h.is_this_month(month) else ''}>
- <a href="${urls.channel_calendar.build(req, channel=channel, year=h.next_month(month).year, month=h.next_month(month).month)}" class="next-month">»</a>
- <a href="${urls.channel_calendar.build(req, channel=channel, year=h.prev_month(month).year, month=h.prev_month(month).month)}" class="prev-month">«</a>
+ % if is_center :
+ <a href="${urls.channel_calendar.build(req, channel=channel, year=h.next_month(month).year, month=h.next_month(month).month)}" class="next-month" title="Next month">»</a>
+ <a href="${urls.channel_calendar.build(req, channel=channel, year=h.prev_month(month).year, month=h.prev_month(month).month)}" class="prev-month" title="Previous month">«</a>
+
+ <form action="${urls.channel_calendar.build(req, channel=channel)}" method="GET">
+ <select name="month">
+ ${h.select_options(((month_num, name) for month_num, name in h.months), month.month)}
+ </select>
+ <select name="year">
+ ${h.select_options(((None, 2006), (None, 2007), (None, 2008), (None, 2009)), month.year)}
+ </select>
+ <input type="submit" value="Go »" />
+ </form>
+ % else :
<span id="month-name">${h.fmt_month(month)}</span>
+ % endif
</th>
</tr>
## month header - weekday names
@@ -47,7 +60,7 @@
</%def>
## three months
-${month_table(h.prev_month(month))}
-${month_table(month )}
-${month_table(h.next_month(month))}
+${month_table(h.prev_month(month), is_center=False )}
+${month_table(month, is_center=True )}
+${month_table(h.next_month(month), is_center=False )}
--- a/templates/preferences.tmpl Wed Feb 11 22:56:43 2009 +0200
+++ b/templates/preferences.tmpl Wed Feb 11 23:22:13 2009 +0200
@@ -9,7 +9,7 @@
<p>
<label for="timezone">Timezone:</label>
<select name="timezone">
- ${h.select_options(((tz_name, tz_name) for tz_name in timezones), prefs['timezone'].zone)}
+ ${h.select_options(((None, tz_name) for tz_name in timezones), prefs['timezone'].zone)}
</select>
<span class="example">(${h.tz_name(prefs['timezone'])})</span>
</p>