当前位置: 首页>>代码示例>>Python>>正文


Python text.cleaned_markdown_conversion函数代码示例

本文整理汇总了Python中mediagoblin.tools.text.cleaned_markdown_conversion函数的典型用法代码示例。如果您正苦于以下问题:Python cleaned_markdown_conversion函数的具体用法?Python cleaned_markdown_conversion怎么用?Python cleaned_markdown_conversion使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了cleaned_markdown_conversion函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: media_preview_comment

def media_preview_comment(request):
    """Runs a comment through markdown so it can be previewed."""
    # If this isn't an ajax request, render_404
    if not request.is_xhr:
        return render_404(request)

    comment = unicode(request.form["comment_content"])
    cleancomment = {"content": cleaned_markdown_conversion(comment)}

    return Response(json.dumps(cleancomment))
开发者ID:aurelienmaury,项目名称:JoshuaGoblin,代码行数:10,代码来源:views.py

示例2: blogpost_edit

def blogpost_edit(request):

    blog_slug = request.matchdict.get('blog_slug', None)
    blog_post_slug = request.matchdict.get('blog_post_slug', None)

    blogpost = request.db.MediaEntry.query.filter_by(slug=blog_post_slug, actor=request.user.id).first()
    blog = get_blog_by_slug(request, blog_slug, author=request.user.id)

    if not blogpost or not blog:
        return render_404(request)

    defaults = dict(
                title = blogpost.title,
                description = cleaned_markdown_conversion(blogpost.description),
                tags=media_tags_as_string(blogpost.tags),
                license=blogpost.license)

    form = blog_forms.BlogPostEditForm(request.form, **defaults)
    if request.method == 'POST' and form.validate():
        blogpost.title = six.text_type(form.title.data)
        blogpost.description = six.text_type(cleaned_markdown_conversion((form.description.data)))
        blogpost.tags =  convert_to_tag_list_of_dicts(form.tags.data)
        blogpost.license = six.text_type(form.license.data)
        set_blogpost_state(request, blogpost)
        blogpost.generate_slug()
        blogpost.save()

        messages.add_message(
            request,
            messages.SUCCESS,
            _('Woohoo! edited blogpost is submitted'))
        return redirect(request, "mediagoblin.media_types.blog.blog-dashboard",
                        user=request.user.username,
                        blog_slug=blog.slug)

    return render_to_response(
        request,
        'mediagoblin/blog/blog_post_edit_create.html',
        {'form': form,
        'app_config': mg_globals.app_config,
        'user': request.user.username,
        'blog_post_slug': blog_post_slug
        })
开发者ID:ausbin,项目名称:mediagoblin,代码行数:43,代码来源:views.py

示例3: user_add_bio_html

def user_add_bio_html(database):
    """
    Users now have richtext bios via Markdown, reflect appropriately.
    """
    collection = database["users"]

    target = collection.find({"bio_html": {"$exists": False}})

    for document in target:
        document["bio_html"] = cleaned_markdown_conversion(document["bio"])
        collection.save(document)
开发者ID:3rdwiki,项目名称:mediagoblin,代码行数:11,代码来源:migrations.py

示例4: blogpost_create

def blogpost_create(request):

    form = blog_forms.BlogPostEditForm(request.form, license=request.user.license_preference)

    if request.method == 'POST' and form.validate():
        blog_slug = request.matchdict.get('blog_slug')
        blog = get_blog_by_slug(request, blog_slug, author=request.user.id)
        if not blog:
            return render_404(request)

        blogpost = request.db.MediaEntry()
        blogpost.media_type = 'mediagoblin.media_types.blogpost'
        blogpost.title = six.text_type(form.title.data)
        blogpost.description = six.text_type(cleaned_markdown_conversion((form.description.data)))
        blogpost.tags =  convert_to_tag_list_of_dicts(form.tags.data)
        blogpost.license = six.text_type(form.license.data) or None
        blogpost.actor = request.user.id
        blogpost.generate_slug()

        set_blogpost_state(request, blogpost)
        blogpost.save()

        # connect this blogpost to its blog
        blog_post_data = request.db.BlogPostData()
        blog_post_data.blog = blog.id
        blog_post_data.media_entry = blogpost.id
        blog_post_data.save()

        messages.add_message(
            request,
            messages.SUCCESS,
            _('Woohoo! Submitted!'))
        add_comment_subscription(request.user, blogpost)
        return redirect(request, "mediagoblin.media_types.blog.blog-dashboard",
                        user=request.user.username,
                        blog_slug=blog.slug)

    return render_to_response(
        request,
        'mediagoblin/blog/blog_post_edit_create.html',
        {'form': form,
        'app_config': mg_globals.app_config,
        'user': request.user.username})
开发者ID:ausbin,项目名称:mediagoblin,代码行数:43,代码来源:views.py

示例5: blog_edit

