34 lines
890 B
Python
34 lines
890 B
Python
# coding: utf-8
|
|
|
|
import os
|
|
from flask import render_template
|
|
from flask import Blueprint
|
|
from flask import redirect
|
|
from flask import url_for
|
|
|
|
viewDocuments = Blueprint('documents', __name__, url_prefix='/documents')
|
|
|
|
|
|
# @viewDocuments.route('/')
|
|
# def index():
|
|
# kb_markdown = ''
|
|
# for ss in file('kb/index.md', 'r'):
|
|
# kb_markdown += ss
|
|
#
|
|
# return render_template('default/kb/index.html', kb_markdown=kb_markdown)
|
|
|
|
|
|
@viewDocuments.route('/<document_name>.html')
|
|
def view(document_name):
|
|
if not os.path.exists('docs/%s.md' % document_name):
|
|
return redirect(url_for('homepage.index'))
|
|
#
|
|
print document_name
|
|
doc_markdown = u''
|
|
for ss in file('docs/%s.md' % document_name, 'r'):
|
|
doc_markdown += ss.decode('UTF-8')
|
|
#
|
|
return render_template(
|
|
'default/documents/index.html',
|
|
doc_markdown=doc_markdown
|
|
)
|