diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 48aa8e7d4..bbbdb96d7 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,10 @@ +2005-07-21 Don Allingham + * src/data/somerights20.gif: make a local copy of the Create Commons + image + * src/data/Makefile.am: add somerights20.gif + * src/plugins/NavWebPage.py: add birth dates to people, use local + create commons image, add surname pages + 2005-07-20 Don Allingham * src/plugins/NavWebPage.py: Add support for multiple directory levels to try to keep the number of files per directory under 254 for optimal ext3 diff --git a/gramps2/src/data/Makefile.am b/gramps2/src/data/Makefile.am index b273ae537..40697ccc3 100644 --- a/gramps2/src/data/Makefile.am +++ b/gramps2/src/data/Makefile.am @@ -6,6 +6,7 @@ pkgdatadir = $(datadir)/@PACKAGE@/data dist_pkgdata_DATA = \ gedcom.xml \ + somerights20.gif \ papersize.xml \ tips.xml\ main1.css\ diff --git a/gramps2/src/data/somerights20.gif b/gramps2/src/data/somerights20.gif new file mode 100644 index 000000000..0860fa98d Binary files /dev/null and b/gramps2/src/data/somerights20.gif differ diff --git a/gramps2/src/plugins/NavWebPage.py b/gramps2/src/plugins/NavWebPage.py index d735c3cbe..335a75f49 100644 --- a/gramps2/src/plugins/NavWebPage.py +++ b/gramps2/src/plugins/NavWebPage.py @@ -20,7 +20,18 @@ # $Id$ -"Web Site/Generate Web Site" +""" +Narrative Web Page generator. +""" + +# +# TODO: +# +# 1) Thumbnail creation +# 2) Surname/People integration to reduce Individual page size +# 3) Templating enhancements +# 4) Privacy options +# #------------------------------------------------------------------------ # @@ -28,6 +39,7 @@ # #------------------------------------------------------------------------ import os +import md5 import time import locale import shutil @@ -98,12 +110,12 @@ _character_sets = [ ] _cc = [ - 'Creative Commons License', - 'Creative Commons License', - 'Creative Commons License', - 'Creative Commons License', - 'Creative Commons License', - 'Creative Commons License', + 'Creative Commons License', + 'Creative Commons License', + 'Creative Commons License', + 'Creative Commons License', + 'Creative Commons License', + 'Creative Commons License', ] @@ -127,12 +139,13 @@ class BasePage: self.levels = levels def copy_media(self,photo): - if photo.get_handle() != self.photo_list and photo.get_handle() not in self.photo_list: + if (photo.get_handle() != self.photo_list + and photo.get_handle() not in self.photo_list): self.photo_list.append(photo.get_handle()) newpath = photo.gramps_id + os.path.splitext(photo.get_path())[1] newpath = os.path.join('images',newpath) return newpath - + def create_file(self,name): if self.archive: self.string_io = StringIO() @@ -170,10 +183,12 @@ class BasePage: of.close() def lnkfmt(self,text): - return text.replace(' ','%20') + return md5.new(text).hexdigest() def display_footer(self,of): + of.write('\n') + of.write('\n') of.write('



\n') of.write('\n') of.write('\n') def display_header(self,of,title,author="",up=False): + self.up = up if up: if self.levels == 1: path = "../.." @@ -242,6 +266,8 @@ class BasePage: if self.use_contact: self.show_link(of,'contact',_('Contact'),path) of.write('\n\n') + of.write('
\n') + of.write('
\n') of.write('
\n') def show_link(self,of,lpath,title,path): @@ -373,6 +399,15 @@ class BasePage: of.write(' [%s]' % gid) of.write('') + def surname_link(self,of,name,opt_val=None,up=False): + handle = self.lnkfmt(name) + dirpath = self.build_path(handle,'srn',up) + + of.write('%s' % (dirpath,handle,self.ext,name)) + if opt_val != None: + of.write(' (%d)' % opt_val) + of.write('') + def media_ref_link(self,of,handle,name,up=False): dirpath = self.build_path(handle,'img',up) of.write('%s' % ( @@ -430,7 +465,7 @@ class IndividualListPage(BasePage): get_researcher().get_name()) msg = _("This page contains an index of all the individuals in the " - "database, sorted by their last names. Selecting person's name " + "database, sorted by their last names. Selecting the person's name " "will take you to that person's individual page.") of.write('

%s

