예제 #1
0
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))