Example #1
0
 def clean_html(self, ids):
     entries = Entry.query.filter(Entry.id.in_(ids)).all()
     app.logger.info(u"Admin Cleaning HTML for Entries: {0}".format(u", ".join(map(str, entries))))
     for entry in entries:
         entry.content = Entry.clean_images(entry.content)
         entry.summary = Entry.clean_images(entry.summary)
         entry.title = Entry.clean_title(entry.title)
         db.session.add(entry)
     db.session.commit()
Example #2
0
    def summary(self, item):
        """
        Gets the summary of an item.

        :param item: Feedparser entry
        :type item: dict
        :return: str
        """
        summary = item.get('summary', None)
        if summary:
            summary = Entry.clean_images(summary)
        return summary
Example #3
0
    def content(self, item):
        """
        Gets the content of the item. If content is None, try
        using the summary.

        :param item: deserialized JSON item
        :type item: dict
        :return: str
        """
        content = item.get('content', None)
        if content is None:
            content = item.get('summary', None)
        if content:
            content = Entry.clean_images(content)
        return content
Example #4
0
    def content(self, item):
        """
        Gets the content of the item. If content is None, try
        using the summary.

        :param item: Feedparser entry
        :type item: dict
        :return: str
        """
        if item.get('content') is None:
            content = item.get('summary', None)
        else:
            try:
                c = item.get('content')[0]
                content = c.get('value')
            except:
                content = None
        if content:
            content = Entry.clean_images(content)
        return content