[wiki/macro/EventCalendar] On passe à la version 0.99a
Ignore-this: 2558d3e32ca5684ef5852238874aa3c7 darcs-hash:20120426100341-bd074-fd45300a9cebc489f6fddeb416e065f69489f7ce.gz
This commit is contained in:
parent
1b99a84115
commit
88d0440100
1 changed files with 1045 additions and 917 deletions
|
@ -1,6 +1,22 @@
|
||||||
# -*- coding: iso-8859-1 -*-
|
|
||||||
"""
|
"""
|
||||||
EventCalendar.py Version 0.98 May 12, 2006
|
EventCalendar.py Version 0.99a July 22, 2009
|
||||||
|
|
||||||
|
* Base 0.99 version
|
||||||
|
* Add ErikMartin's Defaults patch (defaults-099-01)
|
||||||
|
* Add AlanSnelson 2008-11-05 patch for Moin 1.8.0 caching methods
|
||||||
|
* Add tidyup patch for 1.6.1 (EventCalendar-099.py.patch) NeoCoin
|
||||||
|
* Add Weeknumber patch from KlausMariaPfeiffer 2008-01-25
|
||||||
|
* Add label colour patch DavidOCallahan 2006-07-18 {see here for names: http://www.w3schools.com/html/html_colornames.asp}
|
||||||
|
* Add pagelinks-099-01.patch for OrphanedPages maintenance.
|
||||||
|
* Add showpagelist, to append list of contributing pages pagelist-099-01.patch (except: default now off not on)
|
||||||
|
* Add event sorting patch RuthIvimey 2007-05-17
|
||||||
|
* Fix url_prefix usage DaveGore 2008-04-04
|
||||||
|
Not included:
|
||||||
|
ErikMartin's Label Priority patch - too big a patch for this wrapup release.
|
||||||
|
RuthIvimey's page label colour patch - not sure of side-effects
|
||||||
|
HyungyongKim's unicode patch: described as temporary
|
||||||
|
|
||||||
|
EventCalendar.py Version 0.99 May 22, 2006
|
||||||
|
|
||||||
This macro gives a list of the events recorded at the sub-pages in the form of various views:
|
This macro gives a list of the events recorded at the sub-pages in the form of various views:
|
||||||
monthly, weekly, daily, simple-month, list, and upcoming.
|
monthly, weekly, daily, simple-month, list, and upcoming.
|
||||||
|
@ -28,6 +44,7 @@
|
||||||
* numcal: # of calendar. default: 1
|
* numcal: # of calendar. default: 1
|
||||||
* showlastweekday: shows the event at the last weekday if the recurred weekday is not available. (1: enalbed, 0: disabled). default: 0
|
* showlastweekday: shows the event at the last weekday if the recurred weekday is not available. (1: enalbed, 0: disabled). default: 0
|
||||||
* showerror: shows error messages below the calendar if event data format is invalid. (1: enalbed, 0: disabled). default: 1
|
* showerror: shows error messages below the calendar if event data format is invalid. (1: enalbed, 0: disabled). default: 1
|
||||||
|
* showpagelist: shows a list of the pages used for event data below the calendar. (1: enalbed, 0: disabled). default: 0
|
||||||
* showweeknumber: shows the week number of the year (1: enalbed, 0: disabled). default: 0
|
* showweeknumber: shows the week number of the year (1: enalbed, 0: disabled). default: 0
|
||||||
|
|
||||||
|
|
||||||
|
@ -157,7 +174,6 @@ CategoryEventCalendar
|
||||||
|
|
||||||
from MoinMoin import wikiutil, config, search, caching
|
from MoinMoin import wikiutil, config, search, caching
|
||||||
from MoinMoin.Page import Page
|
from MoinMoin.Page import Page
|
||||||
from MoinMoin.parser import text_moin_wiki as wiki
|
|
||||||
import re, calendar, time, datetime
|
import re, calendar, time, datetime
|
||||||
import codecs, os, urllib, sha
|
import codecs, os, urllib, sha
|
||||||
|
|
||||||
|
@ -174,7 +190,7 @@ PICKLE_PROTOCOL = pickle.HIGHEST_PROTOCOL
|
||||||
# the first day of the week. Only SUNDAY or MONDAY (case sensitive) are
|
# the first day of the week. Only SUNDAY or MONDAY (case sensitive) are
|
||||||
# valid here. All other values will not make good calendars.
|
# valid here. All other values will not make good calendars.
|
||||||
# XXX change here ----------------vvvvvv
|
# XXX change here ----------------vvvvvv
|
||||||
calendar.setfirstweekday(calendar.SUNDAY)
|
calendar.setfirstweekday(calendar.MONDAY)
|
||||||
|
|
||||||
|
|
||||||
class Globs:
|
class Globs:
|
||||||
|
@ -217,6 +233,7 @@ class Params:
|
||||||
numcal = 1
|
numcal = 1
|
||||||
showlastweekday = 0
|
showlastweekday = 0
|
||||||
showerror = 1
|
showerror = 1
|
||||||
|
showpagelist = 0
|
||||||
showweeknumber = 0
|
showweeknumber = 0
|
||||||
debug = 0
|
debug = 0
|
||||||
|
|
||||||
|
@ -250,7 +267,7 @@ def execute(macro, args):
|
||||||
if args:
|
if args:
|
||||||
args=request.getText(args)
|
args=request.getText(args)
|
||||||
|
|
||||||
for item in macro.request.form.items():
|
for item in macro.form.items():
|
||||||
if not form_vals.has_key(item[0]):
|
if not form_vals.has_key(item[0]):
|
||||||
try:
|
try:
|
||||||
form_vals[item[0]]=item[1][0]
|
form_vals[item[0]]=item[1][0]
|
||||||
|
@ -301,6 +318,8 @@ def execute(macro, args):
|
||||||
html.append( html_result )
|
html.append( html_result )
|
||||||
html.append( showmenubar() )
|
html.append( showmenubar() )
|
||||||
|
|
||||||
|
html.append( showpagelist() )
|
||||||
|
|
||||||
if Params.showerror and Globs.errormsg:
|
if Params.showerror and Globs.errormsg:
|
||||||
html.append(u'<p><i><font size="2" color="#aa0000"><ol>%s</ol></font></i>' % Globs.errormsg)
|
html.append(u'<p><i><font size="2" color="#aa0000"><ol>%s</ol></font></i>' % Globs.errormsg)
|
||||||
|
|
||||||
|
@ -329,6 +348,7 @@ def getparams(args):
|
||||||
# category name:
|
# category name:
|
||||||
# default: 'CategoryEventCalendar'
|
# default: 'CategoryEventCalendar'
|
||||||
Params.category = params.get('category', Globs.defaultcategory)
|
Params.category = params.get('category', Globs.defaultcategory)
|
||||||
|
|
||||||
# menu bar: shows menubar or not (1: show, 0: no menubar)
|
# menu bar: shows menubar or not (1: show, 0: no menubar)
|
||||||
# default: 1
|
# default: 1
|
||||||
try:
|
try:
|
||||||
|
@ -411,6 +431,13 @@ def getparams(args):
|
||||||
except (TypeError, ValueError):
|
except (TypeError, ValueError):
|
||||||
Params.showweeknumber = 0
|
Params.showweeknumber = 0
|
||||||
|
|
||||||
|
# show definition table
|
||||||
|
# default: 1
|
||||||
|
try:
|
||||||
|
Params.showpagelist = int(params.get('showpagelist', '0'))
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
Params.showpagelist = 1
|
||||||
|
|
||||||
# default bgcolor
|
# default bgcolor
|
||||||
Params.bgcolor = '#ddffdd'
|
Params.bgcolor = '#ddffdd'
|
||||||
|
|
||||||
|
@ -434,15 +461,15 @@ def setglobalvalues(macro):
|
||||||
Globs.pagepath = formatter.page.getPagePath()
|
Globs.pagepath = formatter.page.getPagePath()
|
||||||
|
|
||||||
# european / US differences
|
# european / US differences
|
||||||
months = (u'Janvier',u'Fevrier',u'Mars',u'Avril',u'Mai',u'Juin',u'Juillet',u'Aout',u'Septembre',u'Octobre',u'Novembre',u'Decembre')
|
months = ('January','February','March','April','May','June','July','August','September','October','November','December')
|
||||||
|
|
||||||
# Set things up for Monday or Sunday as the first day of the week
|
# Set things up for Monday or Sunday as the first day of the week
|
||||||
if calendar.firstweekday() == calendar.MONDAY:
|
if calendar.firstweekday() == calendar.MONDAY:
|
||||||
wkend = 6
|
wkend = 6
|
||||||
wkdays = ('Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam', 'Dim')
|
wkdays = ('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun')
|
||||||
elif calendar.firstweekday() == calendar.SUNDAY:
|
elif calendar.firstweekday() == calendar.SUNDAY:
|
||||||
wkend = 0
|
wkend = 0
|
||||||
wkdays = ('Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam')
|
wkdays = ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat')
|
||||||
|
|
||||||
Globs.months = months
|
Globs.months = months
|
||||||
Globs.wkdays = wkdays
|
Globs.wkdays = wkdays
|
||||||
|
@ -550,10 +577,10 @@ def getquerystring(req_fields):
|
||||||
if not tmp_form_vals.has_key('prevcalaction'):
|
if not tmp_form_vals.has_key('prevcalaction'):
|
||||||
m_query.append(u'%s=%s' % ('prevcalaction', tmp_form_vals['calaction']) )
|
m_query.append(u'%s=%s' % ('prevcalaction', tmp_form_vals['calaction']) )
|
||||||
|
|
||||||
m_query = u'&'.join(m_query)
|
m_query = u'&'.join(m_query)
|
||||||
|
|
||||||
if m_query:
|
if m_query:
|
||||||
m_query = '&%s' % m_query
|
m_query = '&%s' % m_query
|
||||||
|
|
||||||
return m_query
|
return m_query
|
||||||
|
|
||||||
|
@ -581,25 +608,25 @@ def showmenubar():
|
||||||
|
|
||||||
# Go Today
|
# Go Today
|
||||||
year, month, day = gettodaydate()
|
year, month, day = gettodaydate()
|
||||||
mnu_curmonthcal = u'<a href="%s?calaction=%s&caldate=%d%02d%02d%s" title="Aujourd\'hui">[Aujourd\'hui]</a>' % (page_url, cal_action, year, month, day, getquerystring(['numcal']))
|
mnu_curmonthcal = u'<a href="%s?calaction=%s&caldate=%d%02d%02d%s" title="Go Today">[Today]</a>' % (page_url, cal_action, year, month, day, getquerystring(['numcal']))
|
||||||
|
|
||||||
# List View
|
# List View
|
||||||
mnu_listview = u'<a href="%s?calaction=list%s" title="Liste de tous les évènements">[Liste]</a>' % (page_url, getquerystring(['caldate', 'numcal']))
|
mnu_listview = u'<a href="%s?calaction=list%s" title="List of all events">[List]</a>' % (page_url, getquerystring(['caldate', 'numcal']))
|
||||||
|
|
||||||
# Monthly View
|
# Monthly View
|
||||||
mnu_monthview = u'<a href="%s?calaction=monthly%s" title="Vue du mois">[Mois]</a>' % (page_url, getquerystring(['caldate', 'numcal']) )
|
mnu_monthview = u'<a href="%s?calaction=monthly%s" title="Monthly view">[Monthly]</a>' % (page_url, getquerystring(['caldate', 'numcal']) )
|
||||||
|
|
||||||
# Simple Calendar View
|
# Simple Calendar View
|
||||||
mnu_simpleview = u'<a href="%s?calaction=simple%s" title="Simple calendrier">[Simple]</a>' % (page_url, getquerystring(['caldate', 'numcal']) )
|
mnu_simpleview = u'<a href="%s?calaction=simple%s" title="Simple calendar view">[Simple]</a>' % (page_url, getquerystring(['caldate', 'numcal']) )
|
||||||
|
|
||||||
# Upcoming Event List
|
# Upcoming Event List
|
||||||
mnu_upcomingview = u'<a href="%s?calaction=upcoming%s" title="Évènements à venir">[À venir]</a>' % (page_url, getquerystring(['caldate', 'numcal']) )
|
mnu_upcomingview = u'<a href="%s?calaction=upcoming%s" title="Upcoming event list">[Upcoming]</a>' % (page_url, getquerystring(['caldate', 'numcal']) )
|
||||||
|
|
||||||
# Daily View
|
# Daily View
|
||||||
mnu_dayview = u'<a href="%s?calaction=daily%s" title="Vue du jour">[Jour]</a>' % (page_url, getquerystring(['caldate', 'numcal']) )
|
mnu_dayview = u'<a href="%s?calaction=daily%s" title="Daily view">[Daily]</a>' % (page_url, getquerystring(['caldate', 'numcal']) )
|
||||||
|
|
||||||
# Weekly View
|
# Weekly View
|
||||||
mnu_weekview = u'<a href="%s?calaction=weekly%s" title="Vue de la semaine" >[Semaine]</a>' % (page_url, getquerystring(['caldate', 'numcal']) )
|
mnu_weekview = u'<a href="%s?calaction=weekly%s" title="Weekly view">[Weekly]</a>' % (page_url, getquerystring(['caldate', 'numcal']) )
|
||||||
|
|
||||||
html = [
|
html = [
|
||||||
u'\r\n',
|
u'\r\n',
|
||||||
|
@ -665,6 +692,42 @@ def showmenubar():
|
||||||
|
|
||||||
return html
|
return html
|
||||||
|
|
||||||
|
def show_page_list():
|
||||||
|
html = ""
|
||||||
|
request = Globs.request
|
||||||
|
formatter = Globs.formatter
|
||||||
|
|
||||||
|
if Params.showpagelist:
|
||||||
|
source_pages = []
|
||||||
|
|
||||||
|
events, cal_events, labels = loadEvents()
|
||||||
|
|
||||||
|
for eid in events.keys():
|
||||||
|
event = events[eid]
|
||||||
|
refer = event['refer']
|
||||||
|
refer_url = '%s/%s' % (request.getScriptname(), wikiutil.quoteWikinameURL(refer))
|
||||||
|
targetlink = '<a href="%s">%s</a>' % ( refer_url, wikiutil.escape(refer))
|
||||||
|
source_pages.append( targetlink )
|
||||||
|
|
||||||
|
from sets import Set
|
||||||
|
page_set = Set(source_pages)
|
||||||
|
|
||||||
|
html = "\n"
|
||||||
|
html += formatter.paragraph(1)
|
||||||
|
html += "Constructed from events defined on these pages"
|
||||||
|
html += formatter.paragraph(0)
|
||||||
|
html += "\n"
|
||||||
|
html += formatter.bullet_list(1)
|
||||||
|
html += "\n"
|
||||||
|
for p in page_set:
|
||||||
|
html += formatter.listitem(1)
|
||||||
|
html += p
|
||||||
|
html += formatter.listitem(0)
|
||||||
|
html += "\n"
|
||||||
|
html += formatter.bullet_list(0)
|
||||||
|
html += "\n"
|
||||||
|
|
||||||
|
return html
|
||||||
|
|
||||||
def getdatefield(str_date):
|
def getdatefield(str_date):
|
||||||
str_year = ''
|
str_year = ''
|
||||||
|
@ -730,13 +793,13 @@ def cal_listhead():
|
||||||
|
|
||||||
html = [
|
html = [
|
||||||
u' <tr>',
|
u' <tr>',
|
||||||
u' <td class="list_head">Titre</td>',
|
u' <td class="list_head">Title</td>',
|
||||||
u' <td class="list_head">Début</td>',
|
u' <td class="list_head">Start Date</td>',
|
||||||
u' <td class="list_head">Fin</td>',
|
u' <td class="list_head">End Date</td>',
|
||||||
u' <td class="list_head">Fréquence</td>',
|
u' <td class="list_head">Recurrence</td>',
|
||||||
u' <td class="list_head">Label</td>',
|
u' <td class="list_head">Label</td>',
|
||||||
u' <td class="list_head">Description</td>',
|
u' <td class="list_head">Description</td>',
|
||||||
u' <td class="list_head">Page source</td>',
|
u' <td class="list_head">Reference</td>',
|
||||||
u' </tr>',
|
u' </tr>',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -850,7 +913,7 @@ def showupcomingeventlist():
|
||||||
html_list_table = [
|
html_list_table = [
|
||||||
u'\r\n<div id="eventlist">',
|
u'\r\n<div id="eventlist">',
|
||||||
u'<table class="eventlist">',
|
u'<table class="eventlist">',
|
||||||
u'<tr><td colspan="7" class="list_entry" style="border-width: 0px;"><b>Évènement à venir: %s ~ %s</b><p><br><p></td></tr>' % (datefrom, dateto),
|
u'<tr><td colspan="7" class="list_entry" style="border-width: 0px;"><b>Upcoming Event List: %s ~ %s</b><p><br><p></td></tr>' % (datefrom, dateto),
|
||||||
u'%s' % html_list_header,
|
u'%s' % html_list_header,
|
||||||
u'%s' % html_event_rows,
|
u'%s' % html_event_rows,
|
||||||
u'</table>',
|
u'</table>',
|
||||||
|
@ -1052,8 +1115,12 @@ def comp_cal_events(xid, yid):
|
||||||
def comp_list_events(xid, yid):
|
def comp_list_events(xid, yid):
|
||||||
events = Globs.events
|
events = Globs.events
|
||||||
|
|
||||||
|
if events[xid]['startdate'] == events[yid]['startdate']:
|
||||||
|
return cmp(events[xid]['starttime'], events[yid]['starttime'])
|
||||||
|
else:
|
||||||
return cmp(events[xid]['startdate'], events[yid]['startdate'])
|
return cmp(events[xid]['startdate'], events[yid]['startdate'])
|
||||||
|
|
||||||
|
|
||||||
# load events from wiki pages
|
# load events from wiki pages
|
||||||
def loadEvents(datefrom='', dateto='', nocache=0):
|
def loadEvents(datefrom='', dateto='', nocache=0):
|
||||||
|
|
||||||
|
@ -1386,6 +1453,7 @@ def loadEventsFromWikiPages():
|
||||||
stored_errmsg = ''
|
stored_errmsg = ''
|
||||||
|
|
||||||
request = Globs.request
|
request = Globs.request
|
||||||
|
formatter = Globs.formatter
|
||||||
category = Params.category
|
category = Params.category
|
||||||
|
|
||||||
# cache configurations
|
# cache configurations
|
||||||
|
@ -1419,14 +1487,19 @@ def loadEventsFromWikiPages():
|
||||||
|
|
||||||
|
|
||||||
if Globs.page_action == 'refresh' or cache_pages.needsUpdate(arena._text_filename()) or timedelta_days >= 1:
|
if Globs.page_action == 'refresh' or cache_pages.needsUpdate(arena._text_filename()) or timedelta_days >= 1:
|
||||||
categorypages = searchPages(request, 'category:'+category)
|
categorypages = searchPages(request, category)
|
||||||
for page in categorypages:
|
for page in categorypages:
|
||||||
|
# this is to workaround the bug in the category search returning
|
||||||
|
# pages that only referance the category but are not in it
|
||||||
|
# i.e. in the paramiter list for this macro
|
||||||
|
if not page.page_name == request.page.page_name:
|
||||||
|
formatter.pagelink(1, pagename=page.page_name)
|
||||||
eventpages.append(page.page_name)
|
eventpages.append(page.page_name)
|
||||||
cache_pages.update('\n'.join(eventpages))
|
cache_pages.update('\n'.join(eventpages).encode('utf-8'))
|
||||||
debug('New page list is built: %d pages<p>%s</p>' % (len(eventpages), "<br/>\n".join(eventpages)))
|
debug('New page list is built: %d pages' % len(eventpages))
|
||||||
else:
|
else:
|
||||||
eventpages = cache_pages.content().split('\n')
|
eventpages = cache_pages.content().decode('utf-8').split('\n')
|
||||||
debug('Cached page list is used: %d pages<p>%s</p>' % (len(eventpages), "<br/>\n".join(eventpages)))
|
debug('Cached page list is used: %d pages' % len(eventpages))
|
||||||
|
|
||||||
if not Globs.page_action == 'refresh':
|
if not Globs.page_action == 'refresh':
|
||||||
# check the cache validity
|
# check the cache validity
|
||||||
|
@ -1443,7 +1516,6 @@ def loadEventsFromWikiPages():
|
||||||
|
|
||||||
if dirty:
|
if dirty:
|
||||||
# generating events
|
# generating events
|
||||||
debug('dirty')
|
|
||||||
|
|
||||||
dirty_local = 0
|
dirty_local = 0
|
||||||
debug_records = {}
|
debug_records = {}
|
||||||
|
@ -1505,6 +1577,34 @@ def loadEventsFromWikiPages():
|
||||||
|
|
||||||
debug('Checking event cache: it\'s dirty or requested to refresh')
|
debug('Checking event cache: it\'s dirty or requested to refresh')
|
||||||
|
|
||||||
|
else:
|
||||||
|
|
||||||
|
debug('Checking event cache: still valid')
|
||||||
|
|
||||||
|
try:
|
||||||
|
events = pickle.loads(cache_events.content())
|
||||||
|
labels = pickle.loads(cache_labels.content())
|
||||||
|
stored_errmsg = pickle.loads(cache_errmsglist.content())
|
||||||
|
|
||||||
|
cached_event_loaded = 1
|
||||||
|
|
||||||
|
debug('Cached event information is used: total %d events' % len(events))
|
||||||
|
|
||||||
|
except (pickle.UnpicklingError, IOError, EOFError, ValueError):
|
||||||
|
events = {}
|
||||||
|
labels = {}
|
||||||
|
stored_errmsg = ''
|
||||||
|
|
||||||
|
debug('Picke error at fetching cached events')
|
||||||
|
|
||||||
|
# if it needs refreshed, generate events dictionary
|
||||||
|
if not cached_event_loaded:
|
||||||
|
|
||||||
|
# XXX: just for debugging
|
||||||
|
debug('Building new event information')
|
||||||
|
for page_name in eventpages:
|
||||||
|
debug(debug_records[page_name])
|
||||||
|
|
||||||
for eventrecords in eventrecord_list:
|
for eventrecords in eventrecord_list:
|
||||||
for evtrecord in eventrecords:
|
for evtrecord in eventrecords:
|
||||||
e_id = evtrecord['id']
|
e_id = evtrecord['id']
|
||||||
|
@ -1525,30 +1625,10 @@ def loadEventsFromWikiPages():
|
||||||
|
|
||||||
debug('Event information is newly built: total %d events' % len(events))
|
debug('Event information is newly built: total %d events' % len(events))
|
||||||
|
|
||||||
|
|
||||||
else:
|
|
||||||
|
|
||||||
debug('Checking event cache: still valid')
|
|
||||||
|
|
||||||
try:
|
|
||||||
events = pickle.loads(cache_events.content())
|
|
||||||
labels = pickle.loads(cache_labels.content())
|
|
||||||
stored_errmsg = pickle.loads(cache_errmsglist.content())
|
|
||||||
|
|
||||||
cached_event_loaded = 1
|
|
||||||
|
|
||||||
debug('Cached event information is used: total %d events' % len(events))
|
|
||||||
|
|
||||||
except (pickle.UnpicklingError, IOError, EOFError, ValueError):
|
|
||||||
" " +1
|
|
||||||
events = {}
|
|
||||||
labels = {}
|
|
||||||
stored_errmsg = ''
|
|
||||||
|
|
||||||
debug('Picke error at fetching cached events')
|
|
||||||
|
|
||||||
Globs.errormsg = stored_errmsg
|
Globs.errormsg = stored_errmsg
|
||||||
|
|
||||||
# end of updating events block
|
# end of updating events block
|
||||||
|
|
||||||
return events, labels
|
return events, labels
|
||||||
|
|
||||||
|
|
||||||
|
@ -1568,7 +1648,7 @@ def getEventRecordFromPage(pagecontent, referpage):
|
||||||
regex_page_bgcolor = r"""
|
regex_page_bgcolor = r"""
|
||||||
(?P<req_field>^[ ]+default_bgcolor::[ ]+)
|
(?P<req_field>^[ ]+default_bgcolor::[ ]+)
|
||||||
(
|
(
|
||||||
(?P<pagebgcolor>\#[0-9a-fA-F]{6})
|
(?P<pagebgcolor>(\#[0-9a-fA-F]{6}|[a-zA-Z]+))
|
||||||
\s*?
|
\s*?
|
||||||
$
|
$
|
||||||
)?
|
)?
|
||||||
|
@ -1609,7 +1689,7 @@ def getEventRecordFromPage(pagecontent, referpage):
|
||||||
(
|
(
|
||||||
(?P<name>[^,^:^\s]+?)
|
(?P<name>[^,^:^\s]+?)
|
||||||
[,: ]+
|
[,: ]+
|
||||||
(?P<bgcolor>\#[0-9a-fA-F]{6})
|
(?P<bgcolor>(\#[0-9a-fA-F]{6}|[a-zA-Z]+))
|
||||||
\s*?
|
\s*?
|
||||||
$
|
$
|
||||||
)?
|
)?
|
||||||
|
@ -1881,7 +1961,7 @@ def geteventfield(detail):
|
||||||
regex_bgcolor = r"""
|
regex_bgcolor = r"""
|
||||||
(?P<reqfield>^[ ]+bgcolor::[ ]+)
|
(?P<reqfield>^[ ]+bgcolor::[ ]+)
|
||||||
(
|
(
|
||||||
(?P<bgcolor>\#[0-9a-fA-F]{6})?
|
(?P<bgcolor>(\#[0-9a-fA-F]{6}|[a-zA-Z]+))?
|
||||||
\s*?
|
\s*?
|
||||||
$
|
$
|
||||||
)?
|
)?
|
||||||
|
@ -1966,7 +2046,7 @@ def geteventfield(detail):
|
||||||
if match:
|
if match:
|
||||||
|
|
||||||
if match.group('startdate'):
|
if match.group('startdate'):
|
||||||
|
passed = 1
|
||||||
# yyyy/mm/dd: 2006/05/10; 06/05/10,
|
# yyyy/mm/dd: 2006/05/10; 06/05/10,
|
||||||
if match.group('startdate1'):
|
if match.group('startdate1'):
|
||||||
if len(match.group('startyear1')) == 2:
|
if len(match.group('startyear1')) == 2:
|
||||||
|
@ -2000,13 +2080,22 @@ def geteventfield(detail):
|
||||||
startmonth = match.group('startmonth3')
|
startmonth = match.group('startmonth3')
|
||||||
startday = match.group('startday3')
|
startday = match.group('startday3')
|
||||||
|
|
||||||
|
else:
|
||||||
|
if len(match.group('startdate').strip()) > 0:
|
||||||
|
raise EventcalError('invalid_startdate')
|
||||||
|
else:
|
||||||
|
passed = 0
|
||||||
|
|
||||||
|
if passed:
|
||||||
startdate = '%d/%02d/%02d' % (int(startyear), int(startmonth), int(startday))
|
startdate = '%d/%02d/%02d' % (int(startyear), int(startmonth), int(startday))
|
||||||
|
else:
|
||||||
|
startdate = ''
|
||||||
|
|
||||||
else:
|
else:
|
||||||
startdate = ''
|
startdate = ''
|
||||||
|
|
||||||
if match.group('starttime'):
|
if match.group('starttime'):
|
||||||
|
passed = 1
|
||||||
# 12h with ':': 12:00; 9:00pm
|
# 12h with ':': 12:00; 9:00pm
|
||||||
if match.group('starttime1'):
|
if match.group('starttime1'):
|
||||||
starthour = int(match.group('starthour1'))
|
starthour = int(match.group('starthour1'))
|
||||||
|
@ -2046,7 +2135,16 @@ def geteventfield(detail):
|
||||||
if starthour < 12 and match.group('am4').lower().startswith('p'):
|
if starthour < 12 and match.group('am4').lower().startswith('p'):
|
||||||
starthour += 12
|
starthour += 12
|
||||||
|
|
||||||
|
else:
|
||||||
|
if len(match.group('starttime').strip()) > 0:
|
||||||
|
raise EventcalError('invalid_starttime')
|
||||||
|
else:
|
||||||
|
passed = 0
|
||||||
|
|
||||||
|
if passed:
|
||||||
starttime = '%02d:%02d' % (int(starthour), int(startmin))
|
starttime = '%02d:%02d' % (int(starthour), int(startmin))
|
||||||
|
else:
|
||||||
|
starttime = ''
|
||||||
|
|
||||||
else:
|
else:
|
||||||
starttime = ''
|
starttime = ''
|
||||||
|
@ -2063,6 +2161,7 @@ def geteventfield(detail):
|
||||||
if match:
|
if match:
|
||||||
|
|
||||||
if match.group('enddate'):
|
if match.group('enddate'):
|
||||||
|
passed = 1
|
||||||
# yyyy/mm/dd: 2006/05/10; 06/05/10,
|
# yyyy/mm/dd: 2006/05/10; 06/05/10,
|
||||||
if match.group('enddate1'):
|
if match.group('enddate1'):
|
||||||
if len(match.group('endyear1')) == 2:
|
if len(match.group('endyear1')) == 2:
|
||||||
|
@ -2096,12 +2195,22 @@ def geteventfield(detail):
|
||||||
endmonth = match.group('endmonth3')
|
endmonth = match.group('endmonth3')
|
||||||
endday = match.group('endday3')
|
endday = match.group('endday3')
|
||||||
|
|
||||||
|
else:
|
||||||
|
if len(match.group('enddate').strip()) > 0:
|
||||||
|
raise EventcalError('invalid_enddate')
|
||||||
|
else:
|
||||||
|
passed = 0
|
||||||
|
|
||||||
|
if passed:
|
||||||
enddate = '%d/%02d/%02d' % (int(endyear), int(endmonth), int(endday))
|
enddate = '%d/%02d/%02d' % (int(endyear), int(endmonth), int(endday))
|
||||||
else:
|
else:
|
||||||
enddate = ''
|
enddate = ''
|
||||||
|
|
||||||
if match.group('endtime'):
|
else:
|
||||||
|
enddate = ''
|
||||||
|
|
||||||
|
if match.group('endtime'):
|
||||||
|
passed = 1
|
||||||
# 12h with ':': 12:00; 9:00pm
|
# 12h with ':': 12:00; 9:00pm
|
||||||
if match.group('endtime1'):
|
if match.group('endtime1'):
|
||||||
endhour = int(match.group('endhour1'))
|
endhour = int(match.group('endhour1'))
|
||||||
|
@ -2141,7 +2250,16 @@ def geteventfield(detail):
|
||||||
if endhour < 12 and match.group('am4').lower() == 'pm':
|
if endhour < 12 and match.group('am4').lower() == 'pm':
|
||||||
endhour += 12
|
endhour += 12
|
||||||
|
|
||||||
|
else:
|
||||||
|
if len(match.group('endtime').strip()) > 0:
|
||||||
|
raise EventcalError('invalid_endtime')
|
||||||
|
else:
|
||||||
|
passed = 0
|
||||||
|
|
||||||
|
if passed:
|
||||||
endtime = '%02d:%02d' % (int(endhour), int(endmin))
|
endtime = '%02d:%02d' % (int(endhour), int(endmin))
|
||||||
|
else:
|
||||||
|
endtime = ''
|
||||||
|
|
||||||
else:
|
else:
|
||||||
endtime = ''
|
endtime = ''
|
||||||
|
@ -2248,7 +2366,11 @@ def geteventfield(detail):
|
||||||
endmonth = match.group('endmonth3')
|
endmonth = match.group('endmonth3')
|
||||||
endday = match.group('endday3')
|
endday = match.group('endday3')
|
||||||
|
|
||||||
|
else:
|
||||||
|
raise EventcalError('invalid_recur_until')
|
||||||
|
|
||||||
recur_until = '%d/%02d/%02d' % (int(endyear), int(endmonth), int(endday))
|
recur_until = '%d/%02d/%02d' % (int(endyear), int(endmonth), int(endday))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise EventcalError('invalid_recur_until')
|
raise EventcalError('invalid_recur_until')
|
||||||
|
|
||||||
|
@ -2269,7 +2391,7 @@ def geteventfield(detail):
|
||||||
if not endtime:
|
if not endtime:
|
||||||
endtime = starttime
|
endtime = starttime
|
||||||
elif not starttime:
|
elif not starttime:
|
||||||
raise EventcalError('invalid_starttime')
|
raise EventcalError('need_starttime')
|
||||||
|
|
||||||
|
|
||||||
# if no time, it's 1-day event
|
# if no time, it's 1-day event
|
||||||
|
@ -2340,12 +2462,12 @@ def geteventfield(detail):
|
||||||
try:
|
try:
|
||||||
ryear, rmonth, rday = getdatefield(recur_until)
|
ryear, rmonth, rday = getdatefield(recur_until)
|
||||||
except (TypeError, ValueError):
|
except (TypeError, ValueError):
|
||||||
raise EventcalError('invalid_date')
|
raise EventcalError('invalid_recur_until')
|
||||||
|
|
||||||
recur_until = formatDate(ryear, rmonth, rday)
|
recur_until = formatDate(ryear, rmonth, rday)
|
||||||
|
|
||||||
if int(recur_until) < int(enddate):
|
if int(recur_until) < int(enddate):
|
||||||
raise EventcalError('invalid_date')
|
raise EventcalError('recur_until_precede')
|
||||||
|
|
||||||
return startdate, starttime, enddate, endtime, bgcolor, label, description, recur_freq, recur_type, recur_until
|
return startdate, starttime, enddate, endtime, bgcolor, label, description, recur_freq, recur_type, recur_until
|
||||||
|
|
||||||
|
@ -2355,7 +2477,7 @@ def converttext(targettext):
|
||||||
# Converts some special characters of html to plain-text style
|
# Converts some special characters of html to plain-text style
|
||||||
# What else to handle?
|
# What else to handle?
|
||||||
|
|
||||||
targettext = targettext.replace(u'&', '&')
|
targettext = targettext.replace(u'&', '&')
|
||||||
targettext = targettext.replace(u'>', '>')
|
targettext = targettext.replace(u'>', '>')
|
||||||
targettext = targettext.replace(u'<', '<')
|
targettext = targettext.replace(u'<', '<')
|
||||||
targettext = targettext.replace(u'\n', '<br>')
|
targettext = targettext.replace(u'\n', '<br>')
|
||||||
|
@ -2812,7 +2934,7 @@ def showdailyeventcalendar(year, month, day):
|
||||||
#debug('appending left %d slots: %d' % (left_slots, hour_index))
|
#debug('appending left %d slots: %d' % (left_slots, hour_index))
|
||||||
html_hour_cols[hour_index].append ( calshow_blankeventbox2( left_slots * colspan, left_slots * width ) )
|
html_hour_cols[hour_index].append ( calshow_blankeventbox2( left_slots * colspan, left_slots * width ) )
|
||||||
|
|
||||||
html_cols = u'\r\n'.join(html_hour_cols[hour_index]) % {'colspan': colspan, 'width': u'%d' % width}
|
html_cols = u'\r\n'.join(html_hour_cols[hour_index]) % {'colspan': colspan, 'width': u'%d%%' % width}
|
||||||
html_cols = u'<tr>%s</tr>\r\n' % html_cols
|
html_cols = u'<tr>%s</tr>\r\n' % html_cols
|
||||||
|
|
||||||
html_calendar_rows.append (html_cols)
|
html_calendar_rows.append (html_cols)
|
||||||
|
@ -3073,7 +3195,7 @@ def showweeklyeventcalendar(year, month, day):
|
||||||
#debug('appending left %d slots: %d' % (left_slots, hour_index))
|
#debug('appending left %d slots: %d' % (left_slots, hour_index))
|
||||||
html_hour_cols[hour_index][dayindex].append ( calshow_blankeventbox2( left_slots * colspan, left_slots * width ) )
|
html_hour_cols[hour_index][dayindex].append ( calshow_blankeventbox2( left_slots * colspan, left_slots * width ) )
|
||||||
|
|
||||||
html_cols = u'\r\n'.join(html_hour_cols[hour_index][dayindex]) % {'colspan': colspan, 'width': "%d%%" % width}
|
html_cols = u'\r\n'.join(html_hour_cols[hour_index][dayindex]) % {'colspan': colspan, 'width': u'%d%%' % width}
|
||||||
html_cols_days.append(html_cols)
|
html_cols_days.append(html_cols)
|
||||||
|
|
||||||
html_cols_collected = u'\r\n'.join(html_cols_days)
|
html_cols_collected = u'\r\n'.join(html_cols_days)
|
||||||
|
@ -3314,7 +3436,7 @@ def showsimpleeventcalendar(year, month):
|
||||||
// -->
|
// -->
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
""" % (request.cfg.url_prefix, "\n".join(maketip_js))
|
""" % (request.cfg.url_prefix_static, "\n".join(maketip_js))
|
||||||
|
|
||||||
|
|
||||||
html_cal_table = [
|
html_cal_table = [
|
||||||
|
@ -3347,9 +3469,9 @@ def calhead_yearmonth(year, month, headclass):
|
||||||
nextyear, nextmonth = yearmonthplusoffset(year, month, 1)
|
nextyear, nextmonth = yearmonthplusoffset(year, month, 1)
|
||||||
prevyear, prevmonth = yearmonthplusoffset(year, month, -1)
|
prevyear, prevmonth = yearmonthplusoffset(year, month, -1)
|
||||||
|
|
||||||
prevlink = u'%s?calaction=%s&caldate=%d%02d%s' % (page_url, cal_action, prevyear, prevmonth, getquerystring(['numcal']) )
|
prevlink = u'%s?calaction=%s&caldate=%d%02d%s' % (page_url, cal_action, prevyear, prevmonth, getquerystring(['numcal']) )
|
||||||
nextlink = u'%s?calaction=%s&caldate=%d%02d%s' % (page_url, cal_action, nextyear, nextmonth, getquerystring(['numcal']))
|
nextlink = u'%s?calaction=%s&caldate=%d%02d%s' % (page_url, cal_action, nextyear, nextmonth, getquerystring(['numcal']))
|
||||||
curlink = u'%s?calaction=%s&caldate=%d%02d%s' % (page_url, cal_action, year, month, getquerystring(['numcal']))
|
curlink = u'%s?calaction=%s&caldate=%d%02d%s' % (page_url, cal_action, year, month, getquerystring(['numcal']))
|
||||||
|
|
||||||
if monthstyle_us:
|
if monthstyle_us:
|
||||||
stryearmonth = u'%s %d' % (months[month-1], year)
|
stryearmonth = u'%s %d' % (months[month-1], year)
|
||||||
|
@ -3389,9 +3511,9 @@ def calhead_yearmonthday(year, month, day, headclass, colspan):
|
||||||
prevdate = date_today - datetime.timedelta(days=1)
|
prevdate = date_today - datetime.timedelta(days=1)
|
||||||
nextdate = date_today + datetime.timedelta(days=1)
|
nextdate = date_today + datetime.timedelta(days=1)
|
||||||
|
|
||||||
prevlink = u'%s?calaction=%s&caldate=%d%02d%02d%s' % (page_url, cal_action, prevdate.year, prevdate.month, prevdate.day, getquerystring(['numcal']) )
|
prevlink = u'%s?calaction=%s&caldate=%d%02d%02d%s' % (page_url, cal_action, prevdate.year, prevdate.month, prevdate.day, getquerystring(['numcal']) )
|
||||||
nextlink = u'%s?calaction=%s&caldate=%d%02d%02d%s' % (page_url, cal_action, nextdate.year, nextdate.month, nextdate.day, getquerystring(['numcal']))
|
nextlink = u'%s?calaction=%s&caldate=%d%02d%02d%s' % (page_url, cal_action, nextdate.year, nextdate.month, nextdate.day, getquerystring(['numcal']))
|
||||||
curlink = u'%s?calaction=%s&caldate=%d%02d%02d%s' % (page_url, cal_action, year, month, day, getquerystring(['numcal']))
|
curlink = u'%s?calaction=%s&caldate=%d%02d%02d%s' % (page_url, cal_action, year, month, day, getquerystring(['numcal']))
|
||||||
|
|
||||||
if monthstyle_us:
|
if monthstyle_us:
|
||||||
stryearmonth = u'%s %d, %d' % (months[month-1], day, year)
|
stryearmonth = u'%s %d, %d' % (months[month-1], day, year)
|
||||||
|
@ -3446,9 +3568,9 @@ def calhead_yearmonthday2(year, month, day, headclass, colspan):
|
||||||
prevdate_l = last_date_week - datetime.timedelta(days=7)
|
prevdate_l = last_date_week - datetime.timedelta(days=7)
|
||||||
nextdate_l = last_date_week + datetime.timedelta(days=7)
|
nextdate_l = last_date_week + datetime.timedelta(days=7)
|
||||||
|
|
||||||
prevlink = u'%s?calaction=%s&caldate=%d%02d%02d%s' % (page_url, cal_action, prevdate.year, prevdate.month, prevdate.day, getquerystring(['numcal']) )
|
prevlink = u'%s?calaction=%s&caldate=%d%02d%02d%s' % (page_url, cal_action, prevdate.year, prevdate.month, prevdate.day, getquerystring(['numcal']) )
|
||||||
nextlink = u'%s?calaction=%s&caldate=%d%02d%02d%s' % (page_url, cal_action, nextdate.year, nextdate.month, nextdate.day, getquerystring(['numcal']))
|
nextlink = u'%s?calaction=%s&caldate=%d%02d%02d%s' % (page_url, cal_action, nextdate.year, nextdate.month, nextdate.day, getquerystring(['numcal']))
|
||||||
curlink = u'%s?calaction=%s&caldate=%d%02d%02d%s' % (page_url, cal_action, year, month, day, getquerystring(['numcal']))
|
curlink = u'%s?calaction=%s&caldate=%d%02d%02d%s' % (page_url, cal_action, year, month, day, getquerystring(['numcal']))
|
||||||
|
|
||||||
if monthstyle_us:
|
if monthstyle_us:
|
||||||
stryearmonth = u'%s %d, %d ~ %s %d, %d' % (months[first_date_week.month-1], first_date_week.day, first_date_week.year, months[last_date_week.month-1], last_date_week.day, last_date_week.year)
|
stryearmonth = u'%s %d, %d ~ %s %d, %d' % (months[first_date_week.month-1], first_date_week.day, first_date_week.year, months[last_date_week.month-1], last_date_week.day, last_date_week.year)
|
||||||
|
@ -3572,12 +3694,12 @@ def calhead_day(year, month, day, wkday):
|
||||||
html_text = u'%s' % day
|
html_text = u'%s' % day
|
||||||
|
|
||||||
page_url = Globs.pageurl
|
page_url = Globs.pageurl
|
||||||
html_text = u'<a href="%s?calaction=daily&caldate=%d%02d%02d">%s</a>' % (page_url, year, month, day, html_text)
|
html_text = u'<a href="%s?calaction=daily&caldate=%d%02d%02d">%s</a>' % (page_url, year, month, day, html_text)
|
||||||
|
|
||||||
cyear, cmonth, cday = gettodaydate()
|
cyear, cmonth, cday = gettodaydate()
|
||||||
|
|
||||||
if (not wkday) and Params.showweeknumber:
|
if (not wkday) and Params.showweeknumber:
|
||||||
html_text = u'%s <font size="1" color="#aaaaaa"><i>(%d)</i></font>' % (html_text, (int(datetime.date(year, month, day).strftime('%W')) + 1))
|
html_text = u'%s <font size="1" color="#aaaaaa"><i>(%d)</i></font>' % (html_text, (int(datetime.date(year, month, day).isocalendar()[1])))
|
||||||
|
|
||||||
if cyear == year and cmonth == month and cday == day:
|
if cyear == year and cmonth == month and cday == day:
|
||||||
html = u' <td class="head_day_today"> %s</td>\r\n' % html_text
|
html = u' <td class="head_day_today"> %s</td>\r\n' % html_text
|
||||||
|
@ -3785,7 +3907,7 @@ def calshow_weekly_eventbox(event):
|
||||||
u' width: %(width)s;" ',
|
u' width: %(width)s;" ',
|
||||||
u' rowspan="%(rowspan)d"' % { 'rowspan': time_len },
|
u' rowspan="%(rowspan)d"' % { 'rowspan': time_len },
|
||||||
u' class="cal_weekly_eventbox">',
|
u' class="cal_weekly_eventbox">',
|
||||||
u' %s' % (showReferPageParsed(event, 'title', 1).replace("%","%%")),
|
u' %s' % showReferPageParsed(event, 'title', 1),
|
||||||
u' </td>',
|
u' </td>',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -3984,7 +4106,7 @@ def geterrormsg(errmsgcode, refer='', title='', hid=''):
|
||||||
msg = 'Error: Invalid date format. Not handled.'
|
msg = 'Error: Invalid date format. Not handled.'
|
||||||
|
|
||||||
elif errmsgcode == 'enddate_precede':
|
elif errmsgcode == 'enddate_precede':
|
||||||
msg = 'Error: Enddate precedes startdate. Not handled.'
|
msg = 'Error: Startdate should be earlier than Enddate. Not handled.'
|
||||||
|
|
||||||
elif errmsgcode == 'invalid_starttime':
|
elif errmsgcode == 'invalid_starttime':
|
||||||
msg = 'Error: Invalid starttime format. Not handled.'
|
msg = 'Error: Invalid starttime format. Not handled.'
|
||||||
|
@ -3996,7 +4118,7 @@ def geterrormsg(errmsgcode, refer='', title='', hid=''):
|
||||||
msg = 'Error: Invalid time format. Not handled.'
|
msg = 'Error: Invalid time format. Not handled.'
|
||||||
|
|
||||||
elif errmsgcode == 'endtime_precede':
|
elif errmsgcode == 'endtime_precede':
|
||||||
msg = 'Error: Enddate precedes startdate. Not handled.'
|
msg = 'Error: Starttime should be earlier than Endtime. Not handled.'
|
||||||
|
|
||||||
elif errmsgcode == 'len_recur_int':
|
elif errmsgcode == 'len_recur_int':
|
||||||
msg = 'Error: Event length should be smaller than recurrence interval. Not handled.'
|
msg = 'Error: Event length should be smaller than recurrence interval. Not handled.'
|
||||||
|
@ -4028,6 +4150,12 @@ def geterrormsg(errmsgcode, refer='', title='', hid=''):
|
||||||
elif errmsgcode == 'empty_label_definition':
|
elif errmsgcode == 'empty_label_definition':
|
||||||
msg = 'Warning: Invalid label definition. Ignored.'
|
msg = 'Warning: Invalid label definition. Ignored.'
|
||||||
|
|
||||||
|
elif errmsgcode == 'need_starttime':
|
||||||
|
msg = 'Error: Starttime should be specified. Not handled.'
|
||||||
|
|
||||||
|
elif errmsgcode == 'recur_until_precede':
|
||||||
|
msg = 'Error: Enddate should be earlier than the end date (until) of recurrence. Not handled.'
|
||||||
|
|
||||||
else:
|
else:
|
||||||
msg = 'undefined: %s' % errmsgcode
|
msg = 'undefined: %s' % errmsgcode
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue