예제 #1
0
def view(document_id):
    enable_cache()
    data = get_index_document(document_id)
    document = get_db_document(document_id)
    data['headers'] = document.headers
    # TODO: should this be it's own API? Probably so, but for that it would
    # be unclear if we should JSON wrap it, or serve plain with the correct
    # MIME type?
    if Document.SCHEMA_HTML in document.model.names:
        data['html'] = sanitize_html(document.body_raw, document.source_url)
    if Document.SCHEMA_TEXT in document.model.names:
        data['text'] = document.body_text
    return jsonify(data, schema=CombinedSchema)
예제 #2
0
def view(document_id):
    enable_cache()
    document = get_index_document(document_id)
    # TODO: should this be it's own API? Probably so, but for that it would
    # be unclear if we should JSON wrap it, or serve plain with the correct
    # MIME type?
    if document.get('type') == Document.TYPE_SCROLL:
        obj = get_document(document_id)
        document['text'] = obj.body_text
    elif document.get('type') == Document.TYPE_HTML:
        obj = get_document(document_id)
        document['html'] = sanitize_html(obj.body_raw)
    return jsonify(document, schema=DocumentSchema)
예제 #3
0
def view(document_id):
    enable_cache()
    document = get_index_document(document_id)
    return jsonify(document, schema=DocumentSchema)