コード例 #1
0
ファイル: mezzanine_tags.py プロジェクト: dfalk/mezzanine
def metablock(parsed):
    """
    Remove HTML tags, entities and superfluous characters from
    meta blocks.
    """
    parsed = " ".join(parsed.replace("\n", "").split()).replace(" ,", ",")
    return escape(strip_tags(decode_entities(parsed)))
コード例 #2
0
ファイル: base.py プロジェクト: desecho/mezzanine
    def add_post(self, title=None, content=None, old_url=None, pub_date=None,
                 tags=None, categories=None, comments=None):
        """
        Adds a post to the post list for processing.

        - ``title`` and ``content`` are strings for the post.
        - ``old_url`` is a string that a redirect will be created for.
        - ``pub_date`` is assumed to be a ``datetime`` object.
        - ``tags`` and ``categories`` are sequences of strings.
        - ``comments`` is a sequence of dicts - each dict should be the
          return value of ``add_comment``.
        """
        if not title:
            title = strip_tags(content).split(". ")[0]
        title = decode_entities(title)
        if categories is None:
            categories = []
        if tags is None:
            tags = []
        if comments is None:
            comments = []
        self.posts.append({
            "title": force_text(title),
            "publish_date": pub_date,
            "content": force_text(content),
            "categories": categories,
            "tags": tags,
            "comments": comments,
            "old_url": old_url,
        })
        return self.posts[-1]
コード例 #3
0
ファイル: base.py プロジェクト: DanHoerst/mezzanine
    def add_post(self, title=None, pub_date=None, tags=None,
        content=None, comments=None, old_url=None, categories=None):
        """
        Adds a post to the post list for processing.

        Attributes:
            pub_date is assumed to be a datetime object.
        """
        if not title:
            title = decode_entities(strip_tags(content).split(". ")[0])
        if categories is None:
            categories = []
        if tags is None:
            tags = []
        if comments is None:
            comments = []
        self.posts.append({
            "title": title,
            "publish_date": pub_date,
            "content": content,
            "categories": categories,
            "tags": tags,
            "comments": comments,
            "old_url": old_url,
        })
        return self.posts[-1]
コード例 #4
0
def metablock(context, nodelist):
    """
    Remove HTML tags, entities and superfluous characters from meta blocks.
    """
    parsed = nodelist.render(context)
    parsed = " ".join(parsed.replace("\n", "").split()).replace(" ,", ",")
    return strip_tags(decode_entities(parsed))
コード例 #5
0
ファイル: base.py プロジェクト: desecho/mezzanine
 def add_page(self, title=None, content=None, old_url=None,
              tags=None, old_id=None, old_parent_id=None):
     """
     Adds a page to the list of pages to be imported - used by the
     Wordpress importer.
     """
     if not title:
         text = decode_entities(strip_tags(content)).replace("\n", " ")
         title = text.split(". ")[0]
     if tags is None:
         tags = []
     self.pages.append({
         "title": title,
         "content": content,
         "tags": tags,
         "old_url": old_url,
         "old_id": old_id,
         "old_parent_id": old_parent_id,
     })
コード例 #6
0
ファイル: base.py プロジェクト: inyoka/mezzanine
 def add_page(self,
              title=None,
              content=None,
              old_url=None,
              tags=None,
              old_id=None,
              old_parent_id=None):
     """
     Adds a page to the list of pages to be imported - used by the
     Wordpress importer.
     """
     if not title:
         text = decode_entities(strip_tags(content)).replace("\n", " ")
         title = text.split(". ")[0]
     if tags is None:
         tags = []
     self.pages.append({
         "title": title,
         "content": content,
         "tags": tags,
         "old_url": old_url,
         "old_id": old_id,
         "old_parent_id": old_parent_id,
     })
コード例 #7
0
def metablock(parsed):
    """
    Remove HTML tags, entities and superfluous characters from meta blocks.
    """
    parsed = " ".join(parsed.replace("\n", "").split()).replace(" ,", ",")
    return strip_tags(decode_entities(parsed))