def blog_edit(request):
    """
    View for editing an existing blog or creating a new blog
    if user have not exceeded maximum allowed acount of blogs.
    """
    url_user = request.matchdict.get('user', None)
    blog_slug = request.matchdict.get('blog_slug', None)

    config = pluginapi.get_config('mediagoblin.media_types.blog')
    max_blog_count = config['max_blog_count']
    form = blog_forms.BlogEditForm(request.form)
    # creating a blog
    if not blog_slug:
        if Blog.query.filter_by(author=request.user.id).count()<max_blog_count:
            if request.method=='GET':
                return render_to_response(
                    request,
                    'mediagoblin/blog/blog_edit_create.html',
                    {'form': form,
                    'user' : request.user,
                    'app_config': mg_globals.app_config})

            if request.method=='POST' and form.validate():
                _log.info("Here")
                blog = request.db.Blog()
                blog.title = six.text_type(form.title.data)
                blog.description = six.text_type(cleaned_markdown_conversion((form.description.data)))
                blog.author = request.user.id
                blog.generate_slug()

                blog.save()
                return redirect(request, "mediagoblin.media_types.blog.blog_admin_dashboard",
                        user=request.user.username
                       )
        else:
            add_message(request, ERROR, "Welcome! You already have created \
                                                        maximum number of blogs.")
            return redirect(request, "mediagoblin.media_types.blog.blog_admin_dashboard",
                        user=request.user.username)


    #Blog already exists.
    else:
        blog = get_blog_by_slug(request, blog_slug)
        if not blog:
            return render_404(request)
        if request.method == 'GET':
            defaults = dict(
                title = blog.title,
                description = cleaned_markdown_conversion(blog.description),
                author = request.user.id)

            form = blog_forms.BlogEditForm(**defaults)

            return render_to_response(
                    request,
                    'mediagoblin/blog/blog_edit_create.html',
                    {'form': form,
                     'user': request.user,
                     'app_config': mg_globals.app_config})
        else:
            if request.method == 'POST' and form.validate():
                blog.title = six.text_type(form.title.data)
                blog.description = six.text_type(cleaned_markdown_conversion((form.description.data)))
                blog.author = request.user.id
                blog.generate_slug()

                blog.save()
                add_message(request, SUCCESS, "Your blog is updated.")
                return redirect(request, "mediagoblin.media_types.blog.blog-dashboard",
                        user=request.user.username,
                        blog_slug=blog.slug)
开发者ID:tofay,项目名称:mediagoblin,代码行数:72,代码来源:views.py

示例6: blog_edit

def blog_edit(request):
    """
    View for editing the existing blog or automatically
    creating a new blog if user does not have any yet.
    """
    url_user = request.matchdict.get('user', None)
    blog_slug = request.matchdict.get('blog_slug', None)
    
    max_blog_count = 1
    form = blog_forms.BlogEditForm(request.form)
    # the blog doesn't exists yet
    if not blog_slug:
        if Blog.query.filter_by(author=request.user.id).count()<max_blog_count:
            if request.method=='GET':
                return render_to_response(
                    request,
                    'mediagoblin/blog/blog_edit_create.html',
                    {'form': form,
                    'user' : request.user,
                    'app_config': mg_globals.app_config})

            if request.method=='POST' and form.validate():
                _log.info("Here")
                blog = request.db.Blog()
                blog.title = unicode(form.title.data)
                blog.description = unicode(cleaned_markdown_conversion((form.description.data))) 
                blog.author = request.user.id
                blog.generate_slug()
               
                blog.save()
                return redirect(request, "mediagoblin.media_types.blog.blog-dashboard",
                        user=request.user.username,
                        blog_slug=blog.slug)
        else:
            #the case when max blog count is one.
            blog = request.db.Blog.query.filter_by(author=request.user.id).first()
            add_message(request, ERROR, "Welcome! You already have created a blog.")
            return redirect(request, "mediagoblin.media_types.blog.blog-dashboard",
                        user=request.user.username,
                        blog_slug=blog.slug)


    #Blog already exists.
    else:
        blog = request.db.Blog.query.filter_by(slug=blog_slug).first()
        if request.method == 'GET':
            defaults = dict(
                title = blog.title,
                description = cleaned_markdown_conversion(blog.description),
                author = request.user.id) 
            
            form = blog_forms.BlogEditForm(**defaults)

            return render_to_response(
                    request,
                    'mediagoblin/blog/blog_edit_create.html',
                    {'form': form,
                     'user': request.user,
                     'app_config': mg_globals.app_config})
        else:
            if request.method == 'POST' and form.validate():
                blog.title = unicode(form.title.data)
                blog.description = unicode(cleaned_markdown_conversion((form.description.data)))
                blog.author = request.user.id
                blog.generate_slug()
                
                blog.save()
                add_message(request, SUCCESS, "Your blog is updated.")
                return redirect(request, "mediagoblin.media_types.blog.blog-dashboard",
                        user=request.user.username,
                        blog_slug=blog.slug)            
开发者ID:spaetz,项目名称:mediagoblin_blog,代码行数:71,代码来源:views.py

示例7: description_html

 def description_html(self):
     """
     Rendered version of the description, run through
     Markdown and cleaned with our cleaning tool.
     """
     return cleaned_markdown_conversion(self.description)
开发者ID:imclab,项目名称:mediagoblin,代码行数:6,代码来源:mixin.py

示例8: bio_html

 def bio_html(self):
     return cleaned_markdown_conversion(self.bio)
开发者ID:imclab,项目名称:mediagoblin,代码行数:2,代码来源:mixin.py

示例9: note_html

 def note_html(self):
     """
     the actual html-rendered version of the note displayed.
     Run through Markdown and the HTML cleaner.
     """
     return cleaned_markdown_conversion(self.note)
开发者ID:imclab,项目名称:mediagoblin,代码行数:6,代码来源:mixin.py

示例10: content_html

 def content_html(self):
     """
     the actual html-rendered version of the comment displayed.
     Run through Markdown and the HTML cleaner.
     """
     return cleaned_markdown_conversion(self.content)
开发者ID:imclab,项目名称:mediagoblin,代码行数:6,代码来源:mixin.py


注:本文中的mediagoblin.tools.text.cleaned_markdown_conversion函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。