async def do_board(): plist = getPaperList(pfile) new_plist = [] for p in plist: new_p = ' '.join(p.split()) new_plist.append(new_p) plist = new_plist writeFile(pfile, '\n'.join(plist)) return pageResponse(template=pages.board, plist=plist)
async def do_edit_get(blog_id, cookies): chk = await checkRequiredData(bid=blog_id, from_public=False, cookies=cookies) if not chk.success: return chk.errorPageResponse b = await Blog.find(blog_id) await b.lightInfo() return pageResponse(template=pages.editor, edit=True, blog=b, me=True)
async def do_me_home(cookies): chk = await checkRequiredData(from_public=False, cookies=cookies) if not chk.success: return chk.errorPageResponse uid = cookies['user_id'] u = await User.find(uid) await u.heavyInfo() return pageResponse(template=pages.user_home, blogs=u.blogs, user=u, me=True)
async def do_visit_user(user_id, cookies): chk = await checkRequiredData(uid=user_id, cookies=cookies) if not chk.success: return chk.errorPageResponse u = await User.find(user_id) blogs = await u.getPublicBlogs() for b in blogs: await b.lightInfo(paths.visit_blog) return pageResponse(template=pages.user_home, user=u, blogs=blogs, not_me=True)
async def do_blog(blog_id, cookies): chk = await checkRequiredData(bid=blog_id, cookies=cookies) if not chk.success: return chk.errorPageResponse b = await Blog.find(blog_id) ## 收集博客信息 u = await User.find(b.user_id) await b.heavyInfo() await u.heavyInfo() return pageResponse(template=pages.visit_blog, blog=b, user=u, blogs=u.blogs)
async def do_blog(blog_id, cookies): chk = await checkRequiredData(bid=blog_id, from_public=False, cookies=cookies) if not chk.success: return chk.errorJsonResponse b = await Blog.find(blog_id) print('view blog:%s' % b) ## 收集博客信息 u = await User.find(b.user_id) await b.lightInfo() await u.heavyInfo() return pageResponse(template=pages.read_my_blog, blog=b, user=u, blogs=u.blogs, me=True)
async def do_home(cookies): ''' parseRequest and Check gatherData: users,blogs,comments def getData(blogs=True,users=false,comments=false): pass :param cookies: :return: ''' blogs = await getBlogRecomendations() users = await getUserRecomendations() ## 添加信息 for b in blogs: await b.lightInfo(paths.visit_blog) for u in users: await u.lightInfo(paths.visit_user) return pageResponse(template=pages.home, blogs=blogs, users=users)
def pageError(template=pages.error, **kws): return pageResponse(template=template, **kws)
async def do_archieves(): return pageResponse(template=pages.archieves)
async def do_editor_get(): return pageResponse(template=pages.editor)
async def do_archieves(): archieves=await man.getArchieves() return pageResponse(template=pages.archieves,cluster=archieves,config=config.site)
async def do_tags(): tags=await man.getTags() return pageResponse(template=pages.tags,cluster=tags,config=config.site)
async def do_root(): # await blman.rebuild() blogs=await man.blog_tb.findAll(visible='true') blogs=models.Collection(blogs).sortBy('created_at') return pageResponse(template=config.page_templates.root,blogs=blogs,config=config.site)
async def do_html_get(aname): fname = 'app/' + aname + '/' + aname + '.html' cpath = 'templates/app/' + aname + '/' + 'content.txt' content = loadText(cpath) return pageResponse(template=fname, content=content)
async def do_board_post_get(): return pageResponse(template='html/post_paper.html')
async def do_search(): return pageResponse(template=pages.search)
async def do_root(): return pageResponse(template=pages.root)
async def do_test(): return pageResponse(template=pages.test)
async def handler(): blogs=await bltb.findAll(visible='true') blogs=blogs.sortBy('created_at') return pageResponse(template=v,config=config,blogs=blogs)
def pageSign(template=pages.sign_up_in, sign_in=True, **kws): return pageResponse(template=template, sign_in=sign_in, **kws)
async def handler(): blogs=await man.blog_tb.findAll(visible='true') blogs=models.Collection(blogs).sortBy('created_at') return pageResponse(template=v,config=config,blogs=blogs)
async def do_manage_get(): blogs=await man.blog_tb.findAll() return pageResponse(template=pages.manage,blogs=blogs,config=config.site)
async def do_about(): return pageResponse(template=pages.about,config=config.site)
async def do_categories(): cates = await blman.getCategories() return pageResponse(template=pages.categories, categories=cates)
async def do_categories(): cates=await man.getCategories() return pageResponse(template=pages.categories,cluster=cates,config=config.site)
async def do_me_editor(cookies): chk = await checkRequiredData(from_public=False, cookies=cookies) if not chk.success: return chk.errorPageResponse return pageResponse(template=pages.editor)
async def do_search(): return pageResponse(template=pages.search,config=config.site)
async def do_manage_get(): blogs = await blman.loadBlogs() return pageResponse(template=pages.manage, blogs=blogs)
async def do_editor_get(): return pageResponse(template=pages.editor,config=config.site)
async def do_tags(): return pageResponse(template=pages.tags)