Exemple #1
0
def edit_textwiki(request):

    resource_database = get_resource_database()

    if request.method == 'POST':
        handle_blueprint_post(request, Wikitext)

    resource = None
    if hasattr(request, 'ductus') and getattr(request.ductus, 'resource',
                                              None):
        resource = request.ductus.resource
        # handle old creole content: make it look like ductus-html5 so we can edit it
        # content is not saved to creole anymore, only to ductus-html5
        if resource.blob.markup_language == 'creole-1.0':
            resource.blob.markup_language = 'ductus-html5'
            resource.text = creole(resource.text,
                                   resource.blob.natural_language)

    return render_to_response('textwiki/edit_wiki.html', {
        'resource_json':
        resource,
        'writable_directories':
        get_writable_directories_for_user(request.user),
    },
                              context_instance=RequestContext(request))
Exemple #2
0
def preview_textwiki(request, pagename):
    """Return HTML rendered from Creole markup sent via AJAX request"""

    from ductus.utils.http import render_json_response
    if request.method == 'POST':
        from ductus.modules.textwiki.templatetags.textwiki import creole
        markup = request.POST.get('text', '')
        rv = creole(markup)
        return render_json_response({"html": rv})

    return render_json_response({"error": "Error previewing your changes"})
Exemple #3
0
def edit_textwiki(request):

    resource_database = get_resource_database()

    if request.method == 'POST':
        handle_blueprint_post(request, Wikitext)

    resource = None
    if hasattr(request, 'ductus') and getattr(request.ductus, 'resource', None):
        resource = request.ductus.resource
        # handle old creole content: make it look like ductus-html5 so we can edit it
        # content is not saved to creole anymore, only to ductus-html5
        if resource.blob.markup_language == 'creole-1.0':
            resource.blob.markup_language = 'ductus-html5'
            resource.text = creole(resource.text, resource.blob.natural_language)

    return render_to_response('textwiki/edit_wiki.html', {
        'resource_json': resource,
        'writable_directories': get_writable_directories_for_user(request.user),
    }, context_instance=RequestContext(request))