templates/channel_calendar.tmpl
author Tero Marttila <terom@fixme.fi>
Mon, 16 Feb 2009 00:54:25 +0200
changeset 132 0e857c4a67de
parent 115 751e3fcd11d2
permissions -rw-r--r--
cache version across calls to version_mercurial, so as to avoid opening the repo every time
54
b65a95eb9f6b implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     1
<%inherit file="channel.tmpl" />
b65a95eb9f6b implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     2
113
9fc0eb751b6a add <form> for month/year to calendar header
Tero Marttila <terom@fixme.fi>
parents: 112
diff changeset
     3
<%def name="month_table(month, is_center=True)">
112
090192b64d7e add three calendars to the channel_calendar view
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
     4
## the set of available days
090192b64d7e add three calendars to the channel_calendar view
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
     5
<% log_dates = h.set(channel.source.get_month_days(month)) %>
090192b64d7e add three calendars to the channel_calendar view
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
     6
## the calendar table
54
b65a95eb9f6b implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     7
<table class="calendar">
b65a95eb9f6b implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     8
## table header - month name
55
5667d2bbdc50 improve calendar further
Tero Marttila <terom@fixme.fi>
parents: 54
diff changeset
     9
    <tr class="month-header">
58
ce028d356e1f special-case current month in calendar
Tero Marttila <terom@fixme.fi>
parents: 55
diff changeset
    10
        <th colspan="7"${' class="this-month"' if h.is_this_month(month) else ''}>
113
9fc0eb751b6a add <form> for month/year to calendar header
Tero Marttila <terom@fixme.fi>
parents: 112
diff changeset
    11
        % if is_center :
9fc0eb751b6a add <form> for month/year to calendar header
Tero Marttila <terom@fixme.fi>
parents: 112
diff changeset
    12
            <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">&raquo;</a>
9fc0eb751b6a add <form> for month/year to calendar header
Tero Marttila <terom@fixme.fi>
parents: 112
diff changeset
    13
            <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">&laquo;</a>
9fc0eb751b6a add <form> for month/year to calendar header
Tero Marttila <terom@fixme.fi>
parents: 112
diff changeset
    14
            
9fc0eb751b6a add <form> for month/year to calendar header
Tero Marttila <terom@fixme.fi>
parents: 112
diff changeset
    15
            <form action="${urls.channel_calendar.build(req, channel=channel)}" method="GET">
9fc0eb751b6a add <form> for month/year to calendar header
Tero Marttila <terom@fixme.fi>
parents: 112
diff changeset
    16
                <select name="month">
9fc0eb751b6a add <form> for month/year to calendar header
Tero Marttila <terom@fixme.fi>
parents: 112
diff changeset
    17
                    ${h.select_options(((month_num, name) for month_num, name in h.months), month.month)}
9fc0eb751b6a add <form> for month/year to calendar header
Tero Marttila <terom@fixme.fi>
parents: 112
diff changeset
    18
                </select>
9fc0eb751b6a add <form> for month/year to calendar header
Tero Marttila <terom@fixme.fi>
parents: 112
diff changeset
    19
                <select name="year">
9fc0eb751b6a add <form> for month/year to calendar header
Tero Marttila <terom@fixme.fi>
parents: 112
diff changeset
    20
                    ${h.select_options(((None, 2006), (None, 2007), (None, 2008), (None, 2009)), month.year)}
9fc0eb751b6a add <form> for month/year to calendar header
Tero Marttila <terom@fixme.fi>
parents: 112
diff changeset
    21
                </select>
9fc0eb751b6a add <form> for month/year to calendar header
Tero Marttila <terom@fixme.fi>
parents: 112
diff changeset
    22
                <input type="submit" value="Go &raquo;" />
9fc0eb751b6a add <form> for month/year to calendar header
Tero Marttila <terom@fixme.fi>
parents: 112
diff changeset
    23
            </form>
9fc0eb751b6a add <form> for month/year to calendar header
Tero Marttila <terom@fixme.fi>
parents: 112
diff changeset
    24
        % else :
55
5667d2bbdc50 improve calendar further
Tero Marttila <terom@fixme.fi>
parents: 54
diff changeset
    25
            <span id="month-name">${h.fmt_month(month)}</span>
113
9fc0eb751b6a add <form> for month/year to calendar header
Tero Marttila <terom@fixme.fi>
parents: 112
diff changeset
    26
        % endif
