Beispiel #1
0
def gdoc2html(request):
    session = request.session

    # grab inputs
    if 'html' in request.POST:
        html = request.POST['html']
    else:
        return

    if 'textbook_html' in request.POST:
        textbook_html = request.POST['textbook_html'] is '1'
    else:
        textbook_html = True

    if 'copy_images' in request.POST:
        copy_images = request.POST['copy_images'] is '1'
    else:
        copy_images = False

    # be anonymous
    session['login'] = AnonymousSession()

    # setup work directory: save_dir = transform_dir + user_subdir_name
    transform_dir = request.registry.settings['transform_dir']
    user_subdir_name, save_dir = create_save_dir(request)

    # allow cross domain access
    request.response.headers.add('Access-Control-Allow-Origin', '*')

    # convert gdoc html to cnxml to textbook (aka structured) html or aloha-ready html
    cnxml, objects = gdocs_to_cnxml(html, bDownloadImages=copy_images)
    cnxml = clean_cnxml(cnxml)
    title = None
    metadata = None
    alohareadyhtml, structuredhtml, conversion_error = update_html(
        cnxml, title, metadata)
    if conversion_error is None:
        if textbook_html:
            html = structuredhtml
        else:
            html = alohareadyhtml
    else:
        html = ""

    jsonresult = {
        "html": html,
        "textbook_html": textbook_html,
        "copy_images": copy_images,
    }
    return jsonresult
 def create_save_dir(self, request):
     return create_save_dir(request, registry_key='slideshare_import_dir')
 def create_save_dir(self, request):
     return create_save_dir(request)
Beispiel #4
0
 def create_save_dir(self, request):
     return create_save_dir(request, registry_key='slideshare_import_dir')
Beispiel #5
0
 def create_save_dir(self, request):
     return create_save_dir(request)