2009-03-21 04:43:06 +05:30
|
|
|
|
#
|
2007-08-27 09:22:06 +05:30
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
|
#
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# Copyright (C) 2007 Thom Sturgill
|
2009-01-30 07:49:04 +05:30
|
|
|
|
# Copyright (C) 2007-2009 Brian G. Matherly
|
2009-02-03 13:31:31 +05:30
|
|
|
|
# Copyright (C) 2008-2009 Rob G. Healey <robhealey1@gmail.com>
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# Copyright (C) 2008 Jason Simanek
|
2007-08-27 09:22:06 +05:30
|
|
|
|
#
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
|
# it under the terms of the GNU General Pubilc License as published by
|
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
#
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
#
|
|
|
|
|
|
2009-03-24 20:28:16 +05:30
|
|
|
|
# $Id: WebCal.py 12238 2009-03-07 09:51:27Z s_charette $
|
2007-08-27 09:22:06 +05:30
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
Web Calendar generator.
|
2008-01-29 13:10:35 +05:30
|
|
|
|
|
2008-11-11 03:11:38 +05:30
|
|
|
|
Refactoring. This is an ongoing job until this plugin is in a better shape.
|
2007-08-27 09:22:06 +05:30
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# python modules
|
|
|
|
|
#
|
|
|
|
|
#------------------------------------------------------------------------
|
2009-02-24 08:22:06 +05:30
|
|
|
|
import os, codecs, shutil
|
2009-04-03 05:34:29 +05:30
|
|
|
|
import datetime, calendar
|
2007-08-27 09:22:06 +05:30
|
|
|
|
from gettext import gettext as _
|
2009-02-04 22:28:46 +05:30
|
|
|
|
from gettext import ngettext
|
2007-08-27 09:22:06 +05:30
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# Set up logging
|
|
|
|
|
#
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
|
import logging
|
|
|
|
|
log = logging.getLogger(".WebPage")
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# GRAMPS module
|
|
|
|
|
#
|
|
|
|
|
#------------------------------------------------------------------------
|
2009-04-06 09:19:47 +05:30
|
|
|
|
from gen.lib import date, Date, Name, Person, NameType, EventType
|
2007-08-27 09:22:06 +05:30
|
|
|
|
import const
|
|
|
|
|
from GrampsCfg import get_researcher
|
2008-10-02 09:32:10 +05:30
|
|
|
|
from gen.plug import PluginManager
|
|
|
|
|
from ReportBase import Report, ReportUtils, MenuReportOptions, CATEGORY_WEB
|
2008-09-27 19:26:17 +05:30
|
|
|
|
from gen.plug.menu import BooleanOption, NumberOption, StringOption, \
|
|
|
|
|
EnumeratedListOption, FilterOption, PersonOption, \
|
|
|
|
|
DestinationOption
|
2007-08-27 09:22:06 +05:30
|
|
|
|
import GrampsLocale
|
2009-01-30 07:49:04 +05:30
|
|
|
|
from QuestionDialog import WarningDialog
|
2009-04-06 09:19:47 +05:30
|
|
|
|
from Utils import probably_alive, ProgressMeter, xml_lang
|
2008-07-17 18:35:15 +05:30
|
|
|
|
from DateHandler import displayer as _dd
|
2007-08-27 09:22:06 +05:30
|
|
|
|
|
2009-04-06 09:19:47 +05:30
|
|
|
|
from BasicUtils import name_displayer as _nd
|
|
|
|
|
|
2009-01-30 07:49:04 +05:30
|
|
|
|
import libholiday
|
2009-04-03 05:34:29 +05:30
|
|
|
|
from libhtml import Html
|
2009-01-30 07:49:04 +05:30
|
|
|
|
|
2007-08-27 09:22:06 +05:30
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# constants
|
|
|
|
|
#
|
|
|
|
|
#------------------------------------------------------------------------
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# Web page filename extensions
|
|
|
|
|
_WEB_EXT = ['.html', '.htm', '.shtml', '.php', '.php3', '.cgi']
|
|
|
|
|
|
2009-02-26 13:55:45 +05:30
|
|
|
|
# Calendar stylesheet names
|
|
|
|
|
_CALENDARSCREEN = 'calendar-screen.css'
|
|
|
|
|
_CALENDARPRINT = 'calendar-print.css'
|
|
|
|
|
|
2008-07-17 18:35:15 +05:30
|
|
|
|
# This information defines the list of styles in the Web calendar
|
2009-02-24 08:22:06 +05:30
|
|
|
|
# options dialog as well as the location of the corresponding
|
2008-07-17 18:35:15 +05:30
|
|
|
|
# stylesheets.
|
|
|
|
|
_CSS_FILES = [
|
|
|
|
|
# First is used as default selection.
|
2008-10-22 00:27:42 +05:30
|
|
|
|
[_("Basic-Ash"), 'Web_Basic-Ash.css'],
|
|
|
|
|
[_("Basic-Cypress"), 'Web_Basic-Cypress.css'],
|
|
|
|
|
[_("Basic-Lilac"), 'Web_Basic-Lilac.css'],
|
|
|
|
|
[_("Basic-Peach"), 'Web_Basic-Peach.css'],
|
|
|
|
|
[_("Basic-Spruce"), 'Web_Basic-Spruce.css'],
|
|
|
|
|
[_("Mainz"), 'Web_Mainz.css'],
|
|
|
|
|
[_("Nebraska"), 'Web_Nebraska.css'],
|
|
|
|
|
[_("Visually Impaired"), 'Web_Visually.css'],
|
2008-11-11 03:11:38 +05:30
|
|
|
|
[_("No style sheet"), ''],
|
2008-07-17 18:35:15 +05:30
|
|
|
|
]
|
2007-08-27 09:22:06 +05:30
|
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
|
_CHARACTER_SETS = [
|
2008-07-17 20:18:54 +05:30
|
|
|
|
# First is used as default selection.
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# As seen on the internet, ISO-xxx are listed as capital letters
|
|
|
|
|
[_('Unicode UTF-8 (recommended)'), 'UTF-8'],
|
|
|
|
|
['ISO-8859-1', 'ISO-8859-1' ],
|
|
|
|
|
['ISO-8859-2', 'ISO-8859-2' ],
|
|
|
|
|
['ISO-8859-3', 'ISO-8859-3' ],
|
|
|
|
|
['ISO-8859-4', 'ISO-8859-4' ],
|
|
|
|
|
['ISO-8859-5', 'ISO-8859-5' ],
|
|
|
|
|
['ISO-8859-6', 'ISO-8859-6' ],
|
|
|
|
|
['ISO-8859-7', 'ISO-8859-7' ],
|
|
|
|
|
['ISO-8859-8', 'ISO-8859-8' ],
|
|
|
|
|
['ISO-8859-9', 'ISO-8859-9' ],
|
|
|
|
|
['ISO-8859-10', 'ISO-8859-10' ],
|
|
|
|
|
['ISO-8859-13', 'ISO-8859-13' ],
|
|
|
|
|
['ISO-8859-14', 'ISO-8859-14' ],
|
|
|
|
|
['ISO-8859-15', 'ISO-8859-15' ],
|
2007-08-27 09:22:06 +05:30
|
|
|
|
['koi8_r', 'koi8_r', ],
|
|
|
|
|
]
|
|
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
|
_CC = [
|
2008-07-17 20:18:54 +05:30
|
|
|
|
'',
|
|
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
|
'<a rel="license" href="http://creativecommons.org/licenses/by/2.5/">'
|
2008-07-17 20:18:54 +05:30
|
|
|
|
'<img alt="Creative Commons License - By attribution" '
|
|
|
|
|
'title="Creative Commons License - By attribution" '
|
|
|
|
|
'src="%(gif_fname)s" /></a>',
|
|
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
|
'<a rel="license" href="http://creativecommons.org/licenses/by-nd/2.5/">'
|
|
|
|
|
'<img alt="Creative Commons License - By attribution, No derivations" '
|
2008-07-17 20:18:54 +05:30
|
|
|
|
'title="Creative Commons License - By attribution, No derivations" '
|
|
|
|
|
'src="%(gif_fname)s" /></a>',
|
|
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
|
'<a rel="license" href="http://creativecommons.org/licenses/by-sa/2.5/">'
|
|
|
|
|
'<img alt="Creative Commons License - By attribution, Share-alike" '
|
2008-07-17 20:18:54 +05:30
|
|
|
|
'title="Creative Commons License - By attribution, Share-alike" '
|
|
|
|
|
'src="%(gif_fname)s" /></a>',
|
|
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
|
'<a rel="license" href="http://creativecommons.org/licenses/by-nc/2.5/">'
|
|
|
|
|
'<img alt="Creative Commons License - By attribution, Non-commercial" '
|
2008-07-17 20:18:54 +05:30
|
|
|
|
'title="Creative Commons License - By attribution, Non-commercial" '
|
|
|
|
|
'src="%(gif_fname)s" /></a>',
|
|
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
|
'<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/2.5/">'
|
2008-07-17 20:18:54 +05:30
|
|
|
|
'<img alt="Creative Commons License - By attribution, Non-commercial, No derivations" '
|
|
|
|
|
'title="Creative Commons License - By attribution, Non-commercial, No derivations" '
|
|
|
|
|
'src="%(gif_fname)s" /></a>',
|
|
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
|
'<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/2.5/">'
|
2008-07-17 20:18:54 +05:30
|
|
|
|
'<img alt="Creative Commons License - By attribution, Non-commerical, Share-alike" '
|
|
|
|
|
'title="Creative Commons License - By attribution, Non-commerical, Share-alike" '
|
|
|
|
|
'src="%(gif_fname)s" /></a>'
|
2007-08-27 09:22:06 +05:30
|
|
|
|
]
|
|
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
|
_COPY_OPTIONS = [
|
|
|
|
|
_('Standard copyright'),
|
2008-07-17 20:18:54 +05:30
|
|
|
|
|
2008-11-11 03:11:38 +05:30
|
|
|
|
# This must match _CC
|
2008-02-10 09:39:09 +05:30
|
|
|
|
_('Creative Commons - By attribution'),
|
|
|
|
|
_('Creative Commons - By attribution, No derivations'),
|
|
|
|
|
_('Creative Commons - By attribution, Share-alike'),
|
|
|
|
|
_('Creative Commons - By attribution, Non-commercial'),
|
|
|
|
|
_('Creative Commons - By attribution, Non-commercial, No derivations'),
|
|
|
|
|
_('Creative Commons - By attribution, Non-commercial, Share-alike'),
|
2008-07-17 20:18:54 +05:30
|
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
|
_('No copyright notice'),
|
|
|
|
|
]
|
|
|
|
|
|
2007-08-27 09:22:06 +05:30
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
|
#
|
2008-02-10 09:39:09 +05:30
|
|
|
|
# WebCalReport
|
2007-08-27 09:22:06 +05:30
|
|
|
|
#
|
|
|
|
|
#------------------------------------------------------------------------
|
2008-02-10 09:39:09 +05:30
|
|
|
|
class WebCalReport(Report):
|
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
|
Create WebCalReport object that produces the report.
|
2008-02-10 09:39:09 +05:30
|
|
|
|
"""
|
2008-02-20 10:22:10 +05:30
|
|
|
|
def __init__(self, database, options):
|
|
|
|
|
Report.__init__(self, database, options)
|
2009-02-27 00:46:02 +05:30
|
|
|
|
mgobn = lambda name:options.menu.get_option_by_name(name).get_value()
|
2008-07-17 20:18:54 +05:30
|
|
|
|
|
2007-08-27 09:22:06 +05:30
|
|
|
|
self.database = database
|
|
|
|
|
self.options = options
|
2008-07-17 20:18:54 +05:30
|
|
|
|
|
2009-02-27 00:46:02 +05:30
|
|
|
|
self.html_dir = mgobn('target')
|
|
|
|
|
self.title_text = mgobn('title')
|
|
|
|
|
filter_option = options.menu.get_option_by_name('filter')
|
2008-02-10 09:39:09 +05:30
|
|
|
|
self.filter = filter_option.get_filter()
|
2009-04-06 09:19:47 +05:30
|
|
|
|
self.name_format = mgobn('name_format')
|
2009-02-27 00:46:02 +05:30
|
|
|
|
self.ext = mgobn('ext')
|
|
|
|
|
self.copy = mgobn('cright')
|
|
|
|
|
self.css = mgobn('css')
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-02-27 00:46:02 +05:30
|
|
|
|
self.country = mgobn('country')
|
|
|
|
|
self.start_dow = mgobn('start_dow')
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-02-27 00:46:02 +05:30
|
|
|
|
self.multiyear = mgobn('multiyear')
|
|
|
|
|
self.start_year = mgobn('start_year')
|
|
|
|
|
self.end_year = mgobn('end_year')
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-02-27 00:46:02 +05:30
|
|
|
|
self.maiden_name = mgobn('maiden_name')
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-02-27 00:46:02 +05:30
|
|
|
|
self.alive = mgobn('alive')
|
|
|
|
|
self.birthday = mgobn('birthdays')
|
|
|
|
|
self.anniv = mgobn('anniversaries')
|
|
|
|
|
self.home_link = mgobn('home_link')
|
2009-02-26 13:55:45 +05:30
|
|
|
|
|
2009-02-27 00:46:02 +05:30
|
|
|
|
self.month_notes = [mgobn('note_' + month) \
|
|
|
|
|
for month in ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul',
|
|
|
|
|
'aug', 'sep', 'oct', 'nov', 'dec']]
|
2008-07-17 20:18:54 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
self.encoding = mgobn('encoding')
|
|
|
|
|
self.fullyear = mgobn('fullyear')
|
|
|
|
|
self.makeoneday = mgobn('makeoneday')
|
|
|
|
|
|
2008-10-08 01:41:46 +05:30
|
|
|
|
# identify researcher name and e-mail address
|
2009-02-26 13:55:45 +05:30
|
|
|
|
# as NarrativeWeb already does
|
2008-10-08 01:41:46 +05:30
|
|
|
|
researcher = get_researcher()
|
|
|
|
|
self.author = researcher.name
|
|
|
|
|
if self.author:
|
|
|
|
|
self.author = self.author.replace(',,,', '')
|
|
|
|
|
self.email = researcher.email
|
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# set to today's date
|
2009-04-06 09:19:47 +05:30
|
|
|
|
self.today = date.Today()
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2008-08-05 02:16:46 +05:30
|
|
|
|
self.warn_dir = True # Only give warning once.
|
2008-07-31 03:07:24 +05:30
|
|
|
|
|
2008-11-11 03:11:38 +05:30
|
|
|
|
# self.calendar is a dict; key is the month number
|
|
|
|
|
# Each entry in the dict is also a dict; key is the day number.
|
|
|
|
|
# The day dict is a list of things to display for that day.
|
|
|
|
|
# These things are: birthdays and anniversaries
|
|
|
|
|
self.calendar = {}
|
|
|
|
|
|
2009-02-10 12:49:56 +05:30
|
|
|
|
calendar.setfirstweekday(dow_gramps2iso[self.start_dow])
|
2008-08-12 01:49:51 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# Copy files to their destination
|
|
|
|
|
#
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
|
2008-07-17 20:18:54 +05:30
|
|
|
|
def copy_file(self, from_fname, to_fname, to_dir=''):
|
2008-07-17 18:35:15 +05:30
|
|
|
|
"""
|
2008-07-17 20:18:54 +05:30
|
|
|
|
Copy a file from a source to a (report) destination.
|
|
|
|
|
If to_dir is not present and if the target is not an archive,
|
|
|
|
|
then the destination directory will be created.
|
|
|
|
|
|
|
|
|
|
Normally 'to_fname' will be just a filename, without directory path.
|
|
|
|
|
|
|
|
|
|
'to_dir' is the relative path name in the destination root. It will
|
|
|
|
|
be prepended before 'to_fname'.
|
2008-07-17 18:35:15 +05:30
|
|
|
|
"""
|
2008-07-17 20:18:54 +05:30
|
|
|
|
dest = os.path.join(self.html_dir, to_dir, to_fname)
|
|
|
|
|
|
|
|
|
|
destdir = os.path.dirname(dest)
|
|
|
|
|
if not os.path.isdir(destdir):
|
|
|
|
|
os.makedirs(destdir)
|
|
|
|
|
|
|
|
|
|
if from_fname != dest:
|
|
|
|
|
shutil.copyfile(from_fname, dest)
|
2008-07-17 18:35:15 +05:30
|
|
|
|
elif self.warn_dir:
|
|
|
|
|
WarningDialog(
|
|
|
|
|
_("Possible destination error") + "\n" +
|
|
|
|
|
_("You appear to have set your target directory "
|
|
|
|
|
"to a directory used for data storage. This "
|
|
|
|
|
"could create problems with file management. "
|
|
|
|
|
"It is recommended that you consider using "
|
|
|
|
|
"a different directory to store your generated "
|
|
|
|
|
"web pages."))
|
|
|
|
|
self.warn_dir = False
|
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
#
|
2009-04-03 05:34:29 +05:30
|
|
|
|
# Adds Birthdays, Anniversaries, and holidays
|
2009-03-21 04:43:06 +05:30
|
|
|
|
#
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
2008-10-08 01:41:46 +05:30
|
|
|
|
def add_day_item(self, text, year, month, day, event):
|
2009-04-03 05:34:29 +05:30
|
|
|
|
"""
|
|
|
|
|
adds birthdays, anniversaries, and holidays to their perspective lists
|
|
|
|
|
|
|
|
|
|
text -- line to be added
|
|
|
|
|
year, month, day -- date to add the text to
|
|
|
|
|
|
|
|
|
|
event -- one of 'BirthDay', 'Anniversary', or 'Holiday'
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
# This may happen for certain "about" dates.
|
|
|
|
|
# Use first day of the month
|
2008-07-31 03:07:24 +05:30
|
|
|
|
if day == 0:
|
2009-04-03 05:34:29 +05:30
|
|
|
|
day = 1
|
2009-03-26 16:47:57 +05:30
|
|
|
|
|
|
|
|
|
# determine which dictionary to use???
|
|
|
|
|
if event in ['Birthday', 'Anniversary']:
|
|
|
|
|
month_dict = self.calendar.get(month, {})
|
|
|
|
|
else:
|
|
|
|
|
month_dict = self.holidays.get(month, {})
|
2007-08-27 09:22:06 +05:30
|
|
|
|
day_list = month_dict.get(day, [])
|
2008-11-11 03:11:38 +05:30
|
|
|
|
|
2008-10-08 01:41:46 +05:30
|
|
|
|
if month > 0:
|
2008-11-11 03:11:38 +05:30
|
|
|
|
try:
|
2009-04-06 09:19:47 +05:30
|
|
|
|
event_date = Date()
|
2009-02-04 11:05:34 +05:30
|
|
|
|
event_date.set_yr_mon_day(year, month, day)
|
2008-11-11 03:11:38 +05:30
|
|
|
|
except ValueError:
|
2009-02-04 11:05:34 +05:30
|
|
|
|
event_date = '...'
|
2008-10-08 01:41:46 +05:30
|
|
|
|
else:
|
2009-02-04 11:05:34 +05:30
|
|
|
|
event_date = '...' #Incomplete date as in about, circa, etc.
|
2008-11-11 03:11:38 +05:30
|
|
|
|
|
2009-02-04 11:05:34 +05:30
|
|
|
|
day_list.append((text, event, event_date))
|
2007-08-27 09:22:06 +05:30
|
|
|
|
month_dict[day] = day_list
|
2009-03-26 16:47:57 +05:30
|
|
|
|
|
|
|
|
|
# determine which dictionary to add it to???
|
|
|
|
|
if event in ['Birthday', 'Anniversary']:
|
|
|
|
|
self.calendar[month] = month_dict
|
|
|
|
|
else:
|
|
|
|
|
self.holidays[month] = month_dict
|
2007-08-27 09:22:06 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
#
|
2009-03-26 16:47:57 +05:30
|
|
|
|
# Retrieves Holidays from the Holiday file,
|
|
|
|
|
# src/plugins/lib/holidays.xml
|
2009-03-21 04:43:06 +05:30
|
|
|
|
#
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
2009-01-30 07:49:04 +05:30
|
|
|
|
def __get_holidays(self, year):
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
|
|
|
|
self.progress.set_pass(_('Calculating Holidays for year %d' % year), 365)
|
|
|
|
|
|
2009-01-30 07:49:04 +05:30
|
|
|
|
""" Get the holidays for the specified country and year """
|
|
|
|
|
holiday_table = libholiday.HolidayTable()
|
|
|
|
|
country = holiday_table.get_countries()[self.country]
|
|
|
|
|
holiday_table.load_holidays(year, country)
|
|
|
|
|
for month in range(1, 13):
|
|
|
|
|
for day in range(1, 32):
|
|
|
|
|
holiday_names = holiday_table.get_holidays(month, day)
|
|
|
|
|
for holiday_name in holiday_names:
|
2009-03-26 16:47:57 +05:30
|
|
|
|
self.add_day_item(holiday_name, year, month, day, 'Holiday')
|
2009-02-10 12:49:56 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# increment progress bar
|
|
|
|
|
self.progress.step()
|
|
|
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# Copies all of the calendar files for all calendars
|
|
|
|
|
#
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
2008-10-08 01:41:46 +05:30
|
|
|
|
def copy_calendar_files(self):
|
2007-08-27 09:22:06 +05:30
|
|
|
|
"""
|
2009-02-08 02:11:27 +05:30
|
|
|
|
Copies all the necessary stylesheets and images for these calendars
|
2007-08-27 09:22:06 +05:30
|
|
|
|
"""
|
2009-02-08 02:11:27 +05:30
|
|
|
|
# Copy the screen stylesheet
|
|
|
|
|
if self.css:
|
2008-10-08 01:41:46 +05:30
|
|
|
|
fname = os.path.join(const.DATA_DIR, self.css)
|
2009-02-26 13:55:45 +05:30
|
|
|
|
self.copy_file(fname, _CALENDARSCREEN, "styles")
|
2008-07-17 18:35:15 +05:30
|
|
|
|
|
2008-12-05 02:08:02 +05:30
|
|
|
|
# copy print stylesheet
|
2008-10-08 01:41:46 +05:30
|
|
|
|
fname = os.path.join(const.DATA_DIR, "Web_Print-Default.css")
|
2009-02-26 13:55:45 +05:30
|
|
|
|
self.copy_file(fname, _CALENDARPRINT, "styles")
|
2008-07-17 18:35:15 +05:30
|
|
|
|
|
2009-02-08 02:11:27 +05:30
|
|
|
|
# set imgs to empty
|
|
|
|
|
imgs = []
|
|
|
|
|
|
2009-03-26 16:47:57 +05:30
|
|
|
|
# Mainz stylesheet graphics
|
|
|
|
|
# will only be used if Mainz is slected as the stylesheet
|
|
|
|
|
Mainz_images = ["Web_Mainz_Bkgd.png", "Web_Mainz_Header.png",
|
|
|
|
|
"Web_Mainz_Mid.png", "Web_Mainz_MidLight.png"]
|
|
|
|
|
|
2009-02-08 02:11:27 +05:30
|
|
|
|
if self.css == "Web_Mainz.css":
|
|
|
|
|
# Copy Mainz Style Images
|
2009-03-26 16:47:57 +05:30
|
|
|
|
imgs += Mainz_images
|
2009-02-08 02:11:27 +05:30
|
|
|
|
|
2008-10-08 01:41:46 +05:30
|
|
|
|
# Copy GRAMPS favicon
|
2009-02-08 02:11:27 +05:30
|
|
|
|
imgs += ['favicon.ico']
|
2008-07-17 18:35:15 +05:30
|
|
|
|
|
2008-10-08 01:41:46 +05:30
|
|
|
|
# copy copyright image
|
2009-02-22 05:44:08 +05:30
|
|
|
|
if 0 < self.copy <= len(_CC):
|
2009-02-08 02:11:27 +05:30
|
|
|
|
imgs += ['somerights20.gif']
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-02-08 02:11:27 +05:30
|
|
|
|
for fname in imgs:
|
|
|
|
|
from_path = os.path.join(const.IMAGE_DIR, fname)
|
|
|
|
|
self.copy_file(from_path, fname, "images")
|
2008-10-22 00:27:42 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# Creates file name passed to it
|
|
|
|
|
#
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
def create_file(self, fname, subdir):
|
2008-07-31 03:07:24 +05:30
|
|
|
|
"""
|
2009-03-21 04:43:06 +05:30
|
|
|
|
Create a file in the html_dir tree.
|
|
|
|
|
If the directory does not exist, create it.
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
fname -- filename to be created
|
|
|
|
|
subdir -- any subdirs to be added
|
2008-10-08 01:41:46 +05:30
|
|
|
|
"""
|
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
fname = os.path.join(self.html_dir, subdir, fname)
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
if not _has_webpage_extension(fname):
|
|
|
|
|
fname += self.ext
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
destdir = os.path.dirname(fname)
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
if not os.path.isdir(destdir):
|
|
|
|
|
os.makedirs(destdir)
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
of = codecs.EncodedFile(open(fname, "w"), 'utf-8', self.encoding, 'xmlcharrefreplace')
|
|
|
|
|
return of
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# Closes all file name passed to it
|
|
|
|
|
#
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
def close_file(self, of):
|
|
|
|
|
""" will close whatever filename is passed to it """
|
|
|
|
|
of.close()
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# Beginning of Calendar Creation
|
|
|
|
|
#
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-03-24 20:28:16 +05:30
|
|
|
|
def write_header(self, nr_up, body_id, title, add_print=True):
|
2009-03-21 04:43:06 +05:30
|
|
|
|
"""
|
|
|
|
|
This creates the header for the Calendars
|
|
|
|
|
'nr_up' - number of directory levels up, started from current page, to the
|
|
|
|
|
root of the directory tree (i.e. to self.html_dir).
|
|
|
|
|
title -- to be inserted into page header section
|
|
|
|
|
add_print -- whether to add printer stylesheet or not
|
|
|
|
|
* only webcalendar() and one_day() only!
|
|
|
|
|
"""
|
2009-02-12 16:09:13 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# number of subdirectories up to reach root
|
|
|
|
|
subdirs = '../'*nr_up
|
2009-02-13 01:36:32 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# Header contants
|
2009-04-06 09:19:47 +05:30
|
|
|
|
xmllang = xml_lang()
|
2009-03-21 21:55:47 +05:30
|
|
|
|
_META1 = 'name="generator" content="%s %s %s"' % (const.PROGRAM_NAME, const.VERSION,
|
2009-03-21 04:43:06 +05:30
|
|
|
|
const.URL_HOMEPAGE)
|
2009-03-21 21:55:47 +05:30
|
|
|
|
_META2 = 'name="author" content="%s"' % self.author
|
|
|
|
|
|
2009-04-03 05:34:29 +05:30
|
|
|
|
page, head, body = Html.page(title=title, encoding=self.encoding, lang=xmllang)
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
|
|
|
|
# GRAMPS favicon
|
|
|
|
|
fname1 = '/'.join([subdirs] + ['images'] + ['favicon.ico'])
|
|
|
|
|
|
|
|
|
|
# _CALENDARSCREEN stylesheet
|
|
|
|
|
fname2 = '/'.join([subdirs] + ['styles'] + [_CALENDARSCREEN])
|
|
|
|
|
|
2009-03-21 21:55:47 +05:30
|
|
|
|
# create additional meta tags
|
2009-04-03 05:34:29 +05:30
|
|
|
|
meta = Html('meta', attr = _META1) + (
|
|
|
|
|
Html('meta', attr = _META2,indent=False)
|
2009-03-21 21:55:47 +05:30
|
|
|
|
)
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
2009-03-21 21:55:47 +05:30
|
|
|
|
# links for GRAMPS favicon and stylesheets
|
2009-04-03 05:34:29 +05:30
|
|
|
|
links = Html('link',rel='shortcut icon', href=fname1,type='image/x-icon') + (
|
|
|
|
|
Html('link',rel='stylesheet', href=fname2,type='text/css',media='screen',indent=False)
|
2009-03-21 04:43:06 +05:30
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# add printer stylesheet to webcalendar() and one_day() only
|
|
|
|
|
if add_print:
|
|
|
|
|
fname = '/'.join([subdirs] + ['styles'] + [_CALENDARPRINT])
|
2009-04-03 05:34:29 +05:30
|
|
|
|
links += Html('link',rel='stylesheet', href=fname,type='text/css',media='print',indent=False)
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
2009-03-26 16:47:57 +05:30
|
|
|
|
# add additional meta tags and stylesheet links to head section
|
|
|
|
|
head += (meta, links)
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
2009-03-24 20:28:16 +05:30
|
|
|
|
# replace standard body element with custom one
|
2009-04-03 05:34:29 +05:30
|
|
|
|
body.attr = 'id="%s"' % body_id
|
2009-03-24 20:28:16 +05:30
|
|
|
|
|
|
|
|
|
# start header division section
|
2009-04-03 05:34:29 +05:30
|
|
|
|
headerdiv = Html('div', id="header") + (
|
2009-03-24 20:28:16 +05:30
|
|
|
|
|
|
|
|
|
# page title
|
2009-04-03 05:34:29 +05:30
|
|
|
|
Html('h1', title, id = "SiteTitle",inline=True),
|
2009-03-24 20:28:16 +05:30
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Created for ?
|
|
|
|
|
if self.author:
|
|
|
|
|
if self.email:
|
|
|
|
|
msg = _('Created for <a href="mailto:%(email)s?'
|
|
|
|
|
'subject=WebCal">%(author)s</a>') % {'email' : self.email,
|
|
|
|
|
'author' : self.author}
|
|
|
|
|
else:
|
|
|
|
|
msg = _('Created for %(author)s') % {'author' : self.author}
|
2009-04-03 05:34:29 +05:30
|
|
|
|
headerdiv += Html('p', msg, id="CreatorInfo")
|
2009-03-24 20:28:16 +05:30
|
|
|
|
|
|
|
|
|
# add header division to body
|
2009-04-03 05:34:29 +05:30
|
|
|
|
body += headerdiv
|
2009-03-24 20:28:16 +05:30
|
|
|
|
|
2009-03-26 16:47:57 +05:30
|
|
|
|
# return to its caller; either webcalendar(), year_glance(), or one_day()
|
2009-04-03 05:34:29 +05:30
|
|
|
|
return page, body
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# Creates year navigation, if multiyear
|
|
|
|
|
#
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-03-24 20:28:16 +05:30
|
|
|
|
def year_navigation(self, nr_up, currentsection):
|
2008-07-31 03:07:24 +05:30
|
|
|
|
"""
|
2008-10-08 01:41:46 +05:30
|
|
|
|
This will create the year navigation menu bar
|
2009-02-08 02:11:27 +05:30
|
|
|
|
|
|
|
|
|
nr_up = number of directories up to reach root directory
|
|
|
|
|
currentsection = proper styling of this navigation bar
|
2008-10-08 01:41:46 +05:30
|
|
|
|
"""
|
|
|
|
|
|
2009-02-12 13:26:51 +05:30
|
|
|
|
# creating more than one year
|
|
|
|
|
if not self.multiyear:
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
num_years = (self.end_year - self.start_year)
|
2008-10-08 01:41:46 +05:30
|
|
|
|
cal_year = self.start_year
|
|
|
|
|
|
2009-02-28 17:19:43 +05:30
|
|
|
|
# stylesheets other than "Web_Visually.css" will hold 22 years in a row
|
|
|
|
|
# otherwise, 18 years in a row
|
2009-03-21 04:43:06 +05:30
|
|
|
|
years_in_row = 22 if self.css is not 'Web_Visually.css' else 18
|
2009-02-28 17:19:43 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# figure out number of rows
|
2009-02-28 17:19:43 +05:30
|
|
|
|
nrows = get_num_of_rows(num_years, years_in_row)
|
|
|
|
|
|
|
|
|
|
for rows in range(0, nrows):
|
2009-04-03 05:34:29 +05:30
|
|
|
|
yearnav = Html('div', id="navigation")
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
2009-04-03 05:34:29 +05:30
|
|
|
|
ul = Html('ul')
|
2009-02-28 17:19:43 +05:30
|
|
|
|
cols = 1
|
|
|
|
|
while (cols <= years_in_row and cal_year <= self.end_year):
|
2009-02-12 13:26:51 +05:30
|
|
|
|
url = ''
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-02-12 13:26:51 +05:30
|
|
|
|
# begin subdir level
|
|
|
|
|
subdirs = ['..'] * nr_up
|
|
|
|
|
subdirs.append(str(cal_year))
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-02-12 13:26:51 +05:30
|
|
|
|
# each year will link to current month.
|
|
|
|
|
# this will always need an extension added
|
2009-03-21 04:43:06 +05:30
|
|
|
|
full_month_name = get_full_month_name(self.today.get_month())
|
2008-07-17 18:35:15 +05:30
|
|
|
|
|
2009-02-12 13:26:51 +05:30
|
|
|
|
# Note. We use '/' here because it is a URL, not a OS dependent
|
|
|
|
|
# pathname.
|
|
|
|
|
url = '/'.join(subdirs + [full_month_name]) + self.ext
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-03-21 12:51:24 +05:30
|
|
|
|
# Figure out if we need <li class="CurrentSection"> or just plain <li>
|
2009-03-21 04:43:06 +05:30
|
|
|
|
cs = str(cal_year) == currentsection and 'class="CurrentSection"' or ''
|
2009-04-03 05:34:29 +05:30
|
|
|
|
ul += Html('li', attr=cs ,inline=True) + (
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
2009-03-25 09:24:47 +05:30
|
|
|
|
# create hyperlink
|
2009-04-03 05:34:29 +05:30
|
|
|
|
Html('a', str(cal_year), href = url,inline=True)
|
2009-03-25 09:24:47 +05:30
|
|
|
|
)
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-02-12 13:26:51 +05:30
|
|
|
|
# increase columns
|
|
|
|
|
cols += 1
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-02-12 13:26:51 +05:30
|
|
|
|
# increase calendar year
|
|
|
|
|
cal_year += 1
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# add ul to yearnav
|
|
|
|
|
yearnav += ul
|
|
|
|
|
|
|
|
|
|
# return yearnav to its caller
|
|
|
|
|
return yearnav
|
|
|
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# Creates month navigation for all Calendars
|
|
|
|
|
#
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-03-24 20:28:16 +05:30
|
|
|
|
def month_navigation(self, nr_up, year, currentsection, add_home):
|
2008-10-08 01:41:46 +05:30
|
|
|
|
"""
|
2009-03-21 04:43:06 +05:30
|
|
|
|
Will create and display the navigation menu bar
|
2009-02-08 02:11:27 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
of = calendar filename being created
|
|
|
|
|
nr_up = number of directories up to reach root directory
|
2009-02-08 02:11:27 +05:30
|
|
|
|
year = year being created
|
2009-03-21 04:43:06 +05:30
|
|
|
|
currentsection = month name being created for proper CSS styling
|
|
|
|
|
use_home = if creating a link to home
|
|
|
|
|
-- a link to root directory of website
|
2008-10-08 01:41:46 +05:30
|
|
|
|
"""
|
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
navs = []
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# An optional link to a home page
|
|
|
|
|
navs.append((self.home_link, _('Home'), add_home))
|
2008-12-05 02:08:02 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
for month in range(1, 13):
|
|
|
|
|
navs.append((month, month, True))
|
|
|
|
|
|
|
|
|
|
# Add a link for year_glance() if requested
|
|
|
|
|
navs.append(('fullyearlinked', _('Year Glance'), self.fullyear))
|
|
|
|
|
|
2009-04-03 05:34:29 +05:30
|
|
|
|
monthnav = Html('div', id="subnavigation")
|
|
|
|
|
ul = Html('ul')
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
|
|
|
|
navs = [(u, n) for u, n, c in navs if c]
|
|
|
|
|
for url_fname, nav_text in navs:
|
|
|
|
|
|
|
|
|
|
if type(url_fname) == int:
|
|
|
|
|
url_fname = get_full_month_name(url_fname)
|
|
|
|
|
|
|
|
|
|
if type(nav_text) == int:
|
|
|
|
|
nav_text = get_short_month_name(nav_text)
|
|
|
|
|
|
|
|
|
|
# Note. We use '/' here because it is a URL, not a OS dependent pathname
|
|
|
|
|
# need to leave home link alone, so look for it ...
|
|
|
|
|
url = url_fname
|
|
|
|
|
add_subdirs = True
|
|
|
|
|
if not (url.startswith('http:') or url.startswith('/')):
|
|
|
|
|
for ext in _WEB_EXT:
|
|
|
|
|
if url_fname.endswith(ext):
|
|
|
|
|
add_subdirs = False
|
|
|
|
|
|
|
|
|
|
# whether to add subdirs or not???
|
|
|
|
|
if add_subdirs:
|
2009-03-25 09:24:47 +05:30
|
|
|
|
subdirs = ['..'] * nr_up
|
|
|
|
|
subdirs.append(str(year))
|
2009-03-21 04:43:06 +05:30
|
|
|
|
url = '/'.join(subdirs + [url_fname])
|
|
|
|
|
|
|
|
|
|
if not _has_webpage_extension(url):
|
|
|
|
|
url += self.ext
|
|
|
|
|
|
2009-03-21 12:51:24 +05:30
|
|
|
|
# Figure out if we need <li class="CurrentSection"> or just plain <li>
|
2009-03-21 04:43:06 +05:30
|
|
|
|
cs = url_fname == currentsection and 'class="CurrentSection"' or ''
|
2009-04-03 05:34:29 +05:30
|
|
|
|
ul += Html('li', attr = cs,inline=True) + (
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-03-25 09:24:47 +05:30
|
|
|
|
# create hyperlink
|
2009-04-03 05:34:29 +05:30
|
|
|
|
Html('a', nav_text, href = url,inline=True)
|
2009-03-25 09:24:47 +05:30
|
|
|
|
)
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
|
|
|
|
# add ul to monthnav
|
|
|
|
|
monthnav += ul
|
|
|
|
|
|
|
|
|
|
# return monthnav to its caller
|
|
|
|
|
return monthnav
|
|
|
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# Creates the Calendar Table
|
|
|
|
|
#
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
def calendar_build(self, cal, year, month):
|
2008-07-17 18:35:15 +05:30
|
|
|
|
"""
|
|
|
|
|
This does the work of building the calendar
|
2009-03-21 04:43:06 +05:30
|
|
|
|
'cal' - one of "yg" year_glance(), or "wc" webcalendar()
|
2009-02-11 09:09:52 +05:30
|
|
|
|
'year' -- year being created
|
2008-07-31 03:07:24 +05:30
|
|
|
|
'month' - month number 1, 2, .., 12
|
2008-07-17 18:35:15 +05:30
|
|
|
|
"""
|
|
|
|
|
|
2008-10-08 01:41:46 +05:30
|
|
|
|
# define names for long and short month names
|
2009-02-10 07:08:08 +05:30
|
|
|
|
full_month_name = get_full_month_name(month)
|
|
|
|
|
abbr_month_name = get_short_month_name(month)
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2008-08-08 02:30:05 +05:30
|
|
|
|
# dow (day-of-week) uses Gramps numbering, sunday => 1, etc
|
|
|
|
|
start_dow = self.start_dow
|
|
|
|
|
col2day = [(x-1)%7+1 for x in range(start_dow, start_dow + 7)]
|
|
|
|
|
|
|
|
|
|
def get_class_for_daycol(col):
|
2009-02-10 12:49:56 +05:30
|
|
|
|
""" Translate a Gramps day number into a HTMLclass """
|
2008-08-08 02:30:05 +05:30
|
|
|
|
day = col2day[col]
|
|
|
|
|
if day == 1:
|
2008-08-05 00:38:31 +05:30
|
|
|
|
return "weekend sunday"
|
2008-08-08 02:30:05 +05:30
|
|
|
|
elif day == 7:
|
2008-08-05 00:38:31 +05:30
|
|
|
|
return "weekend saturday"
|
|
|
|
|
return "weekday"
|
|
|
|
|
|
2008-08-08 02:30:05 +05:30
|
|
|
|
def get_name_for_daycol(col):
|
2009-02-10 12:49:56 +05:30
|
|
|
|
""" Translate a Gramps day number into a HTMLclass """
|
2008-08-08 02:30:05 +05:30
|
|
|
|
day = col2day[col]
|
|
|
|
|
return day_names[day]
|
|
|
|
|
|
2009-02-03 13:31:31 +05:30
|
|
|
|
# Note. GrampsLocale has sunday => 1, monday => 2, etc
|
|
|
|
|
# We slice out the first empty element.
|
|
|
|
|
day_names = GrampsLocale.long_days
|
2008-08-08 02:30:05 +05:30
|
|
|
|
|
2009-01-30 07:49:04 +05:30
|
|
|
|
# Begin calendar head. We'll use the capitalized name, because here it
|
|
|
|
|
# seems appropriate for most countries.
|
2009-02-04 06:29:12 +05:30
|
|
|
|
month_name = full_month_name.capitalize()
|
2008-10-08 01:41:46 +05:30
|
|
|
|
th_txt = month_name
|
2009-03-21 04:43:06 +05:30
|
|
|
|
if cal == 'wc': # webcalendar()
|
2008-10-08 01:41:46 +05:30
|
|
|
|
if not self.multiyear:
|
|
|
|
|
th_txt = '%s %d' % (month_name, year)
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
|
|
|
|
# begin calendar table
|
2009-04-03 05:34:29 +05:30
|
|
|
|
cal_table = Html('table', class_='calendar', id = month_name)
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
|
|
|
|
# begin table head, <thead>
|
2009-04-03 05:34:29 +05:30
|
|
|
|
thead = Html('thead')
|
|
|
|
|
tr = Html('tr')
|
|
|
|
|
th = Html('th', th_txt, class_ ='monthName', colspan=7,inline=True)
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
|
|
|
|
# add them together now
|
|
|
|
|
tr += th
|
|
|
|
|
thead += tr
|
2008-07-17 18:35:15 +05:30
|
|
|
|
|
|
|
|
|
# Calendar weekday names header
|
2009-04-03 05:34:29 +05:30
|
|
|
|
weekday_names = Html('tr')
|
2008-08-05 00:38:31 +05:30
|
|
|
|
for day_col in range(7):
|
2008-08-08 02:30:05 +05:30
|
|
|
|
dayclass = get_class_for_daycol(day_col)
|
2008-12-05 02:08:02 +05:30
|
|
|
|
dayname = get_name_for_daycol(day_col)
|
2009-04-03 05:34:29 +05:30
|
|
|
|
th = Html('th', class_ =dayclass,inline=True) + (
|
2009-03-26 16:47:57 +05:30
|
|
|
|
Html('abbr', dayname[0], title=dayname)
|
|
|
|
|
)
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
|
|
|
|
# now add it all together
|
|
|
|
|
weekday_names += th
|
|
|
|
|
|
|
|
|
|
# add weekdays names to table body
|
|
|
|
|
thead += weekday_names
|
|
|
|
|
|
|
|
|
|
# add table row to table head
|
|
|
|
|
cal_table += thead
|
2008-07-17 18:35:15 +05:30
|
|
|
|
|
2008-10-08 01:41:46 +05:30
|
|
|
|
# begin table body
|
2009-04-03 05:34:29 +05:30
|
|
|
|
tbody = Html('tbody')
|
2008-07-31 03:07:24 +05:30
|
|
|
|
|
2009-02-11 09:09:52 +05:30
|
|
|
|
# get first of the month and month information
|
2009-02-08 02:11:27 +05:30
|
|
|
|
current_date, current_ord, monthinfo = get_first_day_of_month(year, month)
|
2008-07-17 18:35:15 +05:30
|
|
|
|
|
2009-03-26 16:47:57 +05:30
|
|
|
|
# begin calendar table rows, starting week0
|
2008-07-31 03:07:24 +05:30
|
|
|
|
nweeks = len(monthinfo)
|
2008-07-17 18:35:15 +05:30
|
|
|
|
for week_row in range(0, nweeks):
|
|
|
|
|
week = monthinfo[week_row]
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
2009-01-27 13:19:47 +05:30
|
|
|
|
# if you look this up in wikipedia, the first week is called week0
|
2009-04-03 05:34:29 +05:30
|
|
|
|
tr = Html('tr', class_ = 'week%d' % week_row)
|
2008-07-31 03:07:24 +05:30
|
|
|
|
|
2009-03-26 16:47:57 +05:30
|
|
|
|
# begin calendar day column
|
2008-08-05 00:38:31 +05:30
|
|
|
|
for day_col in range(0, 7):
|
2008-08-08 02:30:05 +05:30
|
|
|
|
dayclass = get_class_for_daycol(day_col)
|
2008-07-31 03:07:24 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# day number, can also be a zero -- a day before or after month
|
2008-08-05 00:38:31 +05:30
|
|
|
|
day = week[day_col]
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
|
|
|
|
# start the beginning variable for <td>, table cell
|
|
|
|
|
tdid = "%s%02d" % (abbr_month_name, day)
|
|
|
|
|
|
2009-04-03 05:34:29 +05:30
|
|
|
|
# add calendar date division
|
|
|
|
|
datediv = Html('div', day, class_='date',inline=True)
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
2009-03-26 16:47:57 +05:30
|
|
|
|
# a day in the previous or next month
|
|
|
|
|
if day == 0:
|
|
|
|
|
|
|
|
|
|
# day in previous month
|
|
|
|
|
if week_row == 0:
|
2009-02-03 13:31:31 +05:30
|
|
|
|
specday = get_previous_day(year, month, day_col)
|
2008-07-17 18:35:15 +05:30
|
|
|
|
specclass = "previous " + dayclass
|
2009-03-26 16:47:57 +05:30
|
|
|
|
|
|
|
|
|
# a day in the next month
|
|
|
|
|
elif week_row == (nweeks-1):
|
2009-02-03 13:31:31 +05:30
|
|
|
|
specday = get_next_day(year, month, day_col)
|
2008-07-17 18:35:15 +05:30
|
|
|
|
specclass = "next " + dayclass
|
2008-07-31 03:07:24 +05:30
|
|
|
|
|
2009-03-26 16:47:57 +05:30
|
|
|
|
# continue table cell, <td>, without id tag
|
2009-04-03 05:34:29 +05:30
|
|
|
|
td = Html('td', class_ = specclass,inline=True) + (
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
2009-03-26 16:47:57 +05:30
|
|
|
|
# adds date for previous and next month days
|
2009-04-03 05:34:29 +05:30
|
|
|
|
Html('div', specday, class_ = 'date',inline=True)
|
2009-03-26 16:47:57 +05:30
|
|
|
|
)
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
|
|
|
|
# add table cell, <td>, to table row, <tr>
|
|
|
|
|
tr += td
|
2008-07-31 03:07:24 +05:30
|
|
|
|
|
2009-03-26 16:47:57 +05:30
|
|
|
|
# normal day number in current month
|
|
|
|
|
else:
|
2009-01-27 13:19:47 +05:30
|
|
|
|
thisday = datetime.date.fromordinal(current_ord)
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
2009-03-26 16:47:57 +05:30
|
|
|
|
# Something this month
|
|
|
|
|
if thisday.month == month:
|
2009-01-27 13:19:47 +05:30
|
|
|
|
holiday_list = self.holidays.get(month, {}).get(thisday.day, [])
|
|
|
|
|
bday_anniv_list = self.calendar.get(month, {}).get(thisday.day, [])
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
|
|
|
|
# date is an instance because of subtracting abilities in date.py
|
2009-04-06 09:19:47 +05:30
|
|
|
|
event_date = Date()
|
2009-03-21 04:43:06 +05:30
|
|
|
|
event_date.set_yr_mon_day(thisday.year, thisday.month, thisday.day)
|
|
|
|
|
|
|
|
|
|
# get events for this day
|
|
|
|
|
day_list = get_day_list(event_date, holiday_list, bday_anniv_list)
|
|
|
|
|
|
|
|
|
|
# is there something this day?
|
|
|
|
|
if day_list:
|
2009-01-27 13:19:47 +05:30
|
|
|
|
|
|
|
|
|
hilightday = 'highlight ' + dayclass
|
2009-04-03 05:34:29 +05:30
|
|
|
|
td = Html('td', id=tdid, class_ = hilightday)
|
2009-01-27 13:19:47 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# Year at a Glance
|
|
|
|
|
if cal == "yg":
|
2009-01-27 13:19:47 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# make one day pages and hyperlink
|
|
|
|
|
if self.makeoneday:
|
2009-02-03 13:31:31 +05:30
|
|
|
|
|
|
|
|
|
# create yyyymmdd date string for
|
|
|
|
|
# "One Day" calendar page filename
|
2009-03-21 04:43:06 +05:30
|
|
|
|
fname_date = '%04d%02d%02d' % (year,month,day) + self.ext
|
|
|
|
|
|
|
|
|
|
# create hyperlink to one_day()
|
|
|
|
|
fname_date = full_month_name + '/' + fname_date
|
2009-04-03 05:34:29 +05:30
|
|
|
|
ahref = Html('a', datediv, href=fname_date,inline=True)
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
|
|
|
|
# add hyperlink to table cell, <td>
|
|
|
|
|
td += ahref
|
|
|
|
|
|
|
|
|
|
# only year_glance() needs this to create the one_day() pages
|
|
|
|
|
self.one_day(event_date, fname_date, day_list)
|
|
|
|
|
|
|
|
|
|
# just year_glance(), but no one_day() pages
|
2009-02-03 13:31:31 +05:30
|
|
|
|
else:
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-03-26 16:47:57 +05:30
|
|
|
|
# continue table cell, <td>, without id tag
|
2009-04-03 05:34:29 +05:30
|
|
|
|
td = Html('td', class_ = hilightday,inline=True) + (
|
2009-03-26 16:47:57 +05:30
|
|
|
|
|
|
|
|
|
# adds date division
|
2009-04-03 05:34:29 +05:30
|
|
|
|
Html('div', day, class_ = 'date',inline=True)
|
2009-03-26 16:47:57 +05:30
|
|
|
|
)
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
|
|
|
|
# WebCal
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
|
|
# add date to table cell, <td>
|
|
|
|
|
td += datediv
|
|
|
|
|
|
|
|
|
|
# list the events
|
2009-04-03 05:34:29 +05:30
|
|
|
|
ul = Html('ul')
|
2009-03-21 04:43:06 +05:30
|
|
|
|
for nyears, date, text, event in day_list:
|
2009-04-03 05:34:29 +05:30
|
|
|
|
ul += Html('li', text,inline=False if event == 'Anniversary'
|
2009-03-21 04:43:06 +05:30
|
|
|
|
else True)
|
2009-01-27 13:19:47 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# add events to table cell, <td>
|
|
|
|
|
td += ul
|
|
|
|
|
|
|
|
|
|
# no events for this day
|
2008-10-08 01:41:46 +05:30
|
|
|
|
else:
|
2008-07-31 03:07:24 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# create empty day with date
|
2009-04-03 05:34:29 +05:30
|
|
|
|
td = Html('td', class_ = dayclass,inline=True) + (
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
2009-03-26 16:47:57 +05:30
|
|
|
|
# adds date division
|
2009-04-03 05:34:29 +05:30
|
|
|
|
Html('div', day, class_ = 'date',inline=True)
|
2009-03-26 16:47:57 +05:30
|
|
|
|
)
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
|
|
|
|
# nothing for this month
|
|
|
|
|
else:
|
2009-04-03 05:34:29 +05:30
|
|
|
|
td = Html('td', class_ = dayclass) + (
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
2009-03-26 16:47:57 +05:30
|
|
|
|
# adds date division
|
2009-04-03 05:34:29 +05:30
|
|
|
|
Html('div', day, class_ = 'date',inline=True)
|
2009-03-26 16:47:57 +05:30
|
|
|
|
)
|
2009-01-27 13:19:47 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# add table cell, <td>, to table row, <tr>
|
|
|
|
|
# close the day column
|
|
|
|
|
tr += td
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
|
|
|
|
# change day number
|
2008-07-17 18:35:15 +05:30
|
|
|
|
current_ord += 1
|
2008-07-31 03:07:24 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# add table row, <tr>, to table body, <tbody>
|
|
|
|
|
# close the week
|
|
|
|
|
tbody += tr
|
2008-07-17 18:35:15 +05:30
|
|
|
|
|
2009-01-27 13:19:47 +05:30
|
|
|
|
if cal == "yg":
|
2008-12-05 02:08:02 +05:30
|
|
|
|
# Fill up till we have 6 rows, so that the months align properly
|
|
|
|
|
for i in range(nweeks, 6):
|
2009-04-03 05:34:29 +05:30
|
|
|
|
six_weeks = Html('tr', class_ = 'week%d' % (i + 1)) + (
|
2008-12-05 02:08:02 +05:30
|
|
|
|
|
2009-03-26 16:47:57 +05:30
|
|
|
|
# create table cell, <td>
|
2009-04-03 05:34:29 +05:30
|
|
|
|
Html('td', colspan=7,inline=True)
|
2009-03-26 16:47:57 +05:30
|
|
|
|
)
|
2008-07-17 18:35:15 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# add extra weeks to tbody if needed
|
|
|
|
|
tbody += six_weeks
|
2008-07-17 18:35:15 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# close table body
|
|
|
|
|
cal_table += tbody
|
2007-08-27 09:22:06 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# return calendar table to its caller
|
|
|
|
|
return cal_table
|
2008-07-17 18:35:15 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# Creates the Web Calendars; the primary part of this plugin
|
|
|
|
|
#
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
def webcalendar(self, year):
|
2008-07-17 18:35:15 +05:30
|
|
|
|
"""
|
2009-03-21 04:43:06 +05:30
|
|
|
|
This method provides information and header/ footer to the calendar month
|
2008-07-17 18:35:15 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
year -- year being created
|
|
|
|
|
"""
|
2008-12-05 02:08:02 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# do some error correcting if needed
|
|
|
|
|
if self.multiyear:
|
|
|
|
|
if self.end_year < self.start_year:
|
|
|
|
|
self.end_year = self.start_year
|
2008-11-11 03:11:38 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
nr_up = 1 # Number of directory levels up to get to self.html_dir / root
|
2008-07-17 18:35:15 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# generate progress pass for "WebCal"
|
|
|
|
|
self.progress.set_pass(_('Formatting months ...'), 12)
|
2008-11-11 03:11:38 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
for month in range(1, 13):
|
2007-08-27 09:22:06 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# Name the file, and create it
|
|
|
|
|
cal_fname = get_full_month_name(month)
|
|
|
|
|
of = self.create_file(cal_fname, str(year))
|
2009-02-13 01:36:32 +05:30
|
|
|
|
|
2009-03-24 20:28:16 +05:30
|
|
|
|
# Add xml, doctype, meta and stylesheets
|
|
|
|
|
# body has already been added to webcal already once
|
|
|
|
|
webcal, body = self.write_header(nr_up, 'WebCal', self.title_text)
|
2008-07-17 18:35:15 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# create Year Navigation menu
|
|
|
|
|
if self.multiyear:
|
2009-03-24 20:28:16 +05:30
|
|
|
|
body += self.year_navigation(nr_up, str(year))
|
2008-07-30 00:07:29 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# Create Month Navigation Menu
|
|
|
|
|
# identify currentsection for proper highlighting
|
|
|
|
|
currentsection = get_full_month_name(month)
|
2009-03-24 20:28:16 +05:30
|
|
|
|
body += self.month_navigation(nr_up, year, currentsection, True)
|
2009-02-04 07:33:27 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# build the calendar
|
|
|
|
|
monthly_calendar = self.calendar_build("wc", year, month)
|
2009-02-04 07:33:27 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# create note section for webcalendar()
|
|
|
|
|
note = self.month_notes[month-1].strip()
|
|
|
|
|
note = note or " "
|
2008-07-17 18:35:15 +05:30
|
|
|
|
|
2009-03-21 21:55:47 +05:30
|
|
|
|
# table foot section
|
2009-04-03 05:34:29 +05:30
|
|
|
|
cal_note = Html('tfoot')
|
|
|
|
|
tr = Html('tr')
|
|
|
|
|
td = Html('td', note, colspan=7,inline=True)
|
2009-01-27 04:27:25 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# add table cell to table row
|
|
|
|
|
# add table row to table foot section
|
|
|
|
|
tr += td
|
|
|
|
|
cal_note += tr
|
2009-01-27 04:27:25 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# add calendar note to calendar
|
|
|
|
|
monthly_calendar += cal_note
|
2009-01-27 04:27:25 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# add calendar to body
|
|
|
|
|
body += monthly_calendar
|
2009-01-27 04:27:25 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# create blank line for stylesheets
|
2009-04-03 05:34:29 +05:30
|
|
|
|
body += Html('div', class_ = 'fullclear',inline=True)
|
2009-01-27 04:27:25 +05:30
|
|
|
|
|
2009-03-24 20:28:16 +05:30
|
|
|
|
# create footer division section
|
2009-03-21 04:43:06 +05:30
|
|
|
|
footer = self.write_footer(nr_up)
|
2009-01-27 04:27:25 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# add footer to WebCal
|
|
|
|
|
body += footer
|
2009-02-03 13:31:31 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# send calendar page to web output
|
|
|
|
|
mywriter(webcal, of)
|
2009-02-03 13:31:31 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# close the file
|
|
|
|
|
self.close_file(of)
|
2009-01-27 04:27:25 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# increase progress bar
|
|
|
|
|
self.progress.step()
|
2009-01-27 04:27:25 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# Creates Year At A Glance Calendar
|
|
|
|
|
#
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
2008-07-17 18:35:15 +05:30
|
|
|
|
|
2008-10-08 01:41:46 +05:30
|
|
|
|
def year_glance(self, year):
|
2008-07-17 18:35:15 +05:30
|
|
|
|
"""
|
|
|
|
|
This method will create the Full Year At A Glance Page...
|
2009-02-04 07:33:27 +05:30
|
|
|
|
year -- year being created
|
2008-07-17 18:35:15 +05:30
|
|
|
|
"""
|
|
|
|
|
|
2008-11-11 03:11:38 +05:30
|
|
|
|
nr_up = 1 # Number of directory levels up to get to root
|
2008-07-30 00:07:29 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# generate progress pass for "Year At A Glance"
|
|
|
|
|
self.progress.set_pass(_('Creating Year At A Glance calendar'), 12)
|
|
|
|
|
|
2008-07-30 00:07:29 +05:30
|
|
|
|
# Name the file, and create it
|
2009-03-21 04:43:06 +05:30
|
|
|
|
of = self.create_file('fullyearlinked', str(year))
|
2008-07-30 00:07:29 +05:30
|
|
|
|
|
2008-10-08 01:41:46 +05:30
|
|
|
|
# page title
|
2008-11-11 04:17:48 +05:30
|
|
|
|
title = _("%(year)d, At A Glance") % {'year' : year}
|
2008-07-30 00:07:29 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# Create page header
|
2009-03-24 20:28:16 +05:30
|
|
|
|
# body has already been added to yearglance already once
|
|
|
|
|
yearglance, body = self.write_header(nr_up, 'fullyearlinked', title, False)
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
|
|
|
|
# create Year Navigation menu
|
|
|
|
|
if self.multiyear:
|
2009-03-24 20:28:16 +05:30
|
|
|
|
body += self.year_navigation(nr_up, str(year))
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
|
|
|
|
# Create Month Navigation Menu
|
|
|
|
|
# identify currentsection for proper highlighting
|
2009-03-24 20:28:16 +05:30
|
|
|
|
body += self.month_navigation(nr_up, year, 'fullyearlinked', False)
|
2009-02-11 09:09:52 +05:30
|
|
|
|
|
|
|
|
|
msg = (_('This calendar is meant to give you access '
|
2009-03-21 04:43:06 +05:30
|
|
|
|
'to all your data at a glance compressed into one page. Clicking '
|
|
|
|
|
'on a date will take you to a page that shows all the events for '
|
|
|
|
|
'that date, if there are any!\n'))
|
|
|
|
|
|
|
|
|
|
# page description
|
2009-04-03 05:34:29 +05:30
|
|
|
|
descriptdiv = Html('div', class_ = 'content') + (
|
2009-03-17 11:22:43 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# message line
|
2009-04-03 05:34:29 +05:30
|
|
|
|
Html('p', msg, id='description')
|
2009-03-21 04:43:06 +05:30
|
|
|
|
)
|
2008-07-17 18:35:15 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# add description to body
|
|
|
|
|
body += descriptdiv
|
2009-01-27 04:27:25 +05:30
|
|
|
|
|
2009-02-10 07:08:08 +05:30
|
|
|
|
for month in range(1, 13):
|
2008-07-17 18:35:15 +05:30
|
|
|
|
|
|
|
|
|
# build the calendar
|
2009-03-21 04:43:06 +05:30
|
|
|
|
monthly_calendar = self.calendar_build("yg", year, month)
|
2008-07-17 18:35:15 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# add calendar to body
|
|
|
|
|
body += monthly_calendar
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-01-27 04:27:25 +05:30
|
|
|
|
# increase progress bar
|
2008-10-08 01:41:46 +05:30
|
|
|
|
self.progress.step()
|
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# create blank line for stylesheets
|
2009-04-03 05:34:29 +05:30
|
|
|
|
body += Html('div', class_ = 'fullclear',inline=True)
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
|
|
|
|
# write footer section
|
|
|
|
|
footer = self.write_footer(nr_up)
|
|
|
|
|
|
|
|
|
|
# add footer to body
|
|
|
|
|
body += footer
|
|
|
|
|
|
|
|
|
|
# send calendar page to web output
|
|
|
|
|
mywriter(yearglance, of)
|
|
|
|
|
|
|
|
|
|
# close the file
|
2009-02-11 09:09:52 +05:30
|
|
|
|
self.close_file(of)
|
2008-07-17 18:35:15 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# Creates the individual days for year_glance()
|
|
|
|
|
#
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
def one_day(self, event_date, fname_date, day_list):
|
2008-10-08 01:41:46 +05:30
|
|
|
|
"""
|
2009-03-21 04:43:06 +05:30
|
|
|
|
This method creates the One Day page for "Year At A Glance"
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-03-25 09:24:47 +05:30
|
|
|
|
event_date -- date for the listed events
|
2008-07-17 18:35:15 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
fname_date -- filename date from calendar_build()
|
2008-07-17 18:35:15 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
day_list - a combination of both dictionaries to be able to create one day
|
|
|
|
|
nyears, date, text, event --- are necessary for figuring the age or years married
|
|
|
|
|
for each year being created...
|
|
|
|
|
"""
|
2007-08-27 09:22:06 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
nr_up = 2 # number of directory levels up to get to root
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-03-25 09:24:47 +05:30
|
|
|
|
# get year from event_date for use in this section
|
2009-03-21 04:43:06 +05:30
|
|
|
|
year = event_date.get_year()
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-03-25 09:24:47 +05:30
|
|
|
|
# Name the file, and crate it (see code in calendar_build)
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# chose 'od' as I will be opening and closing more than one file
|
|
|
|
|
# at one time
|
|
|
|
|
od = self.create_file(fname_date, str(year))
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# page title
|
|
|
|
|
title = _('One Day Within A Year')
|
2008-07-17 18:35:15 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# create page header
|
2009-03-24 20:28:16 +05:30
|
|
|
|
# body has already been added to oneday already once
|
|
|
|
|
oneday, body = self.write_header(nr_up, 'OneDay', title)
|
2009-02-04 07:33:27 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# create Year Navigation menu
|
2008-10-08 01:41:46 +05:30
|
|
|
|
if self.multiyear:
|
2009-03-24 20:28:16 +05:30
|
|
|
|
body += self.year_navigation(nr_up, str(year))
|
2008-07-30 00:07:29 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# Create Month Navigation Menu
|
|
|
|
|
# identify currentsection for proper highlighting
|
|
|
|
|
# connect it back to year_glance() calendar
|
2009-03-25 09:24:47 +05:30
|
|
|
|
body += self.month_navigation(nr_up, year, 'fullyearlinked', False)
|
2009-01-27 04:27:25 +05:30
|
|
|
|
|
2009-03-25 09:24:47 +05:30
|
|
|
|
# set date display as in user prevferences
|
|
|
|
|
pg_date = _dd.display(event_date)
|
2009-04-03 05:34:29 +05:30
|
|
|
|
body += Html('h3', pg_date,inline=True)
|
2008-07-17 18:35:15 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# list the events
|
2009-04-03 05:34:29 +05:30
|
|
|
|
ol = Html('ol')
|
2009-03-21 04:43:06 +05:30
|
|
|
|
for nyears, date, text, event in day_list:
|
2009-04-03 05:34:29 +05:30
|
|
|
|
ol += Html('li', text,inline=False if event == 'Anniversary'
|
2009-03-21 04:43:06 +05:30
|
|
|
|
else True)
|
2008-07-17 18:35:15 +05:30
|
|
|
|
|
2009-03-25 09:24:47 +05:30
|
|
|
|
# add ordered list to body section
|
2009-03-21 04:43:06 +05:30
|
|
|
|
body += ol
|
2009-02-03 13:31:31 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# create blank line for stylesheets
|
2009-04-03 05:34:29 +05:30
|
|
|
|
body += Html('div', class_ = 'fullclear',inline=True)
|
2008-07-17 18:35:15 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# write footer section
|
|
|
|
|
footer = self.write_footer(nr_up)
|
2008-07-17 18:35:15 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# add footer to WebCal
|
|
|
|
|
body += footer
|
2008-07-17 18:35:15 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# send calendar page to web output
|
|
|
|
|
mywriter(oneday, od)
|
|
|
|
|
|
|
|
|
|
# close the file
|
|
|
|
|
self.close_file(od)
|
|
|
|
|
|
2009-04-06 09:19:47 +05:30
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# Get person's short name
|
|
|
|
|
#
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
def get_name(self, person, maiden_name = None):
|
|
|
|
|
"""
|
|
|
|
|
Return person's name, unless maiden_name given, unless married_name
|
|
|
|
|
listed.
|
|
|
|
|
|
|
|
|
|
person -- person to get short name from
|
|
|
|
|
maiden_name -- either a woman's maiden name or man's surname
|
|
|
|
|
"""
|
|
|
|
|
# Get all of a person's names:
|
|
|
|
|
primary_name = person.primary_name
|
|
|
|
|
married_name = None
|
|
|
|
|
names = [primary_name] + person.get_alternate_names()
|
|
|
|
|
for name in names:
|
|
|
|
|
if int(name.get_type()) == NameType.MARRIED:
|
|
|
|
|
married_name = name
|
|
|
|
|
break # use first
|
|
|
|
|
|
|
|
|
|
# Now, decide which to use:
|
|
|
|
|
if maiden_name is not None:
|
|
|
|
|
if married_name is not None:
|
|
|
|
|
name = Name(married_name)
|
|
|
|
|
else:
|
|
|
|
|
name = Name(primary_name)
|
|
|
|
|
name.set_surname(maiden_name)
|
|
|
|
|
else:
|
|
|
|
|
name = Name(primary_name)
|
|
|
|
|
name.set_display_as(self.name_format)
|
|
|
|
|
return _nd.display_name(name)
|
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# The database slave; Gathers information for calendars
|
|
|
|
|
#
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
2007-08-27 09:22:06 +05:30
|
|
|
|
|
2008-12-11 18:38:37 +05:30
|
|
|
|
def collect_data(self, this_year):
|
2007-08-27 09:22:06 +05:30
|
|
|
|
"""
|
|
|
|
|
This method runs through the data, and collects the relevant dates
|
|
|
|
|
and text.
|
|
|
|
|
"""
|
2008-12-16 03:12:58 +05:30
|
|
|
|
people = self.database.get_person_handles(sort_handles=False)
|
|
|
|
|
self.progress.set_pass(_('Applying Filter...'), len(people))
|
|
|
|
|
people = self.filter.apply(self.database, people, self.progress)
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
|
|
|
|
self.progress.set_pass(_("Reading database..."), len(people))
|
2007-08-27 09:22:06 +05:30
|
|
|
|
for person_handle in people:
|
2008-07-17 18:35:15 +05:30
|
|
|
|
self.progress.step()
|
2007-08-27 09:22:06 +05:30
|
|
|
|
person = self.database.get_person_from_handle(person_handle)
|
2008-10-08 01:41:46 +05:30
|
|
|
|
family_list = person.get_family_handle_list()
|
2007-08-27 09:22:06 +05:30
|
|
|
|
birth_ref = person.get_birth_ref()
|
|
|
|
|
birth_date = None
|
|
|
|
|
if birth_ref:
|
|
|
|
|
birth_event = self.database.get_event_from_handle(birth_ref.ref)
|
|
|
|
|
birth_date = birth_event.get_date_object()
|
2009-01-27 13:19:47 +05:30
|
|
|
|
|
|
|
|
|
# determine birthday information???
|
2009-02-14 06:27:34 +05:30
|
|
|
|
if (self.birthday and birth_date is not None and birth_date.is_valid()):
|
|
|
|
|
|
|
|
|
|
year = birth_date.get_year()
|
|
|
|
|
month = birth_date.get_month()
|
|
|
|
|
day = birth_date.get_day()
|
|
|
|
|
|
2009-04-06 09:19:47 +05:30
|
|
|
|
# date to figure if someone is still alive
|
|
|
|
|
prob_alive_date = Date(this_year, month, day)
|
2009-02-14 06:27:34 +05:30
|
|
|
|
|
|
|
|
|
# add some things to handle maiden name:
|
|
|
|
|
father_surname = None # husband, actually
|
|
|
|
|
sex = person.gender
|
2009-04-06 09:19:47 +05:30
|
|
|
|
if sex == Person.FEMALE:
|
2009-02-14 06:27:34 +05:30
|
|
|
|
|
|
|
|
|
# get husband's last name:
|
|
|
|
|
if self.maiden_name in ['spouse_first', 'spouse_last']:
|
|
|
|
|
if len(family_list) > 0:
|
|
|
|
|
if self.maiden_name == 'spouse_first':
|
|
|
|
|
fhandle = family_list[0]
|
|
|
|
|
else:
|
|
|
|
|
fhandle = family_list[-1]
|
|
|
|
|
fam = self.database.get_family_from_handle(fhandle)
|
|
|
|
|
father_handle = fam.get_father_handle()
|
|
|
|
|
mother_handle = fam.get_mother_handle()
|
|
|
|
|
if mother_handle == person_handle:
|
|
|
|
|
if father_handle:
|
|
|
|
|
father = self.database.get_person_from_handle(father_handle)
|
2009-02-24 08:22:06 +05:30
|
|
|
|
if father is not None:
|
2009-02-14 06:27:34 +05:30
|
|
|
|
father_name = father.primary_name
|
|
|
|
|
father_surname = _get_regular_surname(sex, father_name)
|
2009-04-06 09:19:47 +05:30
|
|
|
|
short_name = self.get_name(person, father_surname)
|
2009-02-14 06:27:34 +05:30
|
|
|
|
alive = probably_alive(person, self.database, prob_alive_date)
|
|
|
|
|
if (self.alive and alive) or not self.alive:
|
2008-10-08 01:41:46 +05:30
|
|
|
|
text = _('%(short_name)s') % {'short_name' : short_name}
|
2009-02-14 06:27:34 +05:30
|
|
|
|
self.add_day_item(text, year, month, day, 'Birthday')
|
2009-01-27 13:19:47 +05:30
|
|
|
|
|
|
|
|
|
# add anniversary if requested
|
|
|
|
|
if self.anniv:
|
|
|
|
|
for fhandle in family_list:
|
|
|
|
|
fam = self.database.get_family_from_handle(fhandle)
|
|
|
|
|
father_handle = fam.get_father_handle()
|
|
|
|
|
mother_handle = fam.get_mother_handle()
|
2009-02-08 02:11:27 +05:30
|
|
|
|
if father_handle == person.handle:
|
2009-01-27 13:19:47 +05:30
|
|
|
|
spouse_handle = mother_handle
|
|
|
|
|
else:
|
|
|
|
|
continue # with next person if this was the marriage event
|
|
|
|
|
if spouse_handle:
|
|
|
|
|
spouse = self.database.get_person_from_handle(spouse_handle)
|
|
|
|
|
if spouse:
|
2009-04-06 09:19:47 +05:30
|
|
|
|
spouse_name = self.get_name(spouse)
|
|
|
|
|
short_name = self.get_name(person)
|
2009-01-27 13:19:47 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# will return a marriage event or False if not married any longer
|
2009-03-17 05:02:47 +05:30
|
|
|
|
marriage_event = get_marriage_event(self.database, fam)
|
|
|
|
|
if marriage_event:
|
|
|
|
|
event_obj = marriage_event.get_date_object()
|
2009-02-24 08:22:06 +05:30
|
|
|
|
year = event_obj.get_year()
|
|
|
|
|
month = event_obj.get_month()
|
|
|
|
|
day = event_obj.get_day()
|
2009-01-27 13:19:47 +05:30
|
|
|
|
|
2009-04-06 09:19:47 +05:30
|
|
|
|
# date to figure if someone is still alive
|
|
|
|
|
prob_alive_date = Date(this_year, month, day)
|
2009-02-04 11:05:34 +05:30
|
|
|
|
|
2009-02-24 08:22:06 +05:30
|
|
|
|
if event_obj.is_valid():
|
|
|
|
|
text = _('%(spouse)s and %(person)s') % {
|
|
|
|
|
'spouse' : spouse_name,
|
|
|
|
|
'person' : short_name}
|
2009-01-27 13:19:47 +05:30
|
|
|
|
|
2009-02-24 08:22:06 +05:30
|
|
|
|
alive1 = probably_alive(person, self.database, prob_alive_date)
|
|
|
|
|
alive2 = probably_alive(spouse, self.database, prob_alive_date)
|
|
|
|
|
if ((self.alive and alive1 and alive2) or not self.alive):
|
|
|
|
|
self.add_day_item(text, year, month, day, 'Anniversary')
|
2007-08-27 09:22:06 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# ---------------------------------------------------------------------------------------
|
2007-08-27 09:22:06 +05:30
|
|
|
|
#
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# Closes the Calendars; the end
|
2007-08-27 09:22:06 +05:30
|
|
|
|
#
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
def write_footer(self, nr_up):
|
|
|
|
|
"""
|
|
|
|
|
Writes the footer section of the pages
|
|
|
|
|
'nr_up' - number of directory levels up, started from current page, to the
|
|
|
|
|
root of the directory tree (i.e. to self.html_dir).
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
# begin calendar footer
|
2009-04-03 05:34:29 +05:30
|
|
|
|
footer = Html('div', id = 'footer')
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
|
|
|
|
# Display date as user set in preferences
|
|
|
|
|
msg = _('Generated by <a href="http://gramps-project.org">'
|
2009-04-06 09:19:47 +05:30
|
|
|
|
'GRAMPS</a> on %(date)s') % {'date' : _dd.display(date.Today())}
|
2009-04-03 05:34:29 +05:30
|
|
|
|
p = Html('p', msg, id = 'createdate')
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
|
|
|
|
# add Generated by? to footer
|
|
|
|
|
footer += p
|
|
|
|
|
|
|
|
|
|
copy_nr = self.copy
|
|
|
|
|
text = ''
|
|
|
|
|
if copy_nr == 0:
|
|
|
|
|
if self.author:
|
|
|
|
|
text = "© %s %s" % (self.today.get_year(), self.author)
|
|
|
|
|
elif 0 < copy_nr < len(_CC):
|
|
|
|
|
subdirs = ['..'] * nr_up
|
|
|
|
|
# Note. We use '/' here because it is a URL, not a OS dependent pathname
|
|
|
|
|
fname = '/'.join(subdirs + ['images'] + ['somerights20.gif'])
|
|
|
|
|
text = _CC[copy_nr] % {'gif_fname' : fname}
|
|
|
|
|
else:
|
|
|
|
|
text = "© %s %s" % (self.today.get_year(), self.author)
|
|
|
|
|
|
2009-04-03 05:34:29 +05:30
|
|
|
|
p = Html('p', text, id = 'copyright')
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
|
|
|
|
# add copyright to footer
|
|
|
|
|
footer += p
|
|
|
|
|
|
|
|
|
|
# return footer to its caller
|
|
|
|
|
return footer
|
|
|
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# The work horse of this plugin; stages everything
|
|
|
|
|
#
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
def write_report(self):
|
|
|
|
|
"""
|
|
|
|
|
The short method that runs through each month and creates a page.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
# Create progress meter bar
|
2009-04-06 09:19:47 +05:30
|
|
|
|
self.progress = ProgressMeter(_("Web Calendar Report"), '')
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
|
|
|
|
# get data from database for birthdays/ anniversaries
|
|
|
|
|
self.collect_data(self.start_year)
|
|
|
|
|
|
|
|
|
|
# Copy all files for the calendars being created
|
|
|
|
|
self.copy_calendar_files()
|
|
|
|
|
|
|
|
|
|
if self.multiyear:
|
|
|
|
|
for cal_year in range(self.start_year, (self.end_year + 1)):
|
|
|
|
|
|
|
|
|
|
# initialize the holidays dict to fill:
|
|
|
|
|
self.holidays = {}
|
|
|
|
|
|
|
|
|
|
# get the information, zero is equal to None
|
2009-04-06 09:19:47 +05:30
|
|
|
|
print self.country
|
2009-03-21 04:43:06 +05:30
|
|
|
|
if self.country != 0:
|
|
|
|
|
self.__get_holidays(cal_year)
|
|
|
|
|
|
|
|
|
|
# create webcalendar() calendar pages
|
|
|
|
|
self.webcalendar(cal_year)
|
|
|
|
|
|
|
|
|
|
# create "Year At A Glance" and
|
|
|
|
|
# "One Day" calendar pages
|
|
|
|
|
if self.fullyear:
|
|
|
|
|
self.year_glance(cal_year)
|
|
|
|
|
|
|
|
|
|
# a single year
|
|
|
|
|
else:
|
|
|
|
|
cal_year = self.start_year
|
|
|
|
|
|
|
|
|
|
self.holidays = {}
|
|
|
|
|
|
|
|
|
|
# get the information, first from holidays:
|
|
|
|
|
if self.country != 0:
|
|
|
|
|
self.__get_holidays(cal_year)
|
|
|
|
|
|
|
|
|
|
# create webcalendar() calendar pages
|
|
|
|
|
self.webcalendar(cal_year)
|
|
|
|
|
|
|
|
|
|
# create "Year At A Glance" and
|
|
|
|
|
# "One Day" calendar pages
|
|
|
|
|
if self.fullyear:
|
|
|
|
|
self.year_glance(cal_year)
|
|
|
|
|
|
|
|
|
|
# Close the progress meter
|
|
|
|
|
self.progress.close()
|
|
|
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# WebCalOptions; Creates the Menu
|
|
|
|
|
#
|
|
|
|
|
#----------------------------------------------------------------------------------------
|
2008-02-10 09:39:09 +05:30
|
|
|
|
class WebCalOptions(MenuReportOptions):
|
2007-08-27 09:22:06 +05:30
|
|
|
|
"""
|
|
|
|
|
Defines options and provides handling interface.
|
|
|
|
|
"""
|
2008-07-17 20:18:54 +05:30
|
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
|
def __init__(self, name, dbase):
|
|
|
|
|
self.__db = dbase
|
|
|
|
|
self.__pid = None
|
|
|
|
|
self.__filter = None
|
|
|
|
|
MenuReportOptions.__init__(self, name, dbase)
|
2007-08-27 09:22:06 +05:30
|
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
|
def add_menu_options(self, menu):
|
|
|
|
|
"""
|
|
|
|
|
Add options to the menu for the web calendar.
|
|
|
|
|
"""
|
|
|
|
|
self.__add_report_options(menu)
|
|
|
|
|
self.__add_content_options(menu)
|
|
|
|
|
self.__add_notes_options(menu)
|
2009-03-21 04:43:06 +05:30
|
|
|
|
self.__add_advanced_options(menu)
|
2008-07-17 20:18:54 +05:30
|
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
|
def __add_report_options(self, menu):
|
|
|
|
|
"""
|
|
|
|
|
Options on the "Report Options" tab.
|
|
|
|
|
"""
|
|
|
|
|
category_name = _("Report Options")
|
2008-07-17 20:18:54 +05:30
|
|
|
|
|
|
|
|
|
target = DestinationOption( _("Destination"),
|
|
|
|
|
os.path.join(const.USER_HOME, "WEBCAL"))
|
2008-02-10 09:39:09 +05:30
|
|
|
|
target.set_help( _("The destination directory for the web files"))
|
|
|
|
|
target.set_directory_entry(True)
|
|
|
|
|
menu.add_option(category_name, "target", target)
|
2008-07-17 20:18:54 +05:30
|
|
|
|
|
|
|
|
|
title = StringOption(_('Calendar Title'), _('My Family Calendar'))
|
2008-07-17 18:35:15 +05:30
|
|
|
|
title.set_help(_("The title of the calendar"))
|
|
|
|
|
menu.add_option(category_name, "title", title)
|
2008-07-17 20:18:54 +05:30
|
|
|
|
|
2008-07-17 18:35:15 +05:30
|
|
|
|
self.__filter = FilterOption(_("Filter"), 0)
|
|
|
|
|
self.__filter.set_help(
|
|
|
|
|
_("Select filter to restrict people that appear on calendar"))
|
|
|
|
|
menu.add_option(category_name, "filter", self.__filter)
|
|
|
|
|
self.__filter.connect('value-changed', self.__filter_changed)
|
2008-07-17 20:18:54 +05:30
|
|
|
|
|
2008-07-17 18:35:15 +05:30
|
|
|
|
self.__pid = PersonOption(_("Filter Person"))
|
|
|
|
|
self.__pid.set_help(_("The center person for the filter"))
|
|
|
|
|
menu.add_option(category_name, "pid", self.__pid)
|
|
|
|
|
self.__pid.connect('value-changed', self.__update_filters)
|
2008-07-17 20:18:54 +05:30
|
|
|
|
|
2008-07-17 18:35:15 +05:30
|
|
|
|
self.__update_filters()
|
|
|
|
|
|
2009-04-06 09:19:47 +05:30
|
|
|
|
# We must figure out the value of the first option before we can
|
|
|
|
|
# create the EnumeratedListOption
|
|
|
|
|
fmt_list = _nd.get_name_format()
|
|
|
|
|
name_format = EnumeratedListOption(_("Name format"), fmt_list[0][0])
|
|
|
|
|
for num, name, fmt_str, act in fmt_list:
|
|
|
|
|
name_format.add_item(num, name)
|
|
|
|
|
name_format.set_help(_("Select the format to display names"))
|
|
|
|
|
menu.add_option(category_name, "name_format", name_format)
|
|
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
|
ext = EnumeratedListOption(_("File extension"), ".html" )
|
|
|
|
|
for etype in ['.html', '.htm', '.shtml', '.php', '.php3', '.cgi']:
|
|
|
|
|
ext.add_item(etype, etype)
|
|
|
|
|
ext.set_help( _("The extension to be used for the web files"))
|
|
|
|
|
menu.add_option(category_name, "ext", ext)
|
2008-07-17 20:18:54 +05:30
|
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
|
cright = EnumeratedListOption(_('Copyright'), 0 )
|
2008-08-08 02:30:05 +05:30
|
|
|
|
for index, copt in enumerate(_COPY_OPTIONS):
|
2008-02-10 09:39:09 +05:30
|
|
|
|
cright.add_item(index, copt)
|
|
|
|
|
cright.set_help( _("The copyright to be used for the web files"))
|
|
|
|
|
menu.add_option(category_name, "cright", cright)
|
2008-07-17 20:18:54 +05:30
|
|
|
|
|
2009-03-24 20:28:16 +05:30
|
|
|
|
css = EnumeratedListOption(_('StyleSheet'), _CSS_FILES[0][1])
|
2008-07-17 18:35:15 +05:30
|
|
|
|
for style in _CSS_FILES:
|
|
|
|
|
css.add_item(style[1], style[0])
|
2009-03-24 20:28:16 +05:30
|
|
|
|
css.set_help( _('The Style Sheet to be used for the web page'))
|
2008-07-17 18:35:15 +05:30
|
|
|
|
menu.add_option(category_name, "css", css)
|
2008-07-17 20:18:54 +05:30
|
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
|
def __add_content_options(self, menu):
|
|
|
|
|
"""
|
|
|
|
|
Options on the "Content Options" tab.
|
|
|
|
|
"""
|
|
|
|
|
category_name = _("Content Options")
|
2008-07-17 20:18:54 +05:30
|
|
|
|
|
2008-10-08 01:41:46 +05:30
|
|
|
|
# set to today's date for use in menu, etc.
|
2009-04-06 09:19:47 +05:30
|
|
|
|
today = date.Today()
|
2009-03-26 16:47:57 +05:30
|
|
|
|
|
|
|
|
|
self.__multiyear = BooleanOption(_('Create multiple year calendars'), False)
|
|
|
|
|
self.__multiyear.set_help(_('Whether to create Multiple year calendars or not.'))
|
2008-10-08 01:41:46 +05:30
|
|
|
|
menu.add_option(category_name, 'multiyear', self.__multiyear)
|
|
|
|
|
self.__multiyear.connect('value-changed', self.__multiyear_changed)
|
2008-02-10 09:39:09 +05:30
|
|
|
|
|
2009-03-26 16:47:57 +05:30
|
|
|
|
self.__start_year = NumberOption(_('Start Year for the Calendar(s)'), today.get_year(),
|
|
|
|
|
1900, 3000)
|
2009-02-10 12:49:56 +05:30
|
|
|
|
self.__start_year.set_help(_('Enter the starting year for the calendars '
|
|
|
|
|
'between 1900 - 3000'))
|
2008-10-08 01:41:46 +05:30
|
|
|
|
menu.add_option(category_name, 'start_year', self.__start_year)
|
|
|
|
|
|
2009-03-26 16:47:57 +05:30
|
|
|
|
self.__end_year = NumberOption(_('End Year for the Calendar(s)'), today.get_year(),
|
|
|
|
|
1900, 3000)
|
2009-02-10 12:49:56 +05:30
|
|
|
|
self.__end_year.set_help(_('Enter the ending year for the calendars '
|
2009-03-26 16:47:57 +05:30
|
|
|
|
'between 1900 - 3000.'))
|
2008-10-08 01:41:46 +05:30
|
|
|
|
menu.add_option(category_name, 'end_year', self.__end_year)
|
|
|
|
|
|
|
|
|
|
self.__multiyear_changed()
|
|
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
|
country = EnumeratedListOption(_('Country for holidays'), 0 )
|
2009-01-30 07:49:04 +05:30
|
|
|
|
holiday_table = libholiday.HolidayTable()
|
|
|
|
|
for index, item in enumerate(holiday_table.get_countries()):
|
2008-02-10 09:39:09 +05:30
|
|
|
|
country.add_item(index, item)
|
2008-10-08 01:41:46 +05:30
|
|
|
|
country.set_help(_("Holidays will be included for the selected "
|
2008-02-10 09:39:09 +05:30
|
|
|
|
"country"))
|
|
|
|
|
menu.add_option(category_name, "country", country)
|
|
|
|
|
|
2008-10-08 01:41:46 +05:30
|
|
|
|
maiden_name = EnumeratedListOption(_("Birthday surname"), "own")
|
2009-02-10 12:49:56 +05:30
|
|
|
|
maiden_name.add_item('spouse_first', _("Wives use husband's surname "
|
|
|
|
|
"(from first family listed)"))
|
|
|
|
|
maiden_name.add_item('spouse_last', _("Wives use husband's surname "
|
|
|
|
|
"(from last family listed)"))
|
2008-10-08 01:41:46 +05:30
|
|
|
|
maiden_name.add_item("own", _("Wives use their own surname"))
|
|
|
|
|
maiden_name.set_help(_("Select married women's displayed surname"))
|
|
|
|
|
menu.add_option(category_name, "maiden_name", maiden_name)
|
|
|
|
|
|
2008-08-08 02:30:05 +05:30
|
|
|
|
# Default selection ????
|
|
|
|
|
start_dow = EnumeratedListOption(_("First day of week"), 1)
|
|
|
|
|
for count in range(1, 8):
|
|
|
|
|
start_dow.add_item(count, GrampsLocale.long_days[count].capitalize())
|
|
|
|
|
start_dow.set_help(_("Select the first day of the week for the calendar"))
|
|
|
|
|
menu.add_option(category_name, "start_dow", start_dow)
|
|
|
|
|
|
2008-07-17 20:18:54 +05:30
|
|
|
|
home_link = StringOption(_('Home link'), '../index.html')
|
2008-07-17 18:35:15 +05:30
|
|
|
|
home_link.set_help(_("The link to be included to direct the user to "
|
|
|
|
|
"the main page of the web site"))
|
|
|
|
|
menu.add_option(category_name, "home_link", home_link)
|
2008-07-17 20:18:54 +05:30
|
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
|
alive = BooleanOption(_("Include only living people"), True)
|
|
|
|
|
alive.set_help(_("Include only living people in the calendar"))
|
|
|
|
|
menu.add_option(category_name, "alive", alive)
|
|
|
|
|
|
|
|
|
|
birthdays = BooleanOption(_("Include birthdays"), True)
|
|
|
|
|
birthdays.set_help(_("Include birthdays in the calendar"))
|
|
|
|
|
menu.add_option(category_name, "birthdays", birthdays)
|
|
|
|
|
|
|
|
|
|
anniversaries = BooleanOption(_("Include anniversaries"), True)
|
|
|
|
|
anniversaries.set_help(_("Include anniversaries in the calendar"))
|
|
|
|
|
menu.add_option(category_name, "anniversaries", anniversaries)
|
2008-07-17 20:18:54 +05:30
|
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
|
def __add_notes_options(self, menu):
|
|
|
|
|
"""
|
|
|
|
|
Options on the "Months Notes" tabs.
|
|
|
|
|
"""
|
2008-07-17 18:35:15 +05:30
|
|
|
|
category_name = _("Jan - Jun Notes")
|
2007-08-27 09:22:06 +05:30
|
|
|
|
|
2008-07-17 20:18:54 +05:30
|
|
|
|
note_jan = StringOption(_('Jan Note'), _('This prints in January'))
|
2008-02-10 09:39:09 +05:30
|
|
|
|
note_jan.set_help(_("The note for the month of January"))
|
|
|
|
|
menu.add_option(category_name, "note_jan", note_jan)
|
2008-07-17 20:18:54 +05:30
|
|
|
|
|
|
|
|
|
note_feb = StringOption(_('Feb Note'), _('This prints in February'))
|
2008-02-10 09:39:09 +05:30
|
|
|
|
note_feb.set_help(_("The note for the month of February"))
|
|
|
|
|
menu.add_option(category_name, "note_feb", note_feb)
|
2008-07-17 20:18:54 +05:30
|
|
|
|
|
|
|
|
|
note_mar = StringOption(_('Mar Note'), _('This prints in March'))
|
2008-02-10 09:39:09 +05:30
|
|
|
|
note_mar.set_help(_("The note for the month of March"))
|
|
|
|
|
menu.add_option(category_name, "note_mar", note_mar)
|
2008-07-17 20:18:54 +05:30
|
|
|
|
|
|
|
|
|
note_apr = StringOption(_('Apr Note'), _('This prints in April'))
|
2008-02-10 09:39:09 +05:30
|
|
|
|
note_apr.set_help(_("The note for the month of April"))
|
|
|
|
|
menu.add_option(category_name, "note_apr", note_apr)
|
2008-07-17 20:18:54 +05:30
|
|
|
|
|
|
|
|
|
note_may = StringOption(_('May Note'), _('This prints in May'))
|
2008-02-10 09:39:09 +05:30
|
|
|
|
note_may.set_help(_("The note for the month of May"))
|
|
|
|
|
menu.add_option(category_name, "note_may", note_may)
|
2008-07-17 20:18:54 +05:30
|
|
|
|
|
|
|
|
|
note_jun = StringOption(_('Jun Note'), _('This prints in June'))
|
2008-02-10 09:39:09 +05:30
|
|
|
|
note_jun.set_help(_("The note for the month of June"))
|
|
|
|
|
menu.add_option(category_name, "note_jun", note_jun)
|
2008-07-17 20:18:54 +05:30
|
|
|
|
|
2008-07-17 18:35:15 +05:30
|
|
|
|
category_name = _("Jul - Dec Notes")
|
2007-08-27 09:22:06 +05:30
|
|
|
|
|
2008-07-17 20:18:54 +05:30
|
|
|
|
note_jul = StringOption(_('Jul Note'), _('This prints in July'))
|
2008-02-10 09:39:09 +05:30
|
|
|
|
note_jul.set_help(_("The note for the month of July"))
|
|
|
|
|
menu.add_option(category_name, "note_jul", note_jul)
|
2008-07-17 20:18:54 +05:30
|
|
|
|
|
|
|
|
|
note_aug = StringOption(_('Aug Note'), _('This prints in August'))
|
2008-02-10 09:39:09 +05:30
|
|
|
|
note_aug.set_help(_("The note for the month of August"))
|
|
|
|
|
menu.add_option(category_name, "note_aug", note_aug)
|
2008-07-17 20:18:54 +05:30
|
|
|
|
|
|
|
|
|
note_sep = StringOption(_('Sep Note'), _('This prints in September'))
|
2008-02-10 09:39:09 +05:30
|
|
|
|
note_sep.set_help(_("The note for the month of September"))
|
|
|
|
|
menu.add_option(category_name, "note_sep", note_sep)
|
2008-07-17 20:18:54 +05:30
|
|
|
|
|
|
|
|
|
note_oct = StringOption(_('Oct Note'), _('This prints in October'))
|
2008-02-10 09:39:09 +05:30
|
|
|
|
note_oct.set_help(_("The note for the month of October"))
|
|
|
|
|
menu.add_option(category_name, "note_oct", note_oct)
|
2008-07-17 20:18:54 +05:30
|
|
|
|
|
|
|
|
|
note_nov = StringOption(_('Nov Note'), _('This prints in November'))
|
2008-02-10 09:39:09 +05:30
|
|
|
|
note_nov.set_help(_("The note for the month of November"))
|
|
|
|
|
menu.add_option(category_name, "note_nov", note_nov)
|
2008-07-17 20:18:54 +05:30
|
|
|
|
|
|
|
|
|
note_dec = StringOption(_('Dec Note'), _('This prints in December'))
|
2008-02-10 09:39:09 +05:30
|
|
|
|
note_dec.set_help(_("The note for the month of December"))
|
|
|
|
|
menu.add_option(category_name, "note_dec", note_dec)
|
2007-08-27 09:22:06 +05:30
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
def __add_advanced_options(self, menu):
|
|
|
|
|
"""
|
|
|
|
|
Options for the advanced menu
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
category_name = _('Advanced Options')
|
|
|
|
|
|
2009-03-24 20:28:16 +05:30
|
|
|
|
encoding = EnumeratedListOption(_('Character set encoding'), _CHARACTER_SETS[0][1])
|
2009-03-21 04:43:06 +05:30
|
|
|
|
for eopt in _CHARACTER_SETS:
|
|
|
|
|
encoding.add_item(eopt[1], eopt[0])
|
2009-03-24 20:28:16 +05:30
|
|
|
|
encoding.set_help( _('The encoding to be used for the web files'))
|
2009-03-21 04:43:06 +05:30
|
|
|
|
menu.add_option(category_name, "encoding", encoding)
|
|
|
|
|
|
2009-03-24 20:28:16 +05:30
|
|
|
|
fullyear = BooleanOption(_('Create "Year At A Glance" Calendar'), False)
|
2009-03-21 04:43:06 +05:30
|
|
|
|
fullyear.set_help(_('Whether to create A one-page mini calendar '
|
|
|
|
|
'with dates highlighted'))
|
|
|
|
|
menu.add_option(category_name, 'fullyear', fullyear)
|
|
|
|
|
|
|
|
|
|
makeoneday = BooleanOption(_('Create one day event pages for'
|
2009-04-03 05:34:29 +05:30
|
|
|
|
' Year At A Glance calendar'), False)
|
2009-03-21 04:43:06 +05:30
|
|
|
|
makeoneday.set_help(_('Whether to create one day pages or not'))
|
|
|
|
|
menu.add_option(category_name, 'makeoneday', makeoneday)
|
|
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
|
def __update_filters(self):
|
|
|
|
|
"""
|
|
|
|
|
Update the filter list based on the selected person
|
|
|
|
|
"""
|
|
|
|
|
gid = self.__pid.get_value()
|
|
|
|
|
person = self.__db.get_person_from_gramps_id(gid)
|
|
|
|
|
filter_list = ReportUtils.get_person_filters(person, False)
|
|
|
|
|
self.__filter.set_filters(filter_list)
|
2008-07-17 20:18:54 +05:30
|
|
|
|
|
2008-02-10 09:39:09 +05:30
|
|
|
|
def __filter_changed(self):
|
|
|
|
|
"""
|
|
|
|
|
Handle filter change. If the filter is not specific to a person,
|
|
|
|
|
disable the person option
|
|
|
|
|
"""
|
|
|
|
|
filter_value = self.__filter.get_value()
|
|
|
|
|
if filter_value in [1, 2, 3, 4]:
|
|
|
|
|
# Filters 1, 2, 3 and 4 rely on the center person
|
|
|
|
|
self.__pid.set_available(True)
|
2007-08-27 09:22:06 +05:30
|
|
|
|
else:
|
2008-02-10 09:39:09 +05:30
|
|
|
|
# The rest don't
|
|
|
|
|
self.__pid.set_available(False)
|
|
|
|
|
|
2008-10-08 01:41:46 +05:30
|
|
|
|
def __multiyear_changed(self):
|
|
|
|
|
"""
|
|
|
|
|
Handles the ability to print multiple year calendars or not?
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
self.__start_year.set_available(True)
|
|
|
|
|
if self.__multiyear.get_value():
|
|
|
|
|
self.__end_year.set_available(True)
|
|
|
|
|
else:
|
|
|
|
|
self.__end_year.set_available(False)
|
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# # Web Page Fortmatter and writer
|
|
|
|
|
#
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
def mywriter(page, of):
|
|
|
|
|
"""
|
|
|
|
|
This function is simply to make the web page look pretty and readable
|
|
|
|
|
It is not for the browser, but for us, humans
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
page.write(lambda line: of.write(line + '\n'))
|
|
|
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# Support Functions for this plugin
|
|
|
|
|
#
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
|
2009-04-06 09:19:47 +05:30
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# Support Functions for this plugin
|
|
|
|
|
#
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
2008-10-08 01:41:46 +05:30
|
|
|
|
def _get_regular_surname(sex, name):
|
2008-08-05 01:01:38 +05:30
|
|
|
|
"""
|
2009-02-08 02:11:27 +05:30
|
|
|
|
Returns a name string built from the components of the Name instance.
|
2008-08-05 01:01:38 +05:30
|
|
|
|
"""
|
2009-02-08 02:11:27 +05:30
|
|
|
|
|
2009-02-27 00:46:02 +05:30
|
|
|
|
surname = name.get_surname()
|
2008-08-05 01:01:38 +05:30
|
|
|
|
prefix = name.get_surname_prefix()
|
|
|
|
|
if prefix:
|
|
|
|
|
surname = prefix + " " + surname
|
2009-04-06 09:19:47 +05:30
|
|
|
|
if sex is not Person.FEMALE:
|
2008-10-08 01:41:46 +05:30
|
|
|
|
suffix = name.get_suffix()
|
|
|
|
|
if suffix:
|
|
|
|
|
surname = surname + ", " + suffix
|
2008-08-05 01:01:38 +05:30
|
|
|
|
return surname
|
|
|
|
|
|
2009-02-10 12:49:56 +05:30
|
|
|
|
# Simple utility list to convert Gramps day-of-week numbering
|
|
|
|
|
# to calendar.firstweekday numbering
|
2009-02-28 06:05:30 +05:30
|
|
|
|
dow_gramps2iso = [ -1, calendar.SUNDAY, calendar.MONDAY, calendar.TUESDAY,
|
|
|
|
|
calendar.WEDNESDAY, calendar.THURSDAY, calendar.FRIDAY,
|
|
|
|
|
calendar.SATURDAY]
|
2008-08-08 02:30:05 +05:30
|
|
|
|
|
2009-02-08 02:11:27 +05:30
|
|
|
|
# define names for full and abbreviated month names in GrampsLocale
|
2009-02-10 12:49:56 +05:30
|
|
|
|
full_month_name = GrampsLocale.long_months
|
|
|
|
|
abbr_month_name = GrampsLocale.short_months
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-02-10 07:08:08 +05:30
|
|
|
|
def get_full_month_name(month):
|
|
|
|
|
""" returns full or long month name """
|
2009-02-10 12:49:56 +05:30
|
|
|
|
return full_month_name[month]
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-02-10 07:08:08 +05:30
|
|
|
|
def get_short_month_name(month):
|
|
|
|
|
""" return short or abbreviated month name """
|
2009-02-10 12:49:56 +05:30
|
|
|
|
return abbr_month_name[month]
|
2008-10-08 01:41:46 +05:30
|
|
|
|
|
2009-02-24 08:22:06 +05:30
|
|
|
|
def get_marriage_event(db, family):
|
2009-01-27 13:19:47 +05:30
|
|
|
|
"""
|
2009-02-24 08:22:06 +05:30
|
|
|
|
are_married will either be the marriage event or None
|
2009-01-27 13:19:47 +05:30
|
|
|
|
"""
|
|
|
|
|
|
2009-03-17 05:02:47 +05:30
|
|
|
|
marriage_event = False
|
2009-01-27 13:19:47 +05:30
|
|
|
|
for event_ref in family.get_event_ref_list():
|
|
|
|
|
event = db.get_event_from_handle(event_ref.ref)
|
2009-04-06 09:19:47 +05:30
|
|
|
|
if event.type in [EventType.MARRIAGE,
|
|
|
|
|
EventType.MARR_ALT]:
|
2009-03-17 05:02:47 +05:30
|
|
|
|
marriage_event = event
|
2009-04-06 09:19:47 +05:30
|
|
|
|
elif event.type in [EventType.DIVORCE,
|
|
|
|
|
EventType.ANNULMENT,
|
|
|
|
|
EventType.DIV_FILING]:
|
2009-03-17 05:02:47 +05:30
|
|
|
|
marriage_event = False
|
|
|
|
|
return marriage_event
|
2009-01-27 13:19:47 +05:30
|
|
|
|
|
2009-02-08 02:11:27 +05:30
|
|
|
|
def get_first_day_of_month(year, month):
|
2009-02-11 03:06:23 +05:30
|
|
|
|
"""
|
2009-02-10 07:08:08 +05:30
|
|
|
|
Compute the first day to display for this month.
|
|
|
|
|
It can also be a day in the previous month.
|
|
|
|
|
"""
|
|
|
|
|
|
2009-02-14 06:27:34 +05:30
|
|
|
|
# first day of the month
|
|
|
|
|
current_date = datetime.date(year, month, 1)
|
2009-02-08 02:11:27 +05:30
|
|
|
|
|
|
|
|
|
# monthinfo is filled using standard Python library
|
|
|
|
|
# calendar.monthcalendar. It fills a list of 7-day-lists. The first day
|
|
|
|
|
# of the 7-day-list is determined by calendar.firstweekday.
|
|
|
|
|
monthinfo = calendar.monthcalendar(year, month)
|
|
|
|
|
|
|
|
|
|
current_ord = current_date.toordinal() - monthinfo[0].count(0)
|
|
|
|
|
return current_date, current_ord, monthinfo
|
|
|
|
|
|
|
|
|
|
def get_previous_day(year, month, day_col):
|
2009-02-10 07:08:08 +05:30
|
|
|
|
"""
|
|
|
|
|
get last month's last week for previous days in the month
|
|
|
|
|
"""
|
|
|
|
|
|
2009-02-08 02:11:27 +05:30
|
|
|
|
if month == 1:
|
|
|
|
|
prevmonth = calendar.monthcalendar(year - 1, 12)
|
|
|
|
|
else:
|
|
|
|
|
prevmonth = calendar.monthcalendar(year, month-1)
|
|
|
|
|
num_weeks = len(prevmonth)
|
|
|
|
|
lastweek_prevmonth = prevmonth[num_weeks - 1]
|
2009-02-10 12:49:56 +05:30
|
|
|
|
previous_month_day = lastweek_prevmonth[day_col]
|
2009-02-08 02:11:27 +05:30
|
|
|
|
return previous_month_day
|
|
|
|
|
|
|
|
|
|
def get_next_day(year, month, day_col):
|
2009-02-10 07:08:08 +05:30
|
|
|
|
"""
|
|
|
|
|
get next month's first week for next days in the month
|
|
|
|
|
"""
|
|
|
|
|
|
2009-02-08 02:11:27 +05:30
|
|
|
|
if month == 12:
|
|
|
|
|
nextmonth = calendar.monthcalendar(year + 1, 1)
|
|
|
|
|
else:
|
|
|
|
|
nextmonth = calendar.monthcalendar(year, month + 1)
|
|
|
|
|
firstweek_nextmonth = nextmonth[0]
|
|
|
|
|
next_month_day = firstweek_nextmonth[day_col]
|
|
|
|
|
return next_month_day
|
2009-02-03 13:31:31 +05:30
|
|
|
|
|
2009-02-16 14:23:24 +05:30
|
|
|
|
def _has_webpage_extension(url):
|
2009-02-13 01:36:32 +05:30
|
|
|
|
"""
|
|
|
|
|
determine if a filename has an extension or not...
|
|
|
|
|
|
|
|
|
|
url = filename to be checked
|
|
|
|
|
"""
|
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
for ext in _WEB_EXT:
|
2009-02-16 14:23:24 +05:30
|
|
|
|
if url.endswith(ext):
|
|
|
|
|
return True
|
2009-02-13 01:36:32 +05:30
|
|
|
|
return False
|
|
|
|
|
|
2009-02-28 17:19:43 +05:30
|
|
|
|
def get_num_of_rows(num_years, years_in_row):
|
|
|
|
|
"""
|
|
|
|
|
This will return the number of weeks to be display in
|
|
|
|
|
display_year_navs()
|
|
|
|
|
"""
|
|
|
|
|
if num_years > years_in_row:
|
|
|
|
|
rows = 1
|
|
|
|
|
num_years -= years_in_row
|
|
|
|
|
elif 1 <= num_years <= years_in_row:
|
|
|
|
|
return 1
|
|
|
|
|
if num_years > years_in_row:
|
|
|
|
|
rows += 1
|
|
|
|
|
num_years -= years_in_row
|
|
|
|
|
elif 1 <= num_years <= years_in_row:
|
|
|
|
|
rows += 1
|
|
|
|
|
return rows
|
|
|
|
|
if num_years > years_in_row:
|
|
|
|
|
rows += 1
|
|
|
|
|
num_years -= years_in_row
|
|
|
|
|
elif 1 <= num_years <= years_in_row:
|
|
|
|
|
rows += 1
|
|
|
|
|
return rows
|
|
|
|
|
return rows
|
|
|
|
|
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# Gets individual events for each day
|
|
|
|
|
#
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
def get_day_list(event_date, holiday_list, bday_anniv_list):
|
|
|
|
|
"""
|
|
|
|
|
Will fill day_list and return it to its caller: calendar_build()
|
|
|
|
|
|
|
|
|
|
holiday_list -- list of holidays for event_date
|
|
|
|
|
bday_anniv_list -- list of birthdays and anniversaries
|
|
|
|
|
for event_date
|
|
|
|
|
|
|
|
|
|
event_date -- date for this day_list
|
|
|
|
|
|
|
|
|
|
'day_list' - a combination of both dictionaries to be able
|
|
|
|
|
to create one day nyears, date, text, event --- are
|
|
|
|
|
necessary for figuring the age or years married for
|
|
|
|
|
each day being created...
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
# initialize day_list
|
|
|
|
|
day_list = []
|
|
|
|
|
|
|
|
|
|
##################################################################
|
|
|
|
|
# birthday/ anniversary on this day
|
|
|
|
|
# '...' signifies an incomplete date for an event. See add_day_item()
|
|
|
|
|
bday_anniv_list = [(t, e, d) for t, e, d in bday_anniv_list
|
|
|
|
|
if d != '...']
|
|
|
|
|
|
|
|
|
|
# number of years have to be at least zero
|
|
|
|
|
bday_anniv_list = [(t, e, d) for t, e, d in bday_anniv_list
|
|
|
|
|
if (event_date.get_year() - d.get_year()) >= 0]
|
2009-03-30 03:56:36 +05:30
|
|
|
|
|
|
|
|
|
# birthday and anniversary list
|
2009-03-21 04:43:06 +05:30
|
|
|
|
for text, event, date in bday_anniv_list:
|
|
|
|
|
|
|
|
|
|
# number of years married, ex: 10
|
2009-03-26 16:47:57 +05:30
|
|
|
|
# zero will force holidays to be first in list
|
|
|
|
|
nyears = (event_date.get_year() - date.get_year())
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
|
|
|
|
# number of years for birthday, ex: 10 years
|
|
|
|
|
age_str = event_date - date
|
|
|
|
|
age_str.format(precision=1)
|
|
|
|
|
|
|
|
|
|
# a birthday
|
|
|
|
|
if event == 'Birthday':
|
|
|
|
|
|
|
|
|
|
txt_str = _(text + ', <em>'
|
|
|
|
|
+ ('%s old' % str(age_str) if nyears else 'birth')
|
|
|
|
|
+ '</em>')
|
|
|
|
|
|
|
|
|
|
# an anniversary
|
2009-03-30 03:56:36 +05:30
|
|
|
|
else:
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
|
|
|
|
if nyears == 0:
|
|
|
|
|
txt_str = _('%(couple)s, <em>wedding</em>') % {
|
|
|
|
|
'couple' : text}
|
|
|
|
|
else:
|
|
|
|
|
txt_str = (ngettext('%(couple)s, <em>%(years)d'
|
|
|
|
|
'</em> year anniversary',
|
|
|
|
|
'%(couple)s, <em>%(years)d'
|
|
|
|
|
'</em> year anniversary', nyears)
|
|
|
|
|
% {'couple' : text, 'years' : nyears})
|
2009-03-25 09:24:47 +05:30
|
|
|
|
txt_str = Html('span', txt_str, class_ = 'yearsmarried')
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
2009-03-26 16:47:57 +05:30
|
|
|
|
day_list.append((nyears, date, txt_str, event))
|
|
|
|
|
|
|
|
|
|
# a holiday
|
2009-03-30 03:56:36 +05:30
|
|
|
|
# will force holidays to be on top
|
|
|
|
|
nyears = 0
|
|
|
|
|
|
2009-03-26 16:47:57 +05:30
|
|
|
|
for text, event, date in holiday_list:
|
2009-03-30 03:56:36 +05:30
|
|
|
|
day_list.append((nyears, date, text, event))
|
2009-03-21 04:43:06 +05:30
|
|
|
|
|
|
|
|
|
# sort them based on number of years
|
2009-03-30 03:56:36 +05:30
|
|
|
|
# holidays will always be on top of event list
|
2009-03-21 04:43:06 +05:30
|
|
|
|
day_list.sort()
|
|
|
|
|
|
2009-03-26 16:47:57 +05:30
|
|
|
|
# return to its caller calendar_build()
|
2009-03-21 04:43:06 +05:30
|
|
|
|
return day_list
|
|
|
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------------------
|
2007-08-27 09:22:06 +05:30
|
|
|
|
#
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# Register Plugin
|
2007-08-27 09:22:06 +05:30
|
|
|
|
#
|
2009-03-21 04:43:06 +05:30
|
|
|
|
# ---------------------------------------------------------------------------------------
|
2008-05-19 00:54:28 +05:30
|
|
|
|
pmgr = PluginManager.get_instance()
|
|
|
|
|
pmgr.register_report(
|
2007-08-27 09:22:06 +05:30
|
|
|
|
name = 'WebCal',
|
|
|
|
|
category = CATEGORY_WEB,
|
2008-02-10 09:39:09 +05:30
|
|
|
|
report_class = WebCalReport,
|
|
|
|
|
options_class = WebCalOptions,
|
2008-10-02 09:32:10 +05:30
|
|
|
|
modes = PluginManager.REPORT_MODE_GUI,
|
2008-03-02 04:17:48 +05:30
|
|
|
|
translated_name = _("Web Calendar"),
|
2008-03-03 00:46:34 +05:30
|
|
|
|
status = _("Stable"),
|
2008-03-02 04:17:48 +05:30
|
|
|
|
author_name = "Thom Sturgill",
|
|
|
|
|
author_email = "thsturgill@yahoo.com",
|
|
|
|
|
description = _("Produces web (HTML) calendars."),
|
2007-08-27 09:22:06 +05:30
|
|
|
|
)
|