Example #1
0
 def processTitlePage(self):
     if not any(txt != '' for txt in [self.coll.title,
                                      self.coll.subtitle,
                                      self.coll.editor]):
         return
     titlepage = collection.Chapter(self.coll.title)
     titlepage.id = 'titlepage'
     body_content = [E.h1(self.coll.title,
                          style="margin-top:20%;font-size:200%;text-align:center;"),
                     E.h2(self.coll.subtitle,
                          style="margin-top:1em;font-size:150%;text-align:center;"),
                     E.h3(self.coll.editor,
                          style="margin-top:1em;font-size:100%;text-align:center;"),
                     ]
     if any('wikipedia.org' in url for url in self.coll.url2webpage):
         img_src = 'wikipedia_logo.jpg'
         titlepage.images = {img_src:
                             os.path.join(os.path.dirname(__file__), img_src)}
         body_content.append(E.div(E.img(src='images/'+img_src,
                                         width='50%', alt='',
                                         ),
                                   style='text-align:center;margin-top:4em;'
                                   ))
     tree = misc.xhtml_page(title=self.coll.title,
                            body_content=body_content,
                            flatten=False)
     titlepage.tree = tree
     titlepage.xml = misc.flatten_tree(tree)
     self.container.addArticle(titlepage)
Example #2
0
 def processTitlePage(self):
     if not any(txt != '' for txt in
                [self.coll.title, self.coll.subtitle, self.coll.editor]):
         return
     titlepage = collection.Chapter(self.coll.title)
     titlepage.id = 'titlepage'
     body_content = [
         E.h1(self.coll.title,
              style="margin-top:20%;font-size:200%;text-align:center;"),
         E.h2(self.coll.subtitle,
              style="margin-top:1em;font-size:150%;text-align:center;"),
         E.h3(self.coll.editor,
              style="margin-top:1em;font-size:100%;text-align:center;"),
     ]
     if any('wikipedia.org' in url for url in self.coll.url2webpage):
         img_src = 'wikipedia_logo.jpg'
         titlepage.images = {
             img_src: os.path.join(os.path.dirname(__file__), img_src)
         }
         body_content.append(
             E.div(E.img(
                 src='images/' + img_src,
                 width='50%',
                 alt='',
             ),
                   style='text-align:center;margin-top:4em;'))
     tree = misc.xhtml_page(title=self.coll.title,
                            body_content=body_content,
                            flatten=False)
     titlepage.tree = tree
     titlepage.xml = misc.flatten_tree(tree)
     self.container.addArticle(titlepage)
Example #3
0
    def serializeArticle(self, node):
        assert not node.find('.//body'), 'error: node contains BODY tag'

        html = E.html({'xmlns':"http://www.w3.org/1999/xhtml"},
                      E.head(E.meta({'http-equiv':"Content-Type",
                                     'content': "application/xhtml+xml; charset=utf-8"})
                             ),
                      )

        head = html.find('.//head')
        node_head = node.find('.//head')
        for head_content in node_head.iterchildren():
            head.append(head_content)
        node_head.getparent().remove(node_head)

        body = E.body()
        html.append(body)
        body.extend(node)

        return misc.flatten_tree(html)
Example #4
0
    def serializeArticle(self, node):
        assert not node.find('.//body'), 'error: node contains BODY tag'

        html = E.html(
            {'xmlns': "http://www.w3.org/1999/xhtml"},
            E.head(
                E.meta({
                    'http-equiv': "Content-Type",
                    'content': "application/xhtml+xml; charset=utf-8"
                })),
        )

        head = html.find('.//head')
        node_head = node.find('.//head')
        for head_content in node_head.iterchildren():
            head.append(head_content)
        node_head.getparent().remove(node_head)

        body = E.body()
        html.append(body)
        body.extend(node)

        return misc.flatten_tree(html)