やさしいカレンダーその3

以下が、その1、その2でテストしたカレンダーポートレットのコードです。まだ途中ですが、今日にあたる部分(スタイルが適用されているとオレンジの枠になるところ)に「Today 日」というABBRタグをつけるようにしてあります。これにより、スタイルを適用しなくても今日の位置がわかるようになります。

<html xmlns:tal="http://xml.zope.org/namespaces/tal"
      xmlns:metal="http://xml.zope.org/namespaces/metal"
      i18n:domain="plone">
<body>
<div metal:define-macro="portlet"
       tal:omit-tag=""
       tal:define="DateTime python:modules['DateTime'].DateTime;
                   current python:DateTime();
                   current_day current/day;
                   yearmonth here/getYearAndMonthToDisplay;
                   nextYearMax python: current+365;
                   prevYearMin python: current-365;
                   year python:yearmonth[0];
                   month python:yearmonth[1];
                   prevMonthTime python:here.getPreviousMonth(month, year);
                   nextMonthTime python:here.getNextMonth(month, year);
                   weeks python:here.portal_calendar.getEventsForCalendar(month, year);
                   anchor_url request/anchor_url | here_url;
                   query_string python:request.get('orig_query', None);
                   query_string python: (query_string is None and request.get('QUERY_STRING', None)) or query_string;
                   url_quote python:modules['Products.PythonScripts.standard'].url_quote;
                   anchor_method request/anchor_method | template/getId;
                   translation_service nocall:here/translation_service;
                   day_msgid nocall:translation_service/day_msgid;
                   weekday_english nocall:translation_service/weekday_english;
                   utranslate nocall:here/utranslate;
                   toLocalizedTime nocall:here/toLocalizedTime;
                   getEventString nocall:here/getEventString;">
      <!-- The calendar, rendered as a table -->
    <table class="ploneCalendar" id="thePloneCalendar" summary="Calendar" i18n:attributes="summary summary_calendar;">
          <thead>
              <tr>
                  <th colspan="7">
                      <span i18n:translate="" tal:omit-tag="">
                          <span i18n:name="monthname"
                                tal:define="month_english python:translation_service.month_english(month);"
                                tal:attributes="id string:calendar-month-$month_english"
                                tal:content="python: utranslate(translation_service.month_msgid(month), default=month_english)"
                                tal:omit-tag=""
                                id="calendar-month-month">monthname</span>
                          <span i18n:name="year"
                                tal:content="string:$year"
                                tal:attributes="id string:calendar-year-$year;"
                                tal:omit-tag=""
                                id="calendar-year">year</span>
                      </span>
                  </th>
              </tr>
              <tr tal:define="weekdaynumbers here/portal_calendar/getDayNumbers" class="weekdays">
                  <tal:data tal:repeat="daynumber weekdaynumbers">
                      <th tal:define="weekday_english python:weekday_english(daynumber,format='a');"
                          tal:attributes="abbr python: utranslate(day_msgid(daynumber, format='S'), default=weekday_english)"
                          tal:content="python: utranslate(day_msgid(daynumber, format='s'), default=weekday_english)"
                          >
                      </th>
                  </tal:data>
              </tr>
          </thead>
        <tal:comment replace="nothing"><!--
          Sorry for the obtuse formatting below (the stray end-of-tag markers), but until
          tal:block doesn't render an entire line of blank space when used, this is the only way.
          --></tal:comment>
          <tbody>
              <tr tal:repeat="week weeks"
              ><tal:block repeat="day week"
              ><tal:block define="int_daynumber python: int(day['day']);
                                  day_event day/event;
                                  is_today python: current_day==int_daynumber and current.month()==month and current.year()==year">
                 <td class="event" tal:condition="day_event"
                        tal:attributes="class python:is_today and 'todayevent' or 'event'"
                     ><tal:data tal:define="cur_date python:DateTime(year,month,int_daynumber);
                                            begin python:url_quote((cur_date.latestTime()).ISO());
                                            end python:url_quote(cur_date.earliestTime().ISO());"
                                tal:omit-tag=""
                       ><a href=""
                           tal:attributes="href string:${portal_url}/search?review_state=publishedamp;start.query:record:list:date=${begin}amp;start.range:record=maxamp;end.query:record:list:date=${end}amp;end.range:record=min;
                                           title python:'\n'.join([toLocalizedTime(cur_date)]+[getEventString(e) for e in day['eventslist'] ]);"
                           tal:content="python:int_daynumber or default">
                        31
                        </a
                     ></tal:data>
                  </td
                  ><tal:notdayevent tal:condition="not: day_event"
                 ><td tal:attributes="class python:is_today and 'todaynoevent' or None"

                  ><abbr Title="Today"
                         tal:define="int_daynumber_abbr python:'Today '+str(int_daynumber)"
                         tal:attributes="Title int_daynumber_abbr" tal:condition="is_today" tal:content="python:int_daynumber or default"></abbr>
                   <span tal:omit-tag="" tal:condition="python:not is_today" tal:content="python:int_daynumber or default" /></td
                 ></tal:notdayevent
              ></tal:block
              ></tal:block>
              </tr>
              <tr>
                  <th id="calendar-previous"  colspan="3" >
                      <a href="#" rel="nofollow"
                         title="Previous month"
                         tal:attributes="href python:'%s/%s?%samp;month:int=%damp;year:int=%damp;orig_query=%s' % (anchor_url, anchor_method, query_string, prevMonthTime.month(),prevMonthTime.year(),url_quote(query_string))"
                         tal:condition="python: yearmonth > (prevYearMin.year(), prevYearMin.month())"
                         i18n:attributes="title title_previous_month;"
                         ><abbr title="Previous month" i18n:attributes="title title_previous_month;">laquo; <span tal:omit-tag="" i18n:translate="title_previous_month">previous month</span></abbr></a>
                  </th >
                  <th></th >
                  <th id="calendar-next"  colspan="3" >
                      <a href="#" rel="nofollow"
                         title="Next month"
                         tal:attributes="href python:'%s/%s?%samp;month:int=%damp;year:int=%damp;orig_query=%s' % (anchor_url, anchor_method, query_string, nextMonthTime.month(),nextMonthTime.year(),url_quote(query_string))"
                         tal:condition="python: yearmonth lt; (nextYearMax.year(), nextYearMax.month())"
                         i18n:attributes="title title_next_month;"
                         ><abbr title="Next month" i18n:attributes="title title_next_month;"><span tal:omit-tag="" i18n:translate="title_next_month">next month</span> raquo;</abbr></a>
                  </th >
              </tr>
          </tbody>
      </table>
</div>
</body>
</html>