update kb
This commit is contained in:
parent
2231c9c29f
commit
cf21b66da4
2 changed files with 24 additions and 9 deletions
|
@ -1 +1,19 @@
|
||||||
__author__ = 'vanzhiganov'
|
# coding: utf-8
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
class ControllerKB:
|
||||||
|
def __init__(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def is_exists(self, document):
|
||||||
|
if os.path.exists('kb/%s.md' % document):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def get(self, document):
|
||||||
|
kb_markdown = u''
|
||||||
|
for ss in file('kb/%s.md' % document, 'r'):
|
||||||
|
kb_markdown += ss.decode('UTF-8')
|
||||||
|
return kb_markdown
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
|
||||||
import os
|
|
||||||
from flask import render_template
|
from flask import render_template
|
||||||
from flask import Blueprint
|
from flask import Blueprint
|
||||||
from flask import abort
|
from flask import abort
|
||||||
|
from app.cloud.controllers.kb import ControllerKB
|
||||||
|
|
||||||
viewKB = Blueprint('kb', __name__, url_prefix='/kb')
|
viewKB = Blueprint('kb', __name__, url_prefix='/kb')
|
||||||
|
|
||||||
|
@ -11,14 +11,11 @@ viewKB = Blueprint('kb', __name__, url_prefix='/kb')
|
||||||
@viewKB.route('/')
|
@viewKB.route('/')
|
||||||
@viewKB.route('/<path:document>')
|
@viewKB.route('/<path:document>')
|
||||||
def index(document='README'):
|
def index(document='README'):
|
||||||
#
|
# Check exists document
|
||||||
if not os.path.exists('kb/%s.md' % document):
|
if not ControllerKB().is_exists(document):
|
||||||
return abort(404)
|
return abort(404)
|
||||||
#
|
# Return document
|
||||||
kb_markdown = u''
|
|
||||||
for ss in file('kb/%s.md' % document, 'r'):
|
|
||||||
kb_markdown += ss.decode('UTF-8')
|
|
||||||
return render_template(
|
return render_template(
|
||||||
'default/kb/index.html',
|
'default/kb/index.html',
|
||||||
kb_markdown=kb_markdown
|
kb_markdown=ControllerKB().get(document)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue