def tcg4(): if not session.get('log'): abort(403) tags = request.form.get('tcg4') try: blogInfo().config(tags=tags) return "Success" except: return "Error"
def tcg3(): if not session.get('log'): abort(403) sidebar = request.form.get('tcg3') try: blogInfo().config(sidebar=sidebar) return "Success" except: return "Error"
def tcg1(): if not session.get('log'): abort(403) subtitle = request.form.get('tcg1') try: blogInfo().config(subtitle=subtitle) return "Success" except: return "Error"
def index(): info=blogInfo() curPage = ArtiList(page=1) curPage.getAl() curPage.getPagn() curPage.getRe() return render_template('index.html',results = curPage.results, pagn = curPage.pagn,info=info)
def login(): info=blogInfo() pwd = request.form.get('password') if pwd and info.verify(pwd): session['log'] = True return redirect(url_for('admin')) return render_template('login.html',info=info)
def article(bg_id): if request.method == 'POST': try: author = request.form.get('author') if not author: author = session.get('name') if not author: author = getName() session['name'] = author content = request.form.get('content') rid = request.form.get('rid',type=int) Comment(bg_id).insert(content,author,rid) return redirect(url_for('article',bg_id = bg_id)) except: abort(500) if bg_id==0: return redirect(url_for('memo')) try: curArti = Article(bg_id) curArti.getIt() except: abort(404) if curArti.file!=0 or session.get('log'): info=blogInfo() info.subtitle=info.title info.title=curArti.title curComm=Comment(bg_id) curComm.getIt() return render_template('article.html',curArti = curArti,info=info,cl=curComm.cl) abort(404)
def cate(): if not session.get('log'): abort(403) oldId = request.form.get('oldId',type=int) newId = request.form.get('newId',type=int) content = request.form.get('content') res = blogInfo().setCate(oldId,newId,content) return res
def tag(tag,pg): info=blogInfo() curPage = ArtiList('tag',tag,pg) if curPage.getPagn(): curPage.getAl() curPage.getRe() return render_template('page.html',results = curPage.results, pagn = curPage.pagn,info=info) else: abort(404)
def edit(bg_id): if not session.get('log'): abort(403) try: curArti = Article(bg_id) curArti.getIt() except: abort(404) return render_template('edit.html',curArti = curArti,info=blogInfo())
def tcg2(): if not session.get('log'): abort(403) old = request.form.get('old') new = request.form.get('new') try: res = blogInfo().setPwd(old,new) return res except: return "Error"
def article(bg_id): if bg_id == 0: return redirect(url_for('memo')) try: curArti = Article(bg_id) curArti.getIt() except: abort(404) if curArti.file != 0 or session.get('log'): info = blogInfo() info.subtitle = info.title info.title = curArti.title curComm = Comment(bg_id) curComm.getIt() return render_template('article.html', curArti=curArti, info=info, cl=curComm.cl) abort(404)
def memo(): curComm=Comment(0) curComm.getIt() return render_template('memo.html',cl = curComm.cl,info=blogInfo())
def internal_server_error(e): return render_template('error.html',info=blogInfo()), 500
def admin(): if not session.get('log'): return redirect(url_for('login')) return render_template('admin.html',info=blogInfo(),cl=Comment().getNew())
def bad_request(e): return render_template('error.html',info=blogInfo()), 400
def page_not_found(e): return render_template('error.html' ,info=blogInfo()), 404
def new(): if not session.get('log'): abort(403) curArti = Article(0) return render_template('edit.html',curArti = curArti,info=blogInfo())
def forbidden(e): return render_template('forbidden.html',info=blogInfo()), 403
def wish(): return render_template('wish.html',info=blogInfo())