def PrintMedia(self, thumbs, mediapath): """ Print some media infos via HTML class (Gramps) """ LOG.info('Looking at media...') # Web page filename extensions _WEB_EXT = ['.html', '.htm', '.shtml', '.php', '.php3', '.cgi'] # page title title = _('Gallery') fname = os.path.join(USER_PLUGINS, 'lxml', _('Gallery.html')) of = open(fname, "w") LOG.info('Empty "Gallery.hml" file created') # htmlinstance = page # ignored by current code... lang = xml_lang() page, head, body = Html.page(title, encoding='utf-8', lang=str(lang)) head = body = "" self.text = [] self.XHTMLWriter(fname, page, head, body, of, thumbs, mediapath) LOG.info('End (Media)')
def open(self): """ overwrite method, htmlbackend creates a html object that is written on close """ try: DocBackend.open(self) except IOError as msg: errmsg = "%s\n%s" % (_("Could not create %s") % self._filename, msg) raise ReportError(errmsg) except: raise ReportError(_("Could not create %s") % self._filename) if not os.path.isdir(self.datadirfull()): try: os.mkdir(self.datadirfull()) except IOError as msg: errmsg = "%s\n%s" % (_("Could not create %s") % self.datadirfull(), msg) raise ReportError(errmsg) except: raise ReportError(_("Could not create %s") % self.datadirfull()) self.html_page, self.html_header, self.html_body = Html.page( lang=xml_lang(), title=self.title)
def PrintMedia(self, thumbs, mediapath): """ Print some media infos via HTML class (Gramps) """ LOG.info("Looking at media...") # Web page filename extensions _WEB_EXT = [".html", ".htm", ".shtml", ".php", ".php3", ".cgi"] # page title title = _("Gallery") fname = os.path.join(USER_PLUGINS, "lxml", _("Gallery.html")) of = open(fname, "w") LOG.info('Empty "Gallery.hml" file created') # htmlinstance = page # ignored by current code... lang = xml_lang() page, head, body = Html.page(title, encoding="utf-8", lang=str(lang)) head = body = "" self.text = [] self.XHTMLWriter(fname, page, head, body, of, thumbs, mediapath) LOG.info("End (Media)")
def __init__(self, report, langs): """ Create an index for multi language. We will be redirected to the good page depending of the browser language. If the browser language is unknown, we use the first defined in the display tab of the narrative web configuration. @param: report -- The instance of the main report class for this report @param: langs -- The languages to process """ BasePage.__init__(self, report, None, "index") output_file, sio = report.create_file("index", ext="index") page, head, body = Html.page('index', self.report.encoding, langs[0][0]) body.attr = ' onload="lang();"' my_langs = "[" for lang in langs: my_langs += "'" + lang[0].replace('_', '-') my_langs += "', " my_langs += "]" with Html("script", type="text/javascript") as jsc: head += jsc jsc += REDIRECT % (my_langs, self.ext) # send page out for processing # and close the file self.xhtml_writer(page, output_file, sio, 0) self.report.close_file(output_file, sio, 0)