Exemplo n.º 1
0
    def generate_article_page(self, article):
        """
        :type article: src.container.data.article.Article
        :return:
        :rtype:
        """
        answer_content = Template.answer.format(
            **{
                'author_avatar_url': article.author_avatar_url,
                'author_name': article.author_name,
                'author_id': article.author_id,
                'author_headline': article.author_headline,

                'content': article.content,
                'comment_count': article.comment_count,
                'voteup_count': article.voteup_count,
                'updated_time':  ExtraTools.format_date('Y-m-d H:i:s', article.updated_time),
            }
        )

        filename = self.get_random_html_file_name()
        content = Template.question.format(
            **{
                'title': article.title,
                'description': '',
                'answer': answer_content
            }
        )
        uri = Path.html_pool_path + '/' + filename
        buf_file = open(uri, 'w')
        buf_file.write(content)
        buf_file.close()
        return uri
Exemplo n.º 2
0
    def generate_question_page(self, question):
        """
        :type question: src.container.task_result.Question
        :return:
        :rtype:
        """
        # 先输出answer的内容
        answer_content = u''
        for answer in question.answer_list:
            answer_content += Template.answer.format(
                **{
                    'author_avatar_url':
                    answer.author_avatar_url,
                    'author_name':
                    answer.author_name,
                    'author_id':
                    answer.author_id,
                    'author_headline':
                    answer.author_headline,
                    'content':
                    answer.content,
                    'comment_count':
                    answer.comment_count,
                    'voteup_count':
                    answer.voteup_count,
                    'updated_time':
                    ExtraTools.format_date(u'%Y-%m-%d %H:%M:%S',
                                           answer.updated_time),
                })

        filename = self.get_random_html_file_name()
        content = Template.question.format(
            **{
                'title': question.question_info.title,
                'description': question.question_info.detail,
                'answer': answer_content
            })
        uri = Path.html_pool_path + '/' + filename
        buf_file = open(uri, 'w')
        buf_file.write(content)
        buf_file.close()
        return uri
Exemplo n.º 3
0
    def generate_article_page(self, article):
        """
        :type article: src.container.data.article.Article
        :return:
        :rtype:
        """
        answer_content = Template.answer.format(
            **{
                'author_avatar_url':
                article.author_avatar_url,
                'author_name':
                article.author_name,
                'author_id':
                article.author_id,
                'author_headline':
                article.author_headline,
                'content':
                article.content,
                'comment_count':
                article.comment_count,
                'voteup_count':
                article.voteup_count,
                'updated_time':
                ExtraTools.format_date(u'%Y-%m-%d %H:%M:%S',
                                       article.updated_time),
            })

        filename = self.get_random_html_file_name()
        content = Template.question.format(**{
            'title': article.title,
            'description': '',
            'answer': answer_content
        })
        uri = Path.html_pool_path + '/' + filename
        buf_file = open(uri, 'w')
        buf_file.write(content)
        buf_file.close()
        return uri
Exemplo n.º 4
0
    def generate_question_page(self, question):
        """
        :type question: src.container.task_result.Question
        :return:
        :rtype:
        """
        # 先输出answer的内容
        answer_content = u''
        for answer in question.answer_list:
            answer_content += Template.answer.format(
                **{
                    'author_avatar_url': answer.author_avatar_url,
                    'author_name': answer.author_name,
                    'author_id': answer.author_id,
                    'author_headline': answer.author_headline,

                    'content': answer.content,
                    'comment_count': answer.comment_count,
                    'voteup_count': answer.voteup_count,
                    'updated_time': ExtraTools.format_date('Y-m-d H:i:s', answer.updated_time),
                }
            )

        filename = self.get_random_html_file_name()
        content = Template.question.format(
            **{
                'title': question.question_info.title,
                'description': question.question_info.detail,
                'answer': answer_content
            }
        )
        uri = Path.html_pool_path + '/' + filename
        buf_file = open(uri, 'w')
        buf_file.write(content)
        buf_file.close()
        return uri