templates/channel_calendar.tmpl
author Tero Marttila <terom@fixme.fi>
Wed, 11 Feb 2009 22:56:43 +0200
changeset 112 090192b64d7e
parent 85 0521cf830eb9
child 113 9fc0eb751b6a
permissions -rw-r--r--
add three calendars to the channel_calendar view
<%inherit file="channel.tmpl" />

<%def name="month_table(month)">
## the set of available days
<% log_dates = h.set(channel.source.get_month_days(month)) %>
## the calendar table
<table class="calendar">
## 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">&raquo;</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">&laquo;</a>
            <span id="month-name">${h.fmt_month(month)}</span>
        </th>
    </tr>
## month header - weekday names    
    <tr class="week-header">
    % for weekday in h.calendar.iterweekdays() :
        <th>${h.fmt_weekday(weekday)}</th>
    % endfor
    </tr>
## iterate over the weeks
% for week in h.calendar.monthdays2calendar(month.year, month.month) :
    <tr>
    ## iterate over the week's days
    % for day, weekday in week :
        ## is it an empty cell?
        % if not day :
        <td>&nbsp;</td>
        % else :
        ## build date
        <% date = h.build_date(month, day) %>\
        ## render cell
        <td${' id="today"' if h.is_today(date) else ''}${' class="empty"' if date not in log_dates else ''}>\
        ## link to logs for this day?
        % if date in log_dates :
<a href="${urls.channel_date.build(req, channel=channel, date=date)}">${day}</a>\
        % else :
${day}\
        % endif
</td>
    % endif
    % endfor
    </tr>
% endfor
</table>
</%def>

## three months
${month_table(h.prev_month(month))}
${month_table(month              )}
${month_table(h.next_month(month))}