* src/plugins/NavWebPage.py: Marked strings for translation; Dont crash if media file does not exist; Generate pages for every place; Build list of used sources

svn: r4819
This commit is contained in:
Martin Hawlisch 2005-06-10 14:03:27 +00:00
parent dee75c1f08
commit d8d03e335c
2 changed files with 98 additions and 27 deletions

View File

@ -1,5 +1,8 @@
2005-06-10 Martin Hawlisch <Martin.Hawlisch@gmx.de> 2005-06-10 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* src/ReportUtils.py (place_name): Really return place name * src/ReportUtils.py (place_name): Really return place name
* src/plugins/NavWebPage.py: Marked strings for translation; Dont crash
if media file does not exist; Generate pages for every place; Build list
of used sources
2005-06-09 Martin Hawlisch <Martin.Hawlisch@gmx.de> 2005-06-09 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* src/plugins/Makefile.am: Install vCal and vCard plugins * src/plugins/Makefile.am: Install vCal and vCard plugins

View File

@ -135,7 +135,7 @@ class BasePage:
of.write('<br>\n') of.write('<br>\n')
of.write('<br>\n') of.write('<br>\n')
of.write('<hr>\n') of.write('<hr>\n')
of.write('<div class="footer">Generated by ') of.write('<div class="footer">%s ' % _('Generated by'))
of.write('<a href="http://gramps.sourceforge.net">GRAMPS</a> ') of.write('<a href="http://gramps.sourceforge.net">GRAMPS</a> ')
of.write('on 13 December 2004.') of.write('on 13 December 2004.')
of.write('</div>\n') of.write('</div>\n')
@ -159,14 +159,14 @@ class BasePage:
of.write(' <h1 class="navtitle">%s</h1>\n' % self.title_str) of.write(' <h1 class="navtitle">%s</h1>\n' % self.title_str)
of.write(' <hr>\n') of.write(' <hr>\n')
of.write(' <div class="nav">\n') of.write(' <div class="nav">\n')
of.write(' <a href="index.html">Home</a> &nbsp;\n') of.write(' <a href="index.html">%s</a> &nbsp;\n' % _('Home'))
of.write(' <a href="introduction.html">Introduction</a> &nbsp;\n') of.write(' <a href="introduction.html">%s</a> &nbsp;\n' % _('Introduction'))
of.write(' <a href="surnames.html">Surnames</a> &nbsp;\n') of.write(' <a href="surnames.html">%s</a> &nbsp;\n' % _('Surnames'))
of.write(' <a href="individuals.html">Individuals</a> &nbsp;\n') of.write(' <a href="individuals.html">%s</a> &nbsp;\n' % _('Individuals'))
of.write(' <a href="sources.html">Sources</a> &nbsp;\n') of.write(' <a href="sources.html">%s</a> &nbsp;\n' % _('Sources'))
of.write(' <a href="places.html">Places</a> &nbsp;\n') of.write(' <a href="places.html">%s</a> &nbsp;\n' % _('Places'))
of.write(' <a href="download.html">Download</a> &nbsp;\n') of.write(' <a href="download.html">%s</a> &nbsp;\n' % _('Download'))
of.write(' <a href="contact.html">Contact</a> &nbsp;\n') of.write(' <a href="contact.html">%s</a> &nbsp;\n' % _('Contact'))
of.write(' </div>\n') of.write(' </div>\n')
of.write(' </div>\n') of.write(' </div>\n')
@ -255,9 +255,9 @@ class PlaceListPage(BasePage):
for handle in handle_list: for handle in handle_list:
place = db.get_place_from_handle(handle) place = db.get_place_from_handle(handle)
n = place.title n = ReportUtils.place_name(db,handle)
if len(n) == 0: if not n or len(n) == 0:
continue continue
if n[0] != last_letter: if n[0] != last_letter:
@ -274,7 +274,7 @@ class PlaceListPage(BasePage):
of.write('<tr><td class="category">&nbsp;</td>') of.write('<tr><td class="category">&nbsp;</td>')
of.write('<td class="data">') of.write('<td class="data">')
of.write(n) of.write(n)
of.write(' <sup><a href="%s">' % place.gramps_id) of.write(' <sup><a href="%s.html">' % place.gramps_id)
of.write('[%s]' % place.gramps_id) of.write('[%s]' % place.gramps_id)
of.write('</a></sup></td></tr>') of.write('</a></sup></td></tr>')
@ -282,6 +282,58 @@ class PlaceListPage(BasePage):
self.display_footer(of) self.display_footer(of)
of.close() of.close()
#------------------------------------------------------------------------
#
#
#
#------------------------------------------------------------------------
class PlacePage(BasePage):
def __init__(self, db, title, place_handle, html_dir, src_list):
place = db.get_place_from_handle( place_handle)
BasePage.__init__(self,title)
page_name = os.path.join(html_dir,place.get_gramps_id()+".html")
of = open(page_name, "w")
place_name = ReportUtils.place_name(db,place_handle)
self.display_header(of,place_name,
db.get_researcher().get_name())
of.write('<h3>%s</h3>\n' % place_name)
photolist = place.get_media_list()
if photolist:
photo_handle = photolist[0].get_reference_handle()
photo = db.get_object_from_handle(photo_handle)
try:
newpath = photo.gramps_id + os.path.splitext(photo.get_path())[1]
shutil.copyfile(photo.get_path(),os.path.join(html_dir,newpath))
of.write('<div class="snapshot">\n')
of.write('<a href="%s">' % newpath)
of.write('<img class="thumbnail" border="0" src="%s" ' % newpath)
of.write('height="100"></a>')
of.write('</div>\n')
except (IOError,OSError),msg:
ErrorDialog(str(msg))
# TODO: Add more information
of.write('<h4>%s</h4>\n' % _('Narrative'))
of.write('<hr>\n')
noteobj = place.get_note_object()
if noteobj:
format = noteobj.get_format()
text = noteobj.get()
if format:
text = "<pre>" + "<br>".join(text.split("\n"))
else:
text = "</p><p>".join(text.split("\n"))
of.write('<p>%s</p>\n' % text)
self.display_footer(of)
of.close()
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# #
@ -403,13 +455,16 @@ class HomePage(BasePage):
else: else:
mime_type = obj.get_mime_type() mime_type = obj.get_mime_type()
if mime_type and mime_type.startswith("image"): if mime_type and mime_type.startswith("image"):
newpath = obj.gramps_id + os.path.splitext(obj.get_path())[1] try:
shutil.copyfile(obj.get_path(), newpath = obj.gramps_id + os.path.splitext(obj.get_path())[1]
os.path.join(html_dir,newpath)) shutil.copyfile(obj.get_path(),
of.write('<div align="center">\n') os.path.join(html_dir,newpath))
of.write('<img border="0" ') of.write('<div align="center">\n')
of.write('src="%s" />' % newpath) of.write('<img border="0" ')
of.write('</div>\n') of.write('src="%s" />' % newpath)
of.write('</div>\n')
except (IOError,OSError),msg:
ErrorDialog(str(msg))
note_obj = obj.get_note_object() note_obj = obj.get_note_object()
if note_obj: if note_obj:
@ -447,9 +502,12 @@ class SourcesPage(BasePage):
index = 1 index = 1
for handle in handle_list: for handle in handle_list:
source = db.get_source_from_handle(handle)
of.write('<tr><td class="category">%d.</td>\n' % index) of.write('<tr><td class="category">%d.</td>\n' % index)
of.write('<td class="data">') of.write('<td class="data">')
of.write(source.get_title())
of.write('</td></tr>\n') of.write('</td></tr>\n')
index += 1
of.write('</table>\n<blockquote>\n') of.write('</table>\n<blockquote>\n')
@ -615,13 +673,16 @@ class IndividualPage(BasePage):
photo_handle = photolist[0].get_reference_handle() photo_handle = photolist[0].get_reference_handle()
photo = self.db.get_object_from_handle(photo_handle) photo = self.db.get_object_from_handle(photo_handle)
newpath = self.person.gramps_id + os.path.splitext(photo.get_path())[1] try:
shutil.copyfile(photo.get_path(),os.path.join(self.dirpath,newpath)) newpath = self.person.gramps_id + os.path.splitext(photo.get_path())[1]
of.write('<div class="snapshot">\n') shutil.copyfile(photo.get_path(),os.path.join(self.dirpath,newpath))
of.write('<a href="%s">' % newpath) of.write('<div class="snapshot">\n')
of.write('<img class="thumbnail" border="0" src="%s" ' % newpath) of.write('<a href="%s">' % newpath)
of.write('height="100"></a>') of.write('<img class="thumbnail" border="0" src="%s" ' % newpath)
of.write('</div>\n') of.write('height="100"></a>')
of.write('</div>\n')
except (IOError,OSError),msg:
ErrorDialog(str(msg))
of.write('<div class="summaryarea">\n') of.write('<div class="summaryarea">\n')
of.write('<h3>%s</h3>\n' % self.sort_name) of.write('<h3>%s</h3>\n' % self.sort_name)
@ -819,6 +880,8 @@ class IndividualPage(BasePage):
of.write('</blockquote>\n') of.write('</blockquote>\n')
def format_event(self,event): def format_event(self,event):
for sref in event.get_source_references():
self.src_list.add(sref.get_base_handle())
descr = event.get_description() descr = event.get_description()
place_handle = event.get_place_handle() place_handle = event.get_place_handle()
if place_handle: if place_handle:
@ -994,6 +1057,11 @@ class WebReport(Report.Report):
PlaceListPage(self.database, self.title, place_list, PlaceListPage(self.database, self.title, place_list,
dir_name, source_list) dir_name, source_list)
for place in place_list:
print place
PlacePage(self.database, self.title, place, dir_name, source_list)
SourcesPage(self.database,self.title, source_list, dir_name) SourcesPage(self.database,self.title, source_list, dir_name)
self.progress_bar_done() self.progress_bar_done()
@ -1031,7 +1099,7 @@ class WebReportOptions(ReportOptions.ReportOptions):
'HTMLsplita' : 0, 'HTMLsplita' : 0,
'HTMLshorttree' : 1, 'HTMLshorttree' : 1,
'HTMLimagedir' : 'images', 'HTMLimagedir' : 'images',
'HTMLtitle' : 'My Family Tree', 'HTMLtitle' : _('My Family Tree'),
'HTMLincid' : 0, 'HTMLincid' : 0,
'HTMLidurl' : '', 'HTMLidurl' : '',
'HTMLlinktidx' : 1, 'HTMLlinktidx' : 1,