diff --git a/configure.in b/configure.in
index acb426635..97cd68685 100644
--- a/configure.in
+++ b/configure.in
@@ -169,7 +169,6 @@ src/gen/plug/docbackend/Makefile
src/gen/plug/docgen/Makefile
src/gen/plug/menu/Makefile
src/data/Makefile
-src/data/templates/Makefile
src/glade/Makefile
src/images/Makefile
src/images/scalable/Makefile
diff --git a/src/data/templates/Makefile.am b/src/data/templates/Makefile.am
deleted file mode 100644
index be78b1a3c..000000000
--- a/src/data/templates/Makefile.am
+++ /dev/null
@@ -1,10 +0,0 @@
-# This is the src/data/templates level Makefile
-pkgdata_DATA = marble.tpkg \
- pink_marble.tpkg \
- sepia.tpkg \
- sky_border.tpkg \
- blue_edge.tpkg \
- templates.xml
-
-pkgdatadir = $(datadir)/@PACKAGE@/data/templates
-EXTRA_DIST = $(pkgdata_DATA)
diff --git a/src/data/templates/blue_edge.tpkg b/src/data/templates/blue_edge.tpkg
deleted file mode 100644
index 3e47f85ca..000000000
Binary files a/src/data/templates/blue_edge.tpkg and /dev/null differ
diff --git a/src/data/templates/marble.tpkg b/src/data/templates/marble.tpkg
deleted file mode 100644
index 5e95afc9e..000000000
Binary files a/src/data/templates/marble.tpkg and /dev/null differ
diff --git a/src/data/templates/pink_marble.tpkg b/src/data/templates/pink_marble.tpkg
deleted file mode 100644
index e24a45c27..000000000
Binary files a/src/data/templates/pink_marble.tpkg and /dev/null differ
diff --git a/src/data/templates/sepia.tpkg b/src/data/templates/sepia.tpkg
deleted file mode 100644
index b885fa94e..000000000
Binary files a/src/data/templates/sepia.tpkg and /dev/null differ
diff --git a/src/data/templates/sky_border.tpkg b/src/data/templates/sky_border.tpkg
deleted file mode 100644
index cd1f9fac1..000000000
Binary files a/src/data/templates/sky_border.tpkg and /dev/null differ
diff --git a/src/data/templates/templates.xml b/src/data/templates/templates.xml
deleted file mode 100644
index c85628f8e..000000000
--- a/src/data/templates/templates.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/src/docgen/TextBufDoc.py b/src/docgen/TextBufDoc.py
index 5197e38ef..cc05342af 100644
--- a/src/docgen/TextBufDoc.py
+++ b/src/docgen/TextBufDoc.py
@@ -315,7 +315,7 @@ class TextBufDoc(BaseDoc, TextDoc):
if self.cell_lines[self.cellnum] > self.maxlines:
self.maxlines = self.cell_lines[self.cellnum]
- def add_media_object(self, name, align, w_cm, h_cm):
+ def add_media_object(self, name, align, w_cm, h_cm, alt=''):
return
this_text = '(photo)'
diff --git a/src/gen/plug/docbackend/cairobackend.py b/src/gen/plug/docbackend/cairobackend.py
index 187c0e445..d71edb3ea 100644
--- a/src/gen/plug/docbackend/cairobackend.py
+++ b/src/gen/plug/docbackend/cairobackend.py
@@ -49,7 +49,7 @@ from docbackend import DocBackend
#
#------------------------------------------------------------------------
import logging
-log = logging.getLogger(".cairobackend.py")
+LOG = logging.getLogger(".cairobackend.py")
#------------------------------------------------------------------------
#
@@ -89,17 +89,17 @@ class CairoBackend(DocBackend):
ESCAPE_FUNC = lambda x: escape
- def _create_xmltag(self, type, value):
+ def _create_xmltag(self, tagtype, value):
"""
overwrites the method in DocBackend
creates the pango xml tags needed for non bool style types
"""
- if type not in self.SUPPORTED_MARKUP:
+ if tagtype not in self.SUPPORTED_MARKUP:
return None
- if type == DocBackend.FONTSIZE:
+ if tagtype == DocBackend.FONTSIZE:
#size is in thousandths of a point in pango
value = str(1000 * value)
- return ('' % (self.STYLETAG_TO_PROPERTY[type],
+ return ('' % (self.STYLETAG_TO_PROPERTY[tagtype],
self.ESCAPE_FUNC()(value)),
'')
diff --git a/src/gen/plug/docbackend/docbackend.py b/src/gen/plug/docbackend/docbackend.py
index df043faaa..08df27f31 100644
--- a/src/gen/plug/docbackend/docbackend.py
+++ b/src/gen/plug/docbackend/docbackend.py
@@ -48,7 +48,7 @@ from gettext import gettext as _
#
#------------------------------------------------------------------------
import logging
-log = logging.getLogger(".docbackend.py")
+LOG = logging.getLogger(".docbackend.py")
#------------------------------------------------------------------------
#
@@ -57,6 +57,9 @@ log = logging.getLogger(".docbackend.py")
#------------------------------------------------------------------------
def noescape(text):
+ """
+ Function that does not escape the text passed. Default for backends
+ """
return text
#-------------------------------------------------------------------------
@@ -122,9 +125,17 @@ class DocBackend(object):
self._filename = filename
def getf(self):
+ """
+ Obtain the filename on which backend writes
+ """
return self._filename
def setf(self, value):
+ """
+ Set the filename on which the backend writes, changing the value
+ passed on initialization
+ Can only be done if the previous filename is not open
+ """
if self.__file is not None:
raise ValueError, _('Close file first')
self._filename = value
@@ -156,17 +167,20 @@ class DocBackend(object):
pass
def close(self):
+ """
+ Closes the file that is written on.
+ """
if self.__file is None:
raise IOError, 'No file open'
self.__file.close()
self.__file = None
- def write(self, str):
+ def write(self, string):
"""Write a string to the file. There is no return value.
Due to buffering, the string may not actually show up untill the
close() method is called.
"""
- self.__file.write(str)
+ self.__file.write(string)
def writelines(self, sequence):
"""Write a sequence of strings to the file. The sequence can be any
@@ -197,28 +211,28 @@ class DocBackend(object):
If a markup is not present yet, it is created, using the
_create_xmltag method you can overwrite
"""
- type = s_tag.name
+ tagtype = s_tag.name
if not self.STYLETYPE_MAP or \
- self.CLASSMAP <> type.__class__.__name__ :
- self.CLASSMAP == type.__class__.__name__
- self.STYLETYPE_MAP[type.__class__.BOLD] = self.BOLD
- self.STYLETYPE_MAP[type.ITALIC] = self.ITALIC
- self.STYLETYPE_MAP[type.UNDERLINE] = self.UNDERLINE
- self.STYLETYPE_MAP[type.FONTFACE] = self.FONTFACE
- self.STYLETYPE_MAP[type.FONTSIZE] = self.FONTSIZE
- self.STYLETYPE_MAP[type.FONTCOLOR] = self.FONTCOLOR
- self.STYLETYPE_MAP[type.HIGHLIGHT] = self.HIGHLIGHT
- self.STYLETYPE_MAP[type.SUPERSCRIPT] = self.SUPERSCRIPT
+ self.CLASSMAP != tagtype.__class__.__name__ :
+ self.CLASSMAP == tagtype.__class__.__name__
+ self.STYLETYPE_MAP[tagtype.__class__.BOLD] = self.BOLD
+ self.STYLETYPE_MAP[tagtype.ITALIC] = self.ITALIC
+ self.STYLETYPE_MAP[tagtype.UNDERLINE] = self.UNDERLINE
+ self.STYLETYPE_MAP[tagtype.FONTFACE] = self.FONTFACE
+ self.STYLETYPE_MAP[tagtype.FONTSIZE] = self.FONTSIZE
+ self.STYLETYPE_MAP[tagtype.FONTCOLOR] = self.FONTCOLOR
+ self.STYLETYPE_MAP[tagtype.HIGHLIGHT] = self.HIGHLIGHT
+ self.STYLETYPE_MAP[tagtype.SUPERSCRIPT] = self.SUPERSCRIPT
typeval = int(s_tag.name)
s_tagvalue = s_tag.value
tag_name = None
- if type.STYLE_TYPE[typeval] == bool:
+ if tagtype.STYLE_TYPE[typeval] == bool:
return self.STYLETAG_MARKUP[self.STYLETYPE_MAP[typeval]]
- elif type.STYLE_TYPE[typeval] == str:
+ elif tagtype.STYLE_TYPE[typeval] == str:
tag_name = "%d %s" % (typeval, s_tagvalue)
- elif type.STYLE_TYPE[typeval] == int:
+ elif tagtype.STYLE_TYPE[typeval] == int:
tag_name = "%d %d" % (typeval, s_tagvalue)
if not tag_name:
return None
@@ -231,12 +245,12 @@ class DocBackend(object):
self.STYLETAG_MARKUP[tag_name] = tags
return tags
- def _create_xmltag(self, type, value):
+ def _create_xmltag(self, tagtype, value):
"""
Create the xmltags for the backend.
Overwrite this method to create functionality with a backend
"""
- if type not in self.SUPPORTED_MARKUP:
+ if tagtype not in self.SUPPORTED_MARKUP:
return None
return ('', '')
@@ -283,7 +297,7 @@ class DocBackend(object):
end = len(text)
keylist = tagspos.keys()
keylist.sort()
- keylist = [x for x in keylist if x<=len(text)]
+ keylist = [x for x in keylist if x <= len(text)]
opentags = []
otext = u"" #the output, text with markup
lensplit = len(split)
@@ -293,7 +307,7 @@ class DocBackend(object):
if split:
#make sure text can split
splitpos = text[start:pos].find(split)
- while splitpos <> -1:
+ while splitpos != -1:
otext += self.ESCAPE_FUNC()(text[start:start+splitpos])
#close open tags
for opentag in reversed(opentags):
diff --git a/src/gen/plug/docgen/textdoc.py b/src/gen/plug/docgen/textdoc.py
index a025506a6..51d1a3bd6 100644
--- a/src/gen/plug/docgen/textdoc.py
+++ b/src/gen/plug/docgen/textdoc.py
@@ -225,7 +225,7 @@ class TextDoc(object):
else:
self.write_text(piece)
- def add_media_object(self, name, align, w_cm, h_cm):
+ def add_media_object(self, name, align, w_cm, h_cm, alt=''):
"""
Add a photo of the specified width (in centimeters)
@@ -234,5 +234,6 @@ class TextDoc(object):
'right', 'center', and 'single'
@param w_cm: width in centimeters
@param h_cm: height in centimeters
+ @param alt: an alternative text to use. Usefull for eg html reports
"""
raise NotImplementedError
diff --git a/src/plugins/docgen/AsciiDoc.py b/src/plugins/docgen/AsciiDoc.py
index 3f702dcad..5715ba53f 100644
--- a/src/plugins/docgen/AsciiDoc.py
+++ b/src/plugins/docgen/AsciiDoc.py
@@ -336,7 +336,7 @@ class AsciiDoc(BaseDoc,TextDoc):
if self.cell_lines[self.cellnum] > self.maxlines:
self.maxlines = self.cell_lines[self.cellnum]
- def add_media_object(self, name, align, w_cm, h_cm):
+ def add_media_object(self, name, align, w_cm, h_cm, alt=''):
this_text = '(photo)'
if self.in_cell:
self.cellpars[self.cellnum] = self.cellpars[self.cellnum] + this_text
diff --git a/src/plugins/docgen/HtmlDoc.py b/src/plugins/docgen/HtmlDoc.py
index 0ae36c4a0..53b82f7a5 100644
--- a/src/plugins/docgen/HtmlDoc.py
+++ b/src/plugins/docgen/HtmlDoc.py
@@ -22,13 +22,18 @@
# $Id:HtmlDoc.py 9912 2008-01-22 09:17:46Z acraphae $
+
+"""
+Report output generator for html documents, based on Html and HtmlBackend
+"""
+
#------------------------------------------------------------------------
#
# python modules
#
#------------------------------------------------------------------------
import os
-import re
+import shutil
import time
from gettext import gettext as _
@@ -39,77 +44,42 @@ from gettext import gettext as _
#------------------------------------------------------------------------
from gen.plug import PluginManager, DocGenPlugin
import ImgManip
-import tarfile
import const
-import Errors
from gen.plug.docgen import BaseDoc, TextDoc, FONT_SANS_SERIF
from libhtmlbackend import HtmlBackend
-from QuestionDialog import ErrorDialog, WarningDialog
-import Utils
+from libhtml import Html
+from QuestionDialog import WarningDialog
#------------------------------------------------------------------------
#
-# Constant regular expressions
+# Set up logging
#
#------------------------------------------------------------------------
-t_header_line_re = re.compile(
- r"(.*)(.*)(.*)",
- re.DOTALL|re.IGNORECASE|re.MULTILINE)
-t_keyword_line_re = re.compile(
- r'(.*name="keywords"\s+content=")([^\"]*)(".*)$',
- re.DOTALL|re.IGNORECASE|re.MULTILINE)
-
-#------------------------------------------------------------------------
-#
-# Default template
-#
-#------------------------------------------------------------------------
-_top = [
- '\n',
- '\n',
- '\n',
- ' \n',
- ' \n',
- ' \n',
- ' \n',
- ' \n',
- '\n',
- '\n',
- ' \n'
- ]
-
-_bottom = [
- ' \n',
- '\n',
- '\n'
- ]
+import logging
+LOG = logging.getLogger(".htmldoc")
+_HTMLSCREEN = 'grampshtml.css'
#------------------------------------------------------------------------
#
# HtmlDoc
#
#------------------------------------------------------------------------
class HtmlDoc(BaseDoc, TextDoc):
+ """Implementation of the BaseDoc and TextDoc gen.plug.docgen api for the
+ creation of Html files. This is achieved by writing on a HtmlBackend
+ object
+ """
- def __init__(self,styles,type):
+ def __init__(self, styles, paper_style):
BaseDoc.__init__(self, styles, None)
- self.year = time.localtime(time.time())[0]
- self.ext = '.html'
- self.meta = ""
- self.copyright = 'Copyright © %d' % (self.year)
- self.map = None
- self.f = None
- self.filename = None
- self.base = ""
- self.build_header()
- self.style_declaration = None
- self.image_dir = "images"
+ self.style_declaration = ''
+ self.htmllist = []
+ self._backend = None
+ self.css_filename = None
+ self.warn_dir = True
+ self._col = 0
+ self._tbl = None
+ self._empty = 1
def set_css_filename(self, css_filename):
"""
@@ -118,47 +88,47 @@ class HtmlDoc(BaseDoc, TextDoc):
"""
self.css_filename = css_filename
- def set_extension(self,val):
- if val[0] != '.':
- val = "." + val
- self.ext = val
-
- def set_image_dir(self,dirname):
- self.image_dir = dirname
-
- def set_keywords(self,keywords):
- self.meta = ",".join(keywords)
-
- def process_line(self,line):
- l = line.replace('$VERSION',const.VERSION)
- return l.replace('$COPYRIGHT',self.copyright)
+ def open(self, filename):
+ """
+ Overwrite base method
+ """
+ self._backend = HtmlBackend(filename)
+ #self._backend.set_title(....)
+ self._backend.open()
+ self.htmllist += [self._backend.html_body]
- def open(self,filename):
- (r,e) = os.path.splitext(filename)
- if e == self.ext:
- self.filename = filename
- else:
- self.filename = filename + self.ext
-
- self.base = os.path.dirname(self.filename)
-
- try:
- self.f = open(self.filename,"w")
- except IOError,msg:
- errmsg = "%s\n%s" % (_("Could not create %s") % self.filename, msg)
- raise Errors.ReportError(errmsg)
- except:
- raise Errors.ReportError(_("Could not create %s") % self.filename)
-
- if not self.style_declaration:
- self.build_style_declaration()
- self.f.write(self.style_declaration)
+ self.build_header()
def build_header(self):
- ## TODO REMOVE ??
- pass
+ """
+ Build up the header of the html file over the defaults of Html()
+ """
+ # add additional meta tags and stylesheet links to head section
+ # create additional meta tags
+ _meta1 = 'name="generator" content="%s %s %s"' % (const.PROGRAM_NAME,
+ const.VERSION, const.URL_HOMEPAGE)
+ meta = Html('meta', attr = _meta1)
+
+ #set styles of the report as inline css
+ self.build_style_declaration()
+ self._backend.html_header += self.style_declaration
+
+ # GRAMPS favicon en css
+ fname1 = '/'.join([self._backend.datadir(), 'favicon.ico'])
+ fname2 = '/'.join([self._backend.datadir(), _HTMLSCREEN])
+
+ # links for GRAMPS favicon and stylesheets
+ 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)
+ )
+ self._backend.html_header += (meta, links)
def build_style_declaration(self):
+ """
+ Convert the styles of the report into inline css for the html doc
+ """
styles = self.get_style_sheet()
text = ['