55
5667d2bbdc50 improve calendar further
Tero Marttila <terom@fixme.fi>
parents: 54
diff changeset
    27
        </th>
54
b65a95eb9f6b implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    28
    </tr>
b65a95eb9f6b implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    29
## month header - weekday names    
55
5667d2bbdc50 improve calendar further
Tero Marttila <terom@fixme.fi>
parents: 54
diff changeset
    30
    <tr class="week-header">
112
090192b64d7e add three calendars to the channel_calendar view
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    31
    % for weekday in h.calendar.iterweekdays() :
54
b65a95eb9f6b implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    32
        <th>${h.fmt_weekday(weekday)}</th>
b65a95eb9f6b implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    33
    % endfor
b65a95eb9f6b implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    34
    </tr>
b65a95eb9f6b implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    35
## iterate over the weeks
112
090192b64d7e add three calendars to the channel_calendar view
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    36
% for week in h.calendar.monthdays2calendar(month.year, month.month) :
54
b65a95eb9f6b implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    37
    <tr>
b65a95eb9f6b implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    38
    ## iterate over the week's days
b65a95eb9f6b implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    39
    % for day, weekday in week :
b65a95eb9f6b implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    40
        ## is it an empty cell?
b65a95eb9f6b implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    41
        % if not day :
b65a95eb9f6b implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    42
        <td>&nbsp;</td>
b65a95eb9f6b implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    43
        % else :
b65a95eb9f6b implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    44
        ## build date
85
0521cf830eb9 misc. template clean (hide RSS link, remove extra whitespace from calendar source
Tero Marttila <terom@fixme.fi>
parents: 58
diff changeset
    45
        <% date = h.build_date(month, day) %>\
55
5667d2bbdc50 improve calendar further
Tero Marttila <terom@fixme.fi>
parents: 54
diff changeset
    46
        ## render cell
115
751e3fcd11d2 have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents: 114
diff changeset
    47
        <td${' id="today"' if h.is_today(date) else ''}${' class="empty"' if date.date() not in log_dates else ''}>\
54
b65a95eb9f6b implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    48
        ## link to logs for this day?
115
751e3fcd11d2 have dates in URLs be partial timestamps - fix datetime-timezone-comparison mess
Tero Marttila <terom@fixme.fi>
parents: 114
diff changeset
    49
        % if date.date() in log_dates :
85
0521cf830eb9 misc. template clean (hide RSS link, remove extra whitespace from calendar source
Tero Marttila <terom@fixme.fi>
parents: 58
diff changeset
    50
<a href="${urls.channel_date.build(req, channel=channel, date=date)}">${day}</a>\
54
b65a95eb9f6b implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    51
        % else :
85
0521cf830eb9 misc. template clean (hide RSS link, remove extra whitespace from calendar source
Tero Marttila <terom@fixme.fi>
parents: 58
diff changeset
    52
${day}\
54
b65a95eb9f6b implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    53
        % endif
b65a95eb9f6b implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    54
</td>
b65a95eb9f6b implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    55
    % endif
b65a95eb9f6b implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    56
    % endfor
b65a95eb9f6b implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    57
    </tr>
b65a95eb9f6b implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    58
% endfor
b65a95eb9f6b implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    59
</table>
b65a95eb9f6b implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    60
</%def>
b65a95eb9f6b implement browse-by-date to show a nice calendar
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    61
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: 113
diff changeset
    62
<div id="title">${channel.title} :: Calendar for ${h.fmt_month(month)}</div>
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: 113
diff changeset
    63
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: 113
diff changeset
    64
<div class="calendar-list">
112
090192b64d7e add three calendars to the channel_calendar view
Tero Marttila <terom@fixme.fi>
parents: 85
diff changeset
    65
## three months
113
9fc0eb751b6a add <form> for month/year to calendar header
Tero Marttila <terom@fixme.fi>
parents: 112
diff changeset
    66
${month_table(h.prev_month(month), is_center=False  )}
9fc0eb751b6a add <form> for month/year to calendar header
Tero Marttila <terom@fixme.fi>
parents: 112
diff changeset
    67
${month_table(month,               is_center=True   )}
9fc0eb751b6a add <form> for month/year to calendar header
Tero Marttila <terom@fixme.fi>
parents: 112
diff changeset
    68
${month_table(h.next_month(month), is_center=False  )}
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: 113
diff changeset
    69
</div>