\n' % _('Individuals')) @@ -440,10 +475,9 @@ class IndividualListPage(BasePage): of.write('cellpadding="0" border="0">\n') of.write('%s\n' % _('Surname')) of.write('%s\n' % _('Name')) + of.write('%s\n' % _('Birth date')) of.write('\n') - flist = sets.Set(person_handle_list) - person_handle_list = sort_people(db,person_handle_list) for (surname,handle_list) in person_handle_list: @@ -460,6 +494,11 @@ class IndividualListPage(BasePage): self.person_link(of,person.handle, person.get_primary_name().get_first_name(), person.gramps_id) + of.write('') + birth_handle = person.get_birth_handle() + if birth_handle: + birth = db.get_event_from_handle(birth_handle) + of.write(birth.get_date()) of.write('\n') first = False @@ -467,6 +506,49 @@ class IndividualListPage(BasePage): self.display_footer(of) self.close_file(of) +#------------------------------------------------------------------------ +# +# +# +#------------------------------------------------------------------------ +class SurnamePage(BasePage): + + def __init__(self, db, title, person_handle_list, options, archive, + media_list, levels): + BasePage.__init__(self, title, options, archive, media_list, levels) + + of = self.create_link_file(md5.new(title).hexdigest(),'srn') + self.display_header(of,title,get_researcher().get_name(),True) + + msg = _("This page contains an index of all the individuals in the " + "database with the surname of %s. Selecting the person's name " + "will take you to that person's individual page.") % title + + of.write('

%s

\n' % title) + of.write('

%s

\n' % msg) + of.write('
\n') + of.write('\n') + of.write('\n' % _('Name')) + of.write('\n' % _('Birth date')) + of.write('\n') + + for person_handle in person_handle_list: + person = db.get_person_from_handle(person_handle) + of.write('\n') + of.write('
%s%s
') + self.person_link(of,person.handle, + person.get_primary_name().get_first_name(), + person.gramps_id,up=True) + of.write('') + birth_handle = person.get_birth_handle() + if birth_handle: + birth = db.get_event_from_handle(birth_handle) + of.write(birth.get_date()) + of.write('
\n
\n') + self.display_footer(of) + self.close_file(of) + #------------------------------------------------------------------------ # # @@ -690,6 +772,8 @@ class SurnameListPage(BasePage): of.write('%s\n' % _('Letter')) of.write('') of.write('%s\n' % _('Surname')) + of.write('') + of.write('%s\n' % _('Number of people')) of.write('\n') person_handle_list = sort_people(db,person_handle_list) @@ -704,16 +788,15 @@ class SurnameListPage(BasePage): last_letter = surname[0] of.write('%s' % last_letter) of.write('') - of.write('' % (self.ext,self.lnkfmt(surname))) - of.write("%s (%d)" % (surname,len(data_list))) - of.write('') + self.surname_link(of,surname) + of.write('') elif surname != last_surname: of.write(' ') of.write('') - of.write('' % (self.ext,self.lnkfmt(surname))) - of.write("%s (%d)" % (surname,len(data_list))) - of.write('') + self.surname_link(of,surname) + of.write('') last_surname = surname + of.write('%d' % len(data_list)) of.write('\n\n') self.display_footer(of) @@ -789,7 +872,7 @@ class HomePage(BasePage): mime_type = obj.get_mime_type() if mime_type and mime_type.startswith("image"): try: - newpath = self.copy_media(obj) + newpath = self.copy_media_add(obj) of.write('
\n') of.write('%s' % (newpath, obj.get_description())) @@ -1604,6 +1687,10 @@ class WebReport(Report.Report): archive = None self.write_css(archive,self.target_path,self.css) + if 1 < self.copyright < 7: + from_path = os.path.join(const.dataDir,"somerights20.gif") + to_path = os.path.join("images","somerights20.gif") + self.store_file(archive,self.target_path,from_path,to_path) photo_list = [] @@ -1652,6 +1739,11 @@ class WebReport(Report.Report): while gtk.events_pending(): gtk.main_iteration() + local_list = sort_people(self.database,ind_list) + for (surname,handle_list) in local_list: + SurnamePage(self.database, surname, handle_list, self.options_class, + archive, photo_list, levels) + PlaceListPage(self.database, self.title, place_list, source_list,self.options_class, archive, photo_list, levels) @@ -1696,7 +1788,15 @@ class WebReport(Report.Report): else: shutil.copyfile(os.path.join(const.dataDir,css_file), os.path.join(html_dir,_NARRATIVE)) - + + def store_file(self,archive,html_dir,from_path,to_path): + if archive: + imagefile = open(from_path,"r") + archive.add_file(to_path,time.time(),imagefile) + imagefile.close() + else: + shutil.copyfile(from_path,os.path.join(html_dir,to_path)) + def add_styles(self,doc): pass