* 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 file performance, add support for copyright. svn: r4958
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
2005-07-20 Don Allingham <don@gramps-project.org>
|
||||
* 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
|
||||
file performance, add support for copyright.
|
||||
|
||||
2005-07-20 Julio Sanchez <jsanchez@users.sourceforge.net>
|
||||
* src/plugins/DetDescendantReport.py: Names, events and sources.
|
||||
* src/plugins/DetAncestralReport.py (add_user_options): Names, events and sources.
|
||||
|
@@ -97,15 +97,24 @@ _character_sets = [
|
||||
['koi8_r', 'koi8_r', ],
|
||||
]
|
||||
|
||||
_cc = [
|
||||
'<a rel="license" href="http://creativecommons.org/licenses/by/2.5/"><img alt="Creative Commons License" border="0" src="http://creativecommons.org/images/public/somerights20.gif" /></a>',
|
||||
'<a rel="license" href="http://creativecommons.org/licenses/by-nd/2.5/"><img alt="Creative Commons License" border="0" src="http://creativecommons.org/images/public/somerights20.gif" /></a>',
|
||||
'<a rel="license" href="http://creativecommons.org/licenses/by-sa/2.5/"><img alt="Creative Commons License" border="0" src="http://creativecommons.org/images/public/somerights20.gif" /></a>',
|
||||
'<a rel="license" href="http://creativecommons.org/licenses/by-nc/2.5/"><img alt="Creative Commons License" border="0" src="http://creativecommons.org/images/public/somerights20.gif" /></a>',
|
||||
'<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/2.5/"><img alt="Creative Commons License" border="0" src="http://creativecommons.org/images/public/somerights20.gif" /></a>',
|
||||
'<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/2.5/"><img alt="Creative Commons License" border="0" src="http://creativecommons.org/images/public/somerights20.gif" /></a>',
|
||||
]
|
||||
|
||||
|
||||
class BasePage:
|
||||
def __init__(self, title, options, archive, photo_list):
|
||||
def __init__(self, title, options, archive, photo_list, levels):
|
||||
self.title_str = title
|
||||
self.inc_download = options.handler.options_dict['NWEBdownload']
|
||||
self.html_dir = options.handler.options_dict['NWEBod']
|
||||
self.copyright = options.handler.options_dict['NWEBcopyright']
|
||||
self.options = options
|
||||
self.archive = archive
|
||||
self.image_dir = options.handler.options_dict['NWEBimagedir'].strip()
|
||||
self.ext = options.handler.options_dict['NWEBext']
|
||||
self.encoding = options.handler.options_dict['NWEBencoding']
|
||||
self.css = options.handler.options_dict['NWEBcss']
|
||||
@@ -114,13 +123,14 @@ class BasePage:
|
||||
self.use_contact = options.handler.options_dict['NWEBcontact'] != u""
|
||||
self.photo_list = photo_list
|
||||
self.private = not options.handler.options_dict['NWEBincpriv']
|
||||
self.copyright = options.handler.options_dict['NWEBcopyright']
|
||||
self.levels = levels
|
||||
|
||||
def copy_media(self,photo):
|
||||
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]
|
||||
if self.image_dir:
|
||||
newpath = os.path.join(self.image_dir,newpath)
|
||||
newpath = os.path.join('images',newpath)
|
||||
return newpath
|
||||
|
||||
def create_file(self,name):
|
||||
@@ -133,6 +143,25 @@ class BasePage:
|
||||
of = codecs.EncodedFile(open(page_name, "w"),'utf-8',self.encoding)
|
||||
return of
|
||||
|
||||
def create_link_file(self,name,path):
|
||||
if self.archive:
|
||||
self.string_io = StringIO()
|
||||
of = codecs.EncodedFile(self.string_io,'utf-8',self.encoding)
|
||||
if self.levels == 1:
|
||||
self.cur_name = os.path.join(path,name[0],name + "." + self.ext)
|
||||
else:
|
||||
self.cur_name = os.path.join(path,name[0],name[1],name + "." + self.ext)
|
||||
else:
|
||||
if self.levels == 1:
|
||||
dirname = os.path.join(self.html_dir,path,name[0])
|
||||
else:
|
||||
dirname = os.path.join(self.html_dir,path,name[0],name[1])
|
||||
if not os.path.isdir(dirname):
|
||||
os.makedirs(dirname)
|
||||
page_name = os.path.join(dirname,name + "." + self.ext)
|
||||
of = codecs.EncodedFile(open(page_name, "w"),'utf-8',self.encoding)
|
||||
return of
|
||||
|
||||
def close_file(self,of):
|
||||
if self.archive:
|
||||
self.archive.add_file(self.cur_name,time.time(),self.string_io)
|
||||
@@ -145,62 +174,81 @@ class BasePage:
|
||||
|
||||
def display_footer(self,of):
|
||||
|
||||
format = locale.nl_langinfo(locale.D_FMT)
|
||||
value = time.strftime(format,time.localtime(time.time()))
|
||||
|
||||
msg = _('Generated by <a href="http://gramps-project.org">'
|
||||
'GRAMPS</a> on %(date)s' % { 'date' : value })
|
||||
|
||||
of.write('</div>\n')
|
||||
of.write('<div class="footer">%s</div>\n' % msg)
|
||||
of.write('<br><br><hr>\n')
|
||||
of.write('<div class="footer">\n')
|
||||
if self.copyright == 0:
|
||||
if self.author:
|
||||
self.author = self.author.replace(',,,','')
|
||||
year = time.localtime(time.time())[0]
|
||||
cright = _('© %(year)d %(person)s') % {
|
||||
'person' : self.author,
|
||||
'year' : year }
|
||||
of.write('<br>%s\n' % cright)
|
||||
elif self.copyright <=6:
|
||||
of.write('<div align="center">')
|
||||
of.write(_cc[self.copyright-1])
|
||||
of.write('</div>')
|
||||
of.write('</div><br><br><br><hr>\n')
|
||||
of.write('</body>\n')
|
||||
of.write('</html>\n')
|
||||
|
||||
def display_header(self,of,title,author=""):
|
||||
|
||||
if author:
|
||||
author = author.replace(',,,','')
|
||||
year = time.localtime(time.time())[0]
|
||||
cright = _('Copyright © %(person)s %(year)d') % {
|
||||
'person' : author,
|
||||
'year' : year }
|
||||
|
||||
def display_header(self,of,title,author="",up=False):
|
||||
if up:
|
||||
if self.levels == 1:
|
||||
path = "../.."
|
||||
else:
|
||||
path = "../../.."
|
||||
else:
|
||||
path = ""
|
||||
|
||||
self.author = author
|
||||
of.write('<!DOCTYPE HTML PUBLIC ')
|
||||
of.write('"-//W3C//DTD HTML 4.01 Transitional//EN">\n')
|
||||
of.write('<html>\n<head>\n')
|
||||
of.write('<title>%s - %s</title>\n' % (self.title_str, title))
|
||||
of.write('<meta http-equiv="Content-Type" content="text/html; ')
|
||||
of.write('charset=%s">\n' % self.encoding)
|
||||
of.write('<link href="%s" ' % _NARRATIVE)
|
||||
if path:
|
||||
of.write('<link href="%s/%s" ' % (path,_NARRATIVE))
|
||||
else:
|
||||
of.write('<link href="%s" ' % _NARRATIVE)
|
||||
of.write('rel="stylesheet" type="text/css">\n')
|
||||
of.write('<link href="favicon.png" rel="Shortcut Icon">\n')
|
||||
of.write('<!-- $Id$ -->')
|
||||
of.write('</head>\n')
|
||||
of.write('<body>\n')
|
||||
of.write('<div class="navheader">\n')
|
||||
if author:
|
||||
of.write('<div class="navbyline">%s</div>\n' % cright)
|
||||
|
||||
format = locale.nl_langinfo(locale.D_FMT)
|
||||
value = time.strftime(format,time.localtime(time.time()))
|
||||
|
||||
msg = _('Generated by <a href="http://gramps-project.org">'
|
||||
'GRAMPS</a> on %(date)s' % { 'date' : value })
|
||||
|
||||
of.write('<div class="navbyline">%s</div>\n' % msg)
|
||||
of.write('<h1 class="navtitle">%s</h1>\n' % self.title_str)
|
||||
of.write('<hr>\n')
|
||||
of.write('<div class="nav">\n')
|
||||
self.show_link(of,'index',_('Home'))
|
||||
self.show_link(of,'index',_('Home'),path)
|
||||
if self.use_intro:
|
||||
self.show_link(of,'introduction',_('Introduction'))
|
||||
self.show_link(of,'surnames',_('Surnames'))
|
||||
self.show_link(of,'individuals',_('Individuals'))
|
||||
self.show_link(of,'sources',_('Sources'))
|
||||
self.show_link(of,'places',_('Places'))
|
||||
self.show_link(of,'gallery',_('Gallery'))
|
||||
self.show_link(of,'introduction',_('Introduction'),path)
|
||||
self.show_link(of,'surnames',_('Surnames'),path)
|
||||
self.show_link(of,'individuals',_('Individuals'),path)
|
||||
self.show_link(of,'sources',_('Sources'),path)
|
||||
self.show_link(of,'places',_('Places'),path)
|
||||
self.show_link(of,'gallery',_('Gallery'),path)
|
||||
if self.inc_download:
|
||||
self.show_link(of,'download',_('Download'))
|
||||
self.show_link(of,'download',_('Download'),path)
|
||||
if self.use_contact:
|
||||
self.show_link(of,'contact',_('Contact'))
|
||||
self.show_link(of,'contact',_('Contact'),path)
|
||||
of.write('</div>\n</div>\n')
|
||||
of.write(' <div class="content">\n')
|
||||
|
||||
def show_link(self,of,lpath,title):
|
||||
of.write('<a href="%s.%s">%s</a> ' % (lpath,self.ext,title))
|
||||
def show_link(self,of,lpath,title,path):
|
||||
if path:
|
||||
of.write('<a href="%s/%s.%s">%s</a> ' % (path,lpath,self.ext,title))
|
||||
else:
|
||||
of.write('<a href="%s.%s">%s</a> ' % (lpath,self.ext,title))
|
||||
|
||||
def display_first_image_as_thumbnail( self, of, db, photolist=None):
|
||||
if not photolist:
|
||||
@@ -213,9 +261,8 @@ class BasePage:
|
||||
try:
|
||||
newpath = self.copy_media(photo)
|
||||
of.write('<div class="snapshot">\n')
|
||||
of.write('<a href="%s.%s">' % (photo_handle,self.ext))
|
||||
of.write('<img class="thumbnail" border="0" src="%s" ' % newpath)
|
||||
of.write('height="100" alt="%s"></a>' % photo.get_description())
|
||||
self.media_link(of,photo_handle,newpath,
|
||||
photo.get_description(),up=True)
|
||||
of.write('</div>\n')
|
||||
except (IOError,OSError),msg:
|
||||
ErrorDialog(str(msg))
|
||||
@@ -235,12 +282,8 @@ class BasePage:
|
||||
if photo.get_mime_type():
|
||||
try:
|
||||
newpath = self.copy_media(photo)
|
||||
of.write('<div class="galleryentry">\n')
|
||||
of.write('<a href="%s.%s">' % (photo_handle,self.ext))
|
||||
of.write('<img class="thumbnail" border="0" src="%s" ' % newpath)
|
||||
of.write('height="100" alt="%s"></a>' % photo.get_description())
|
||||
of.write('<div>%s</div>' % photo.get_description())
|
||||
of.write('</div>\n')
|
||||
self.media_link(of,photo_handle,newpath,
|
||||
photo.get_description(),up=True)
|
||||
except (IOError,OSError),msg:
|
||||
ErrorDialog(str(msg))
|
||||
of.write('</blockquote>')
|
||||
@@ -304,12 +347,74 @@ class BasePage:
|
||||
for handle in handlelist:
|
||||
person = db.get_person_from_handle(handle)
|
||||
of.write('<tr><td class="field">%d. ' % index)
|
||||
of.write('<a href="%s.%s">%s</a>' % (handle,self.ext,
|
||||
nameof(person,self.private)))
|
||||
self.person_link(of,handle,nameof(person,self.private),
|
||||
person.gramps_id,True)
|
||||
of.write('</td></tr>\n')
|
||||
index = index + 1
|
||||
of.write('</table>\n')
|
||||
|
||||
def build_path(self,handle,dirroot,up):
|
||||
if up:
|
||||
if self.levels == 1:
|
||||
return '../../%s/%s/' % (dirroot,handle[0])
|
||||
else:
|
||||
return '../../../%s/%s/%s' % (dirroot,handle[0],handle[1])
|
||||
else:
|
||||
if self.levels == 1:
|
||||
return "%s/%s" % (dirroot,handle[0])
|
||||
else:
|
||||
return "%s/%s/%s" % (dirroot,handle[0],handle[1])
|
||||
|
||||
def person_link(self,of,handle,name,gid="",up=False):
|
||||
dirpath = self.build_path(handle,'ppl',up)
|
||||
|
||||
of.write('<a href="%s/%s.%s">%s' % (dirpath,handle,self.ext,name))
|
||||
if not self.noid and gid != "":
|
||||
of.write(' <span class="grampsid">[%s]</span>' % gid)
|
||||
of.write('</a>')
|
||||
|
||||
def media_ref_link(self,of,handle,name,up=False):
|
||||
dirpath = self.build_path(handle,'img',up)
|
||||
of.write('<a href="%s/%s.%s">%s</a>' % (
|
||||
dirpath,handle,self.ext,name))
|
||||
|
||||
def media_link(self,of,handle,path,name,up,usedescr=True):
|
||||
dirpath = self.build_path(handle,'img',up)
|
||||
of.write('<a href="%s/%s.%s">' % (
|
||||
dirpath,handle,self.ext))
|
||||
if self.levels == 1:
|
||||
of.write('<img class="thumbnail" border="0" src="../../%s" ' % path)
|
||||
else:
|
||||
of.write('<img class="thumbnail" border="0" src="../../../%s" ' % path)
|
||||
of.write('height="100", alt="%s"></a>' % name)
|
||||
if usedescr:
|
||||
of.write('<div class="thumbname">%s</div>' % name)
|
||||
of.write('</a>')
|
||||
|
||||
def source_link(self,of,handle,name,gid="",up=False):
|
||||
dirpath = self.build_path(handle,'src',up)
|
||||
of.write('<a href="%s/%s.%s">%s' % (
|
||||
dirpath,handle,self.ext,name))
|
||||
if not self.noid and gid != "":
|
||||
of.write(' <span class="grampsid">[%s]</span>' % gid)
|
||||
of.write('</a>')
|
||||
|
||||
def place_link(self,of,handle,name,gid="",up=False):
|
||||
dirpath = self.build_path(handle,'plc',up)
|
||||
of.write('<a href="%s/%s.%s">%s' % (
|
||||
dirpath,handle,self.ext,name))
|
||||
if not self.noid and gid != "":
|
||||
of.write(' <span class="grampsid">[%s]</span>' % gid)
|
||||
of.write('</a>')
|
||||
|
||||
def place_link_str(self,handle,name,gid="",up=False):
|
||||
dirpath = self.build_path(handle,'plc',up)
|
||||
retval = '<a href="%s/%s.%s">%s' % (
|
||||
dirpath,handle,self.ext,name)
|
||||
if not self.noid and gid != "":
|
||||
retval = retval + ' <span class="grampsid">[%s]</span>' % gid
|
||||
return retval + '</a>'
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
@@ -317,8 +422,8 @@ class BasePage:
|
||||
#------------------------------------------------------------------------
|
||||
class IndividualListPage(BasePage):
|
||||
|
||||
def __init__(self, db, title, person_handle_list, options, archive, media_list):
|
||||
BasePage.__init__(self, title, options, archive, media_list)
|
||||
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_file("individuals")
|
||||
self.display_header(of,_('Individuals'),
|
||||
@@ -352,11 +457,10 @@ class IndividualListPage(BasePage):
|
||||
else:
|
||||
of.write(' ')
|
||||
of.write('</td><td class="data">')
|
||||
of.write(' <a href="%s.%s">' % (person.handle,self.ext))
|
||||
of.write(person.get_primary_name().get_first_name())
|
||||
if not self.noid:
|
||||
of.write(u' <span class="grampsid">[%s]</span>' % person.gramps_id)
|
||||
of.write('</a></td></tr>\n')
|
||||
self.person_link(of,person.handle,
|
||||
person.get_primary_name().get_first_name(),
|
||||
person.gramps_id)
|
||||
of.write('</td></tr>\n')
|
||||
first = False
|
||||
|
||||
of.write('</table>\n</blockquote>\n')
|
||||
@@ -370,8 +474,9 @@ class IndividualListPage(BasePage):
|
||||
#------------------------------------------------------------------------
|
||||
class PlaceListPage(BasePage):
|
||||
|
||||
def __init__(self, db, title, place_handles, src_list, options, archive, media_list):
|
||||
BasePage.__init__(self, title, options, archive, media_list)
|
||||
def __init__(self, db, title, place_handles, src_list, options, archive,
|
||||
media_list, levels):
|
||||
BasePage.__init__(self, title, options, archive, media_list, levels)
|
||||
of = self.create_file("places")
|
||||
self.display_header(of,_('Places'),
|
||||
get_researcher().get_name())
|
||||
@@ -410,20 +515,14 @@ class PlaceListPage(BasePage):
|
||||
of.write('<tr><td colspan="2"> </td></tr>\n')
|
||||
of.write('<tr><td class="category">%s</td>' % last_letter)
|
||||
of.write('<td class="data">')
|
||||
of.write('<a href="%s.%s">' % (place.handle,self.ext))
|
||||
of.write(n)
|
||||
if not self.noid:
|
||||
of.write(' <span class="grampsid">[%s]</span>' % place.gramps_id)
|
||||
of.write('</a></td></tr>')
|
||||
self.place_link(of,place.handle,n,place.gramps_id)
|
||||
of.write('</td></tr>')
|
||||
last_surname = n
|
||||
elif n != last_surname:
|
||||
of.write('<tr><td class="category"> </td>')
|
||||
of.write('<td class="data">')
|
||||
of.write('<a href="%s.%s">' % (place.handle,self.ext))
|
||||
of.write(n)
|
||||
if not self.noid:
|
||||
of.write(' <span class="grampsid">[%s]</span>' % place.gramps_id)
|
||||
of.write('</a></td></tr>')
|
||||
self.place_link(of,place.handle,n,place.gramps_id)
|
||||
of.write('</td></tr>')
|
||||
last_surname = n
|
||||
|
||||
of.write('</table>\n</blockquote>\n')
|
||||
@@ -437,13 +536,14 @@ class PlaceListPage(BasePage):
|
||||
#------------------------------------------------------------------------
|
||||
class PlacePage(BasePage):
|
||||
|
||||
def __init__(self, db, title, place_handle, src_list, place_list, options, archive, media_list):
|
||||
def __init__(self, db, title, place_handle, src_list, place_list, options,
|
||||
archive, media_list, levels):
|
||||
place = db.get_place_from_handle( place_handle)
|
||||
BasePage.__init__(self, title, options, archive, media_list)
|
||||
of = self.create_file(place.get_handle())
|
||||
BasePage.__init__(self, title, options, archive, media_list, levels)
|
||||
of = self.create_link_file(place.get_handle(),"plc")
|
||||
place_name = ReportUtils.place_name(db,place_handle)
|
||||
self.display_header(of,"%s - %s" % (_('Places'), place_name),
|
||||
get_researcher().get_name())
|
||||
get_researcher().get_name(),up=True)
|
||||
|
||||
self.display_first_image_as_thumbnail(of, db, place.get_media_list())
|
||||
|
||||
@@ -497,16 +597,15 @@ class PlacePage(BasePage):
|
||||
class MediaPage(BasePage):
|
||||
|
||||
def __init__(self, db, title, handle, src_list, options, archive, media_list,
|
||||
info):
|
||||
info, levels):
|
||||
|
||||
(prev, next, page_number, total_pages) = info
|
||||
photo = db.get_object_from_handle(handle)
|
||||
BasePage.__init__(self, title, options, archive, media_list)
|
||||
of = self.create_file(handle)
|
||||
BasePage.__init__(self, title, options, archive, media_list, levels)
|
||||
of = self.create_link_file(handle,"img")
|
||||
|
||||
newpath = photo.gramps_id + os.path.splitext(photo.get_path())[1]
|
||||
if self.image_dir:
|
||||
newpath = os.path.join(self.image_dir,newpath)
|
||||
newpath = os.path.join('images',newpath)
|
||||
if self.archive:
|
||||
imagefile = open(photo.get_path(),"r")
|
||||
self.archive.add_file(newpath,time.time(),imagefile)
|
||||
@@ -516,7 +615,8 @@ class MediaPage(BasePage):
|
||||
os.path.join(self.html_dir,newpath))
|
||||
|
||||
title = photo.get_description()
|
||||
self.display_header(of, "%s - %s" % (_('Gallery'), title), get_researcher().get_name())
|
||||
self.display_header(of, "%s - %s" % (_('Gallery'), title),
|
||||
get_researcher().get_name(),up=True)
|
||||
|
||||
of.write('<div class="summaryarea">\n')
|
||||
of.write('<h3>%s</h3>\n' % title)
|
||||
@@ -524,12 +624,13 @@ class MediaPage(BasePage):
|
||||
# gallery navigation
|
||||
of.write('<div class="img_navbar">')
|
||||
if prev:
|
||||
of.write('<a href="%s.%s">%s</a>' % (prev,self.ext,_('Previous')))
|
||||
self.media_ref_link(of,prev,_('Previous'),True)
|
||||
data = _('%(page_number)d of %(total_pages)d' % {
|
||||
'page_number' : page_number, 'total_pages' : total_pages })
|
||||
of.write(' %s ' % data)
|
||||
if next:
|
||||
of.write('<a href="%s.%s">%s</a>' % (next,self.ext,_('Next')))
|
||||
self.media_ref_link(of,next,_('Next'),True)
|
||||
|
||||
of.write('</div><br>\n')
|
||||
|
||||
mime_type = photo.get_mime_type()
|
||||
@@ -537,7 +638,7 @@ class MediaPage(BasePage):
|
||||
try:
|
||||
of.write('<div align="center">\n')
|
||||
of.write('<img border="0" ')
|
||||
of.write('src="%s" alt="%s"/>' % (newpath, title))
|
||||
of.write('src="../../%s" alt="%s"/>' % (newpath, title))
|
||||
of.write('</div>\n')
|
||||
except (IOError,OSError),msg:
|
||||
ErrorDialog(str(msg))
|
||||
@@ -568,8 +669,9 @@ class MediaPage(BasePage):
|
||||
#------------------------------------------------------------------------
|
||||
class SurnameListPage(BasePage):
|
||||
|
||||
def __init__(self, db, title, person_handle_list, options, archive, media_list):
|
||||
BasePage.__init__(self, title, options, archive, media_list)
|
||||
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_file("surnames")
|
||||
self.display_header(of,_('Surnames'),
|
||||
get_researcher().get_name())
|
||||
@@ -625,8 +727,8 @@ class SurnameListPage(BasePage):
|
||||
#------------------------------------------------------------------------
|
||||
class IntroductionPage(BasePage):
|
||||
|
||||
def __init__(self, db, title, options, archive, media_list):
|
||||
BasePage.__init__(self, title, options, archive, media_list)
|
||||
def __init__(self, db, title, options, archive, media_list, levels):
|
||||
BasePage.__init__(self, title, options, archive, media_list, levels)
|
||||
note_id = options.handler.options_dict['NWEBintronote']
|
||||
|
||||
of = self.create_file("introduction")
|
||||
@@ -670,8 +772,8 @@ class IntroductionPage(BasePage):
|
||||
#------------------------------------------------------------------------
|
||||
class HomePage(BasePage):
|
||||
|
||||
def __init__(self, db, title, options, archive, media_list):
|
||||
BasePage.__init__(self, title, options, archive, media_list)
|
||||
def __init__(self, db, title, options, archive, media_list, levels):
|
||||
BasePage.__init__(self, title, options, archive, media_list, levels)
|
||||
note_id = options.handler.options_dict['NWEBhomenote']
|
||||
|
||||
of = self.create_file("index")
|
||||
@@ -715,8 +817,9 @@ class HomePage(BasePage):
|
||||
#------------------------------------------------------------------------
|
||||
class SourcesPage(BasePage):
|
||||
|
||||
def __init__(self, db, title, handle_set, options, archive, media_list):
|
||||
BasePage.__init__(self, title, options, archive, media_list)
|
||||
def __init__(self, db, title, handle_set, options, archive, media_list,
|
||||
levels):
|
||||
BasePage.__init__(self, title, options, archive, media_list, levels)
|
||||
|
||||
of = self.create_file("sources")
|
||||
self.display_header(of,_('Sources'),
|
||||
@@ -737,9 +840,8 @@ class SourcesPage(BasePage):
|
||||
source = db.get_source_from_handle(handle)
|
||||
of.write('<tr><td class="category">%d.</td>\n' % index)
|
||||
of.write('<td class="data">')
|
||||
of.write('<a href="%s.%s">' % (handle,self.ext))
|
||||
of.write('%s <span class="grampsid">[%s]</span>' % (source.get_title(),source.gramps_id))
|
||||
of.write('</a></td></tr>\n')
|
||||
self.source_link(of,handle,source.get_title(),source.gramps_id)
|
||||
of.write('</td></tr>\n')
|
||||
index += 1
|
||||
|
||||
of.write('</table>\n</blockquote>\n')
|
||||
@@ -754,12 +856,14 @@ class SourcesPage(BasePage):
|
||||
#------------------------------------------------------------------------
|
||||
class SourcePage(BasePage):
|
||||
|
||||
def __init__(self, db, title, handle, src_list, options, archive, media_list):
|
||||
def __init__(self, db, title, handle, src_list, options, archive,
|
||||
media_list, levels):
|
||||
source = db.get_source_from_handle( handle)
|
||||
BasePage.__init__(self, title, options, archive, media_list)
|
||||
of = self.create_file(source.get_handle())
|
||||
BasePage.__init__(self, title, options, archive, media_list, levels)
|
||||
of = self.create_link_file(source.get_handle(),"src")
|
||||
source_name = source.get_title()
|
||||
self.display_header(of,"%s - %s" % (_('Sources'), source_name),get_researcher().get_name())
|
||||
self.display_header(of,"%s - %s" % (_('Sources'), source_name),
|
||||
get_researcher().get_name(),up=True)
|
||||
|
||||
self.display_first_image_as_thumbnail(of, db, source.get_media_list())
|
||||
|
||||
@@ -795,8 +899,8 @@ class SourcePage(BasePage):
|
||||
#------------------------------------------------------------------------
|
||||
class GalleryPage(BasePage):
|
||||
|
||||
def __init__(self, db, title, handle_set, options, archive, media_list):
|
||||
BasePage.__init__(self, title, options, archive, media_list)
|
||||
def __init__(self, db, title, handle_set, options, archive, media_list, levels):
|
||||
BasePage.__init__(self, title, options, archive, media_list, levels)
|
||||
|
||||
of = self.create_file("gallery")
|
||||
self.display_header(of, _('Gallery'), get_researcher().get_name())
|
||||
@@ -816,9 +920,7 @@ class GalleryPage(BasePage):
|
||||
media = db.get_object_from_handle(handle)
|
||||
of.write('<tr><td class="category">%d.</td>\n' % index)
|
||||
of.write('<td class="data">')
|
||||
of.write('<a href="%s.%s">' % (handle,self.ext))
|
||||
of.write(media.get_description())
|
||||
of.write('</a>\n')
|
||||
self.media_ref_link(of,handle,media.get_description())
|
||||
of.write('</td></tr>\n')
|
||||
index += 1
|
||||
|
||||
@@ -843,8 +945,8 @@ class GalleryPage(BasePage):
|
||||
#------------------------------------------------------------------------
|
||||
class DownloadPage(BasePage):
|
||||
|
||||
def __init__(self, db, title, options, archive, media_list):
|
||||
BasePage.__init__(self, title, options, archive, media_list)
|
||||
def __init__(self, db, title, options, archive, media_list, levels):
|
||||
BasePage.__init__(self, title, options, archive, media_list, levels)
|
||||
|
||||
of = self.create_file("download")
|
||||
self.display_header(of,_('Download'),
|
||||
@@ -862,8 +964,8 @@ class DownloadPage(BasePage):
|
||||
#------------------------------------------------------------------------
|
||||
class ContactPage(BasePage):
|
||||
|
||||
def __init__(self, db, title, options, archive, media_list):
|
||||
BasePage.__init__(self, title, options, archive, media_list)
|
||||
def __init__(self, db, title, options, archive, media_list, levels):
|
||||
BasePage.__init__(self, title, options, archive, media_list, levels)
|
||||
|
||||
of = self.create_file("contact")
|
||||
self.display_header(of,_('Contact'),
|
||||
@@ -934,9 +1036,9 @@ class IndividualPage(BasePage):
|
||||
RelLib.Person.UNKNOWN : const.unknown,
|
||||
}
|
||||
|
||||
def __init__(self, db, person, title, ind_list,
|
||||
place_list, src_list, options, archive, media_list):
|
||||
BasePage.__init__(self, title, options, archive, media_list)
|
||||
def __init__(self, db, person, title, ind_list, place_list, src_list,
|
||||
options, archive, media_list, levels):
|
||||
BasePage.__init__(self, title, options, archive, media_list, levels)
|
||||
self.person = person
|
||||
self.db = db
|
||||
self.ind_list = ind_list
|
||||
@@ -946,9 +1048,9 @@ class IndividualPage(BasePage):
|
||||
self.sort_name = sort_nameof(self.person,self.private)
|
||||
self.name = sort_nameof(self.person,self.private)
|
||||
|
||||
of = self.create_file(person.handle)
|
||||
of = self.create_link_file(person.handle,"ppl")
|
||||
self.display_header(of, self.sort_name,
|
||||
get_researcher().get_name())
|
||||
get_researcher().get_name(),up=True)
|
||||
self.display_ind_general(of)
|
||||
self.display_ind_events(of)
|
||||
self.display_attr_list(of, self.person.get_attribute_list())
|
||||
@@ -975,7 +1077,7 @@ class IndividualPage(BasePage):
|
||||
sreflist = self.src_refs + self.person.get_source_references()
|
||||
if not sreflist:
|
||||
return
|
||||
of.write('<h4>%s</h4>\n' % _('Source Referencess'))
|
||||
of.write('<h4>%s</h4>\n' % _('Source References'))
|
||||
of.write('<hr>\n')
|
||||
of.write('<table class="infolist" cellpadding="0" ')
|
||||
of.write('cellspacing="0" border="0">\n')
|
||||
@@ -992,8 +1094,8 @@ class IndividualPage(BasePage):
|
||||
source = self.db.get_source_from_handle(shandle)
|
||||
title = source.get_title()
|
||||
of.write('<tr><td class="field"><a name="sref%d">%d.</a></td>' % (index,index))
|
||||
of.write('<td class="field"><a href="%s.%s">' % (source.handle,self.ext))
|
||||
of.write('%s <span class="grampsid">[%s]</span>' %(title,source.gramps_id))
|
||||
of.write('<td class="field">')
|
||||
self.source_link(of,source.handle,title,source.gramps_id,True)
|
||||
of.write('</a>')
|
||||
tmp = []
|
||||
for (label,data) in [(_('Page'),sref.page),
|
||||
@@ -1135,12 +1237,10 @@ class IndividualPage(BasePage):
|
||||
child = self.db.get_person_from_handle(child_handle)
|
||||
gid = child.get_gramps_id()
|
||||
if use_link:
|
||||
of.write('<a href="%s.%s">' % (child.handle,self.ext))
|
||||
of.write(nameof(child,self.private))
|
||||
if not self.noid:
|
||||
of.write(' <span class="grampsid">[%s]</span>' % gid)
|
||||
if use_link:
|
||||
of.write('</a>\n')
|
||||
self.person_link(of,child_handle,nameof(child,self.private),
|
||||
gid,True)
|
||||
else:
|
||||
of.write(nameof(child,self.private))
|
||||
of.write(u"<br>\n")
|
||||
|
||||
def display_parent(self, of, handle, title, rel):
|
||||
@@ -1150,12 +1250,10 @@ class IndividualPage(BasePage):
|
||||
of.write('<td class="data">')
|
||||
val = person.gramps_id
|
||||
if use_link:
|
||||
of.write('<a href="%s.%s">' % (person.handle,self.ext))
|
||||
of.write(nameof(person,self.private))
|
||||
if not self.noid:
|
||||
of.write(' <span class="grampsid">[%s]</span>' % (val))
|
||||
if use_link:
|
||||
of.write('</a>')
|
||||
self.person_link(of,handle,nameof(person,self.private),
|
||||
val,up=True)
|
||||
else:
|
||||
of.write(nameof(person,self.private))
|
||||
if rel != RelLib.Person.CHILD_REL_BIRTH:
|
||||
of.write(' (%s)' % const.child_rel_list[rel])
|
||||
of.write('</td>\n')
|
||||
@@ -1258,13 +1356,10 @@ class IndividualPage(BasePage):
|
||||
use_link = spouse_id in self.ind_list
|
||||
gid = spouse.get_gramps_id()
|
||||
if use_link:
|
||||
of.write('<a href="%s.%s">' % (spouse.handle,self.ext))
|
||||
of.write(name)
|
||||
if not self.noid:
|
||||
of.write(' <span class="grampsid">[%s]</span>' % (gid))
|
||||
if use_link:
|
||||
of.write('</a>')
|
||||
|
||||
self.person_link(of,spouse.handle,nameof(spouse,self.private),
|
||||
gid,True)
|
||||
else:
|
||||
of.write(name)
|
||||
of.write('</td>\n</tr>\n')
|
||||
|
||||
for event_id in family.get_event_list():
|
||||
@@ -1299,10 +1394,10 @@ class IndividualPage(BasePage):
|
||||
person_link = person.handle in self.ind_list
|
||||
of.write('%s ' % bullet)
|
||||
if person_link:
|
||||
of.write('<a href="%s.%s">' % (person.handle,self.ext))
|
||||
of.write(nameof(person,self.private))
|
||||
if person_link:
|
||||
of.write('</a>')
|
||||
self.person_link(of,person.handle,nameof(person,self.private),
|
||||
up=True)
|
||||
else:
|
||||
of.write(nameof(person,self.private))
|
||||
of.write('<br>\n')
|
||||
|
||||
def pedigree_family(self,of):
|
||||
@@ -1342,7 +1437,9 @@ class IndividualPage(BasePage):
|
||||
else:
|
||||
self.place_list[place_handle] = [self.person.handle]
|
||||
|
||||
place = '<a href="%s.%s">%s</a>' % (place_handle,self.ext,ReportUtils.place_name(self.db,place_handle))
|
||||
place = self.place_link_str(place_handle,
|
||||
ReportUtils.place_name(self.db,place_handle),
|
||||
up=True)
|
||||
else:
|
||||
place = u""
|
||||
|
||||
@@ -1401,7 +1498,6 @@ class WebReport(Report.Report):
|
||||
NWEBplaceidx
|
||||
NWEBshorttree
|
||||
NWEBidxcol
|
||||
NWEBimagedir
|
||||
NWEBincid
|
||||
NWEBidurl
|
||||
NWEBlinktidx
|
||||
@@ -1425,6 +1521,7 @@ class WebReport(Report.Report):
|
||||
self.filter = filters[filter_num]
|
||||
|
||||
self.target_path = options_class.handler.options_dict['NWEBod']
|
||||
self.copyright = options_class.handler.options_dict['NWEBcopyright']
|
||||
self.ext = options_class.handler.options_dict['NWEBext']
|
||||
self.encoding = options_class.handler.options_dict['NWEBencoding']
|
||||
self.css = options_class.handler.options_dict['NWEBcss']
|
||||
@@ -1434,7 +1531,6 @@ class WebReport(Report.Report):
|
||||
self.private = options_class.handler.options_dict['NWEBincpriv']
|
||||
self.noid = options_class.handler.options_dict['NWEBnoid']
|
||||
self.srccomments = options_class.handler.options_dict['NWEBcmtxtsi']
|
||||
self.image_dir = options_class.handler.options_dict['NWEBimagedir']
|
||||
self.title = options_class.handler.options_dict['NWEBtitle']
|
||||
self.separate_alpha = options_class.handler.options_dict['NWEBsplita']
|
||||
self.depth = options_class.handler.options_dict['NWEBtreed']
|
||||
@@ -1472,10 +1568,7 @@ class WebReport(Report.Report):
|
||||
dir_name)
|
||||
return
|
||||
|
||||
if self.image_dir:
|
||||
image_dir_name = os.path.join(dir_name, self.image_dir)
|
||||
else:
|
||||
image_dir_name = dir_name
|
||||
image_dir_name = os.path.join(dir_name, 'images')
|
||||
if not os.path.isdir(image_dir_name) and self.photos != 0:
|
||||
try:
|
||||
os.mkdir(image_dir_name)
|
||||
@@ -1513,18 +1606,24 @@ class WebReport(Report.Report):
|
||||
self.write_css(archive,self.target_path,self.css)
|
||||
|
||||
photo_list = []
|
||||
|
||||
if len(ind_list) > 9000:
|
||||
levels = 2
|
||||
else:
|
||||
levels = 1
|
||||
|
||||
HomePage(self.database, self.title, self.options_class, archive, photo_list)
|
||||
HomePage(self.database, self.title, self.options_class, archive,
|
||||
photo_list, levels)
|
||||
if self.inc_contact:
|
||||
ContactPage(self.database, self.title, self.options_class,
|
||||
archive, photo_list)
|
||||
archive, photo_list, levels)
|
||||
if self.inc_download:
|
||||
DownloadPage(self.database, self.title, self.options_class,
|
||||
archive, photo_list)
|
||||
archive, photo_list, levels)
|
||||
|
||||
if self.use_intro:
|
||||
IntroductionPage(self.database, self.title, self.options_class,
|
||||
archive, photo_list)
|
||||
archive, photo_list, levels)
|
||||
|
||||
place_list = {}
|
||||
source_list = {}
|
||||
@@ -1536,36 +1635,40 @@ class WebReport(Report.Report):
|
||||
|
||||
idoc = IndividualPage(self.database, person, self.title,
|
||||
ind_list, place_list, source_list,
|
||||
self.options_class, archive, photo_list)
|
||||
self.options_class, archive,
|
||||
photo_list, levels)
|
||||
self.progress_bar_step()
|
||||
while gtk.events_pending():
|
||||
gtk.main_iteration()
|
||||
|
||||
if len(ind_list) > 1:
|
||||
IndividualListPage(self.database, self.title, ind_list,
|
||||
self.options_class, archive, photo_list)
|
||||
self.options_class, archive, photo_list,
|
||||
levels)
|
||||
SurnameListPage(self.database, self.title, ind_list,
|
||||
self.options_class, archive, photo_list)
|
||||
self.options_class, archive, photo_list,
|
||||
levels)
|
||||
self.progress_bar_step()
|
||||
while gtk.events_pending():
|
||||
gtk.main_iteration()
|
||||
|
||||
PlaceListPage(self.database, self.title, place_list,
|
||||
source_list,self.options_class, archive, photo_list)
|
||||
source_list,self.options_class, archive,
|
||||
photo_list, levels)
|
||||
|
||||
for place in place_list.keys():
|
||||
PlacePage(self.database, self.title, place, source_list, place_list,
|
||||
self.options_class, archive, photo_list)
|
||||
self.options_class, archive, photo_list, levels)
|
||||
|
||||
SourcesPage(self.database,self.title, source_list.keys(), self.options_class,
|
||||
archive, photo_list)
|
||||
archive, photo_list, levels)
|
||||
|
||||
for key in list(source_list):
|
||||
SourcePage(self.database,self.title, key, source_list, self.options_class,
|
||||
archive, photo_list)
|
||||
archive, photo_list, levels)
|
||||
|
||||
GalleryPage(self.database, self.title, source_list, self.options_class,
|
||||
archive, photo_list)
|
||||
archive, photo_list, levels)
|
||||
|
||||
prev = None
|
||||
total = len(photo_list)
|
||||
@@ -1577,7 +1680,7 @@ class WebReport(Report.Report):
|
||||
next = photo_list[index]
|
||||
MediaPage(self.database, self.title, photo_handle, source_list,
|
||||
self.options_class, archive, photo_list,
|
||||
(prev, next, index, total))
|
||||
(prev, next, index, total), levels)
|
||||
prev = photo_handle
|
||||
index += 1
|
||||
|
||||
@@ -1617,6 +1720,7 @@ class WebReportOptions(ReportOptions.ReportOptions):
|
||||
self.options_dict = {
|
||||
'NWEBarchive' : 0,
|
||||
'NWEBod' : './',
|
||||
'NWEBcopyright' : 0,
|
||||
'NWEBimg' : 2,
|
||||
'NWEBrestrictinfo' : 0,
|
||||
'NWEBincpriv' : 0,
|
||||
@@ -1627,7 +1731,6 @@ class WebReportOptions(ReportOptions.ReportOptions):
|
||||
'NWEBcontact' : '',
|
||||
'NWEBdownload' : 0,
|
||||
'NWEBshorttree' : 1,
|
||||
'NWEBimagedir' : 'images',
|
||||
'NWEBtitle' : _('My Family Tree'),
|
||||
'NWEBincid' : 0,
|
||||
'NWEBidurl' : '',
|
||||
@@ -1725,9 +1828,6 @@ class WebReportOptions(ReportOptions.ReportOptions):
|
||||
self.no_comments = gtk.CheckButton(no_com_msg)
|
||||
self.no_comments.set_active(not self.options_dict['NWEBcmtxtsi'])
|
||||
|
||||
self.imgdir = gtk.Entry()
|
||||
self.imgdir.set_text(self.options_dict['NWEBimagedir'])
|
||||
|
||||
self.intro_note = gtk.Entry()
|
||||
self.intro_note.set_text(self.options_dict['NWEBintronote'])
|
||||
|
||||
@@ -1743,9 +1843,26 @@ class WebReportOptions(ReportOptions.ReportOptions):
|
||||
for text in self.ext_options:
|
||||
self.ext.append_text(text)
|
||||
|
||||
self.copy = gtk.combo_box_new_text()
|
||||
self.copy_options = [
|
||||
_('Standard copyright'),
|
||||
_('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-commerical, Share-alike'),
|
||||
_('No copyright notice'),
|
||||
]
|
||||
for text in self.copy_options:
|
||||
self.copy.append_text(text)
|
||||
|
||||
def_ext = "." + self.options_dict['NWEBext']
|
||||
self.ext.set_active(self.ext_options.index(def_ext))
|
||||
|
||||
index = self.options_dict['NWEBcopyright']
|
||||
self.copy.set_active(index)
|
||||
|
||||
cset_node = None
|
||||
cset = self.options_dict['NWEBencoding']
|
||||
|
||||
@@ -1768,10 +1885,10 @@ class WebReportOptions(ReportOptions.ReportOptions):
|
||||
self.css = GrampsNoteComboBox(store,cset_node)
|
||||
|
||||
dialog.add_option(title_msg,self.title)
|
||||
dialog.add_option(imgdir_msg,self.imgdir)
|
||||
dialog.add_option(ext_msg,self.ext)
|
||||
dialog.add_option(_('Character set encoding'),self.encoding)
|
||||
dialog.add_option(_('Stylesheet'),self.css)
|
||||
dialog.add_option(_('Copyright'),self.copy)
|
||||
|
||||
title = _("Page Generation")
|
||||
|
||||
@@ -1805,6 +1922,7 @@ class WebReportOptions(ReportOptions.ReportOptions):
|
||||
dialog.add_frame_option(title,None,self.no_comments)
|
||||
self.no_images.connect('toggled',self.on_nophotos_toggled)
|
||||
|
||||
|
||||
def parse_user_options(self,dialog):
|
||||
"""Parse the privacy options frame of the dialog. Save the
|
||||
user selected choices for later use."""
|
||||
@@ -1814,7 +1932,6 @@ class WebReportOptions(ReportOptions.ReportOptions):
|
||||
self.options_dict['NWEBnoid'] = int(self.noid.get_active())
|
||||
self.options_dict['NWEBcontact'] = unicode(self.contact.get_handle())
|
||||
self.options_dict['NWEBdownload'] = int(self.inc_download.get_active())
|
||||
self.options_dict['NWEBimagedir'] = unicode(self.imgdir.get_text())
|
||||
self.options_dict['NWEBtitle'] = unicode(self.title.get_text())
|
||||
self.options_dict['NWEBintronote'] = unicode(self.intro_note.get_handle())
|
||||
self.options_dict['NWEBhomenote'] = unicode(self.home_note.get_handle())
|
||||
@@ -1841,6 +1958,7 @@ class WebReportOptions(ReportOptions.ReportOptions):
|
||||
photos = 2
|
||||
self.options_dict['NWEBimg'] = photos
|
||||
self.options_dict['NWEBod'] = dialog.target_path
|
||||
self.options_dict['NWEBcopyright'] = self.copy.get_active()
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
|
Reference in New Issue
Block a user