def signup(): config.reset(settingdb.select()) config.kargs['blogTitle'] = "ទំព័រសមាជិក" config.kargs['posts'] = userdb.select(config.kargs['dashboardPostLimit']) config.kargs['thumbs'] = lib.getPostThumbs(config.kargs['posts'], type="user") config.kargs['page'] = 1 return template('dashboard/signup', data=config.kargs)
def search(place): config.reset(settingdb.select()) query = request.forms.getunicode('fquery') config.kargs['posts'] = postdb.search(query) config.kargs['thumbs'] = lib.getPostThumbs(config.kargs['posts']) config.kargs['blogTitle'] = "ទំព័រស្វែងរក" if place == "backend": return template('dashboard/search', data=config.kargs) else: return template('search', data=config.kargs)
def category(name): config.reset(settingdb.select()) config.kargs['blogTitle'] = "ទំព័រជំពូក" config.kargs['category'] = name config.kargs['posts'] = postdb.select(config.kargs['categoryPostLimit'], category=name) config.kargs['thumbs'] = lib.getPostThumbs(config.kargs['posts']) config.kargs['page'] = 1 author = request.get_cookie("logged-in", secret=config.kargs['secretKey']) if author: config.kargs['showEdit'] = True return template('categories', data=config.kargs)
def post(name): config.reset(settingdb.select()) config.kargs['blogTitle'] = "ទំព័រសមាជិក" config.kargs['post'] = userdb.select(1, author=name) config.kargs['posts'] = userdb.select(config.kargs['authorPagePostLimit']) config.kargs['thumbs'] = lib.getPostThumbs(config.kargs['posts'], "user") config.kargs['page'] = 1 author = request.get_cookie("logged-in", secret=config.kargs['secretKey']) if author: config.kargs['showEdit'] = True return template('user', data=config.kargs)
def edit(): author = request.get_cookie("logged-in", secret=config.kargs['secretKey']) if ((author != "Guest") and userdb.checkAdmin(author)): config.kargs['blogTitle'] = "ទំព័រកែតំរូវ" config.kargs['posts'] = postdb.select( config.kargs['dashboardPostLimit']) config.kargs['thumbs'] = lib.getPostThumbs(config.kargs['posts']) config.kargs['post'] = settingdb.select() config.kargs['page'] = 1 return template('dashboard/setting', data=config.kargs) redirect('/login')
def post(id): config.reset(settingdb.select()) config.kargs['blogTitle'] = "ទំព័រស្តាទិក" config.kargs['post'] = pagedb.select(1, id) config.kargs['posts'] = pagedb.select(config.kargs['frontPagePostLimit']) config.kargs['thumbs'] = lib.getPostThumbs(config.kargs['posts']) config.kargs['page'] = 1 author = request.get_cookie("logged-in", secret=config.kargs['secretKey']) if author: config.kargs['showEdit'] = True return template('page', data=config.kargs)
def post(): config.reset(settingdb.select()) config.kargs['blogTitle'] = "ទំព័រជំពូក" config.kargs['posts'] = categorydb.select(config.kargs['dashboardPostLimit']) config.kargs['thumbs'] = lib.getPostThumbs(config.kargs['posts']) config.kargs['datetime'] = getTimeZone() config.kargs['page'] = 1 author = request.get_cookie("logged-in", secret=config.kargs['secretKey']) if author: config.kargs['author'] = author config.kargs['showEdit'] = True return template('dashboard/category', data=config.kargs)
def edit(id): author = request.get_cookie("logged-in", secret=config.kargs['secretKey']) if ((author != "Guest") and categorydb.check(author)): config.reset(settingdb.select()) config.kargs['blogTitle'] = "ទំព័រកែតំរូវ" config.kargs['posts'] = categorydb.select(config.kargs['dashboardPostLimit']) config.kargs['thumbs'] = lib.getPostThumbs(config.kargs['posts']) config.kargs['post'] = categorydb.select(1, id) config.kargs['edit'] = True config.kargs['postId'] = id config.kargs['page'] = 1 return template('dashboard/category', data=config.kargs) redirect('/category')
def login(): user = userdb.createTable() username = request.get_cookie("logged-in", secret=config.kargs['secretKey']) if not user: return template('dashboard/signup', data=config.kargs) elif username: config.reset(settingdb.select()) config.kargs['author'] = username config.kargs['blogTitle'] = "ទំព័រគ្រប់គ្រង" config.kargs['datetime'] = getTimeZone() config.kargs['posts'] = postdb.select( config.kargs['dashboardPostLimit']) config.kargs['categories'] = categorydb.select(amount="all") config.kargs['thumbs'] = lib.getPostThumbs(config.kargs['posts']) config.kargs['page'] = 1 return template('dashboard/home', data=config.kargs) else: return template('login', data=config.kargs)
def main(): config.reset(settingdb.select()) config.kargs['posts'] = postdb.select(config.kargs['homePagePostLimit']) config.kargs['thumbs'] = lib.getPostThumbs(config.kargs['posts']) config.kargs['page'] = 1 return template('home', data=config.kargs)
#config.py from models import settingdb setting = settingdb.createTable() kargs = {} kargs['message'] = '' kargs['page'] = 1 def reset(setting): kargs['blogTitle'] = setting[0] kargs['secretKey'] = setting[1] kargs['dashboardPostLimit'] = setting[2] kargs['frontPagePostLimit'] = setting[3] kargs['homePagePostLimit'] = setting[4] kargs['authorPagePostLimit'] = setting[5] kargs['categoryPostLimit'] = setting[6] if not setting: settingdb.insert('គេហទំព័រខ្មែរអង្គរ', 'h4!#au%8tb_9@oe+c0te=g=u%cfxb8t8fy%7+(gx2+51!t*b+s', 5, 8, 12, 16, 20) setting = settingdb.select() reset(setting)