Example #1
0
 def create_article(self, article, prefix=''):
     with open('./src/template/content/article.html') as article_temp:
         template = article_temp.read()
     content = template.format(**article)
     page = Page()
     page.content = self.fix_image(content)
     page.filename = str(prefix) + '_' + str(article['article_id']) + '.html'
     page.title = article['title']
     return page
Example #2
0
 def create_article(self, article, prefix=""):
     with open("./html_template/content/article.html") as article_temp:
         template = article_temp.read()
     content = template.format(**article)
     page = Page()
     page.content = self.fix_image(content)
     page.filename = prefix + str(article["article_id"]) + ".html"
     page.title = article["title"]
     return page
Example #3
0
 def create_info_page(self, book):
     kind = book.kind
     info = book.info
     with open('./src/template/info/{}.html'.format(kind)) as file:
         template = file.read()
     content = template.format(**info)
     page = Page()
     page.content = self.fix_image(content)
     page.filename = str(book.epub.prefix) + '_' + 'info.html'
     page.title = book.epub.title
     if book.epub.split_index:
         page.title += "_({})".format(book.epub.split_index)
     return page
Example #4
0
    def create_question(self, question, prefix=''):
        def create_answer(answer):
            with open('./src/template/content/answer.html') as answer_temp:
                template = answer_temp.read()
            return template.format(**answer)

        answer_content = ''.join([create_answer(answer) for answer in question['answer_list']])
        question['answer_content'] = answer_content
        with open('./src/template/content/question.html') as question_temp:
            template = question_temp.read()
        question.update(question['question'])
        content = template.format(**question)
        page = Page()
        page.content = self.fix_image(content)
        page.filename = str(prefix) + '_' + str(question['question_id']) + '.html'
        page.title = question['title']
        return page
Example #5
0
    def create_question(self, question, prefix=""):
        def create_answer(answer):
            with open("./html_template/content/answer.html") as answer_temp:
                template = answer_temp.read()
            return template.format(**answer)

        answer_content = "".join([create_answer(answer) for answer in question["answer_list"]])
        question["answer_content"] = answer_content
        with open("./html_template/content/question.html") as question_temp:
            template = question_temp.read()
        question.update(question["question"])
        content = template.format(**question)
        page = Page()
        page.content = self.fix_image(content)
        page.filename = str(prefix) + str(question["question_id"]) + ".html"
        page.title = question["title"]
        return page