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
|
||||
|
||||
import os
|
||||
from flask import render_template
|
||||
from flask import Blueprint
|
||||
from flask import abort
|
||||
from app.cloud.controllers.kb import ControllerKB
|
||||
|
||||
viewKB = Blueprint('kb', __name__, url_prefix='/kb')
|
||||
|
||||
|
@ -11,14 +11,11 @@ viewKB = Blueprint('kb', __name__, url_prefix='/kb')
|
|||
@viewKB.route('/')
|
||||
@viewKB.route('/<path:document>')
|
||||
def index(document='README'):
|
||||
#
|
||||
if not os.path.exists('kb/%s.md' % document):
|
||||
# Check exists document
|
||||
if not ControllerKB().is_exists(document):
|
||||
return abort(404)
|
||||
#
|
||||
kb_markdown = u''
|
||||
for ss in file('kb/%s.md' % document, 'r'):
|
||||
kb_markdown += ss.decode('UTF-8')
|
||||
# Return document
|
||||
return render_template(
|
||||
'default/kb/index.html',
|
||||
kb_markdown=kb_markdown
|
||||
kb_markdown=ControllerKB().get(document)
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue