From d15b24537663773b84a88d3bb1faab17d0a3fc9a Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Fri, 22 Jul 2005 04:28:29 +0000 Subject: [PATCH] * 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 svn: r4959 --- gramps2/ChangeLog | 7 ++ gramps2/src/data/Makefile.am | 1 + gramps2/src/data/somerights20.gif | Bin 0 -> 1835 bytes gramps2/src/plugins/NavWebPage.py | 144 +++++++++++++++++++++++++----- 4 files changed, 130 insertions(+), 22 deletions(-) create mode 100644 gramps2/src/data/somerights20.gif 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 0000000000000000000000000000000000000000..0860fa98decdcb79a368723e5ebdb05f93918c0e GIT binary patch literal 1835 zcmV+`2h{jSNk%w1VORhk0OkMy00021v8w<7|E#jBKtMo%fPk&Dtgp4MvbV9Ww5_nV zuOJ{Gx4gEsy0o;pv$?*w-{0S^v#k&i5V5zg&(h9taB#T2x1XP%FfcH?z`D-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}B?G@L1ESDsEnDJ2DE000;Y zDi9E80R#}hga9W15J#9}mbrlqXa*^1T9#c{Nt~Fv_ugE0X5c~)BbIn#9sn%RT6Kbj z5ZfC?$dKcXQ)Ka2WM?VB46eC;d#N?V!AI1G^@(s_5~%Hf2LLL-D_E+3Y_VYf4J8oq zU<*}9*nn9nROpPilz>aHhMXMGjR_4{q+Aruk?>rfSEOO8p@Kocq8Mb{$ek0t3;`Y# zLH2eYuEJ#qQE_usWI-3>46)P-Lhzsg5?6>Zhzcj5P(Z2xctHjXwACO43$p4~3>YR% zY9U*e`t(q*bJfM^T?*?J!&5uJ&;}QVaM4E?Ff3>V4o)xzVaM7|#x2si%1I|g@5P5) zIHyQmS_w|cfJ6~nj4{UWu-tJ$bfQa-p#VKtl$Ca9JTJKnr8&!x*k6Fc@H<{Qx5X zz^G4x>E2z+wXX)4%kkQ2<#ypaA-Jfhnf1iiD5=1~71e0oibltKtt2 zDOiC5UC@CVB%&bp*vAC!?*d9>q#qsG#rZ+N14_hW0_&&6B%Uvbf)jk<4>fp5MK;id zNCYAUISGkW0-!bMqhKrtu>dY!vNbD|APSW5!}Ey}lw2gEDQ$T|PX?xzf$`%fT_lJd z?(dj_8B`t%85<82072vPfCm;Zs4`A)d=hvOIIp=)OmeebgOUI>X*nniRDhcVT7Wvo Zr>uCkvs6?;r#<8Oy?*-hpN$9v06Vt#9ijjL literal 0 HcmV?d00001 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