def post(id): config.reset(settingdb.select()) config.kargs['blogTitle'] = "ទំព័រការផ្សាយ" config.kargs['post'] = postdb.select(1, id) config.kargs['posts'] = postdb.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('post', data=config.kargs)
def edit(id): author = request.get_cookie("logged-in", secret=config.kargs['secretKey']) if ((author != "Guest") and postdb.check(author)): config.reset(settingdb.select()) config.kargs['blogTitle'] = "ទំព័រកែតំរូវ" config.kargs['posts'] = postdb.select(config.kargs['dashboardPostLimit']) config.kargs['thumbs'] = lib.getPostThumbs(config.kargs['posts']) config.kargs['categories'] = categorydb.select(amount="all") config.kargs['post'] = postdb.select(1, id) config.kargs['edit'] = True config.kargs['postId'] = id config.kargs['page'] = 1 return template('dashboard/home', data=config.kargs) redirect('/login')
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 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 paginate(category): posts = postdb.select(config.kargs['categoryPostLimit'], category=category, page=config.kargs['page']) def toString(post): post[3] = post[3].strftime('%d-%m-%Y') post[4] = post[4].strftime('%H:%M:%S') if posts: config.kargs['page'] += 1 posts = [list(obj) for obj in posts ] [toString(obj) for obj in posts] thumbs = lib.getPostThumbs(posts) print(posts) return {'json':posts, 'thumbs':thumbs} else: return {'json':0}
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 paginate(place): if place == "frontEnd": postLimit = config.kargs['frontPagePostLimit'] elif place == 'home': postLimit = config.kargs['homePagePostLimit'] else: postLimit = config.kargs['dashboardPostLimit'] posts = postdb.select(postLimit, page=config.kargs['page']) def toString(post): post[3] = post[3].strftime('%d-%m-%Y') post[4] = post[4].strftime('%H:%M:%S') if posts: config.kargs['page'] += 1 posts = [list(obj) for obj in posts ] [toString(obj) for obj in posts] thumbs = lib.getPostThumbs(posts) return {'json':posts, 'thumbs':thumbs} else: return {'json':0}
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)