Example #1
0
 def POST(self):
     ninfo = web.input(newname = '', oldpwd = '', newpwd = '', repwd = '')
     if ninfo.oldpwd:
         userinfo = model.Kvdata.get(web.ctx.session.user)
         if userinfo:
             if userinfo['passwd'] == hash_md5(ninfo.oldpwd):
                 if ninfo.newname:
                     model.Kvdata.modify(web.ctx.session.user, ninfo.newname)
                     web.ctx.session.user = ninfo.newname
                     return R.render('user', user=web.ctx.session.user, msg = "用户名修改成功")
                 if ninfo.newpwd and ninfo.newpwd == ninfo.repwd:
                     model.Kvdata.set(web.ctx.session.user, {'passwd': hash_md5(ninfo.newpwd)})
                     return R.render('user', user=web.ctx.session.user, msg = "密码修改成功")
     raise web.seeother('/manage/user')
Example #2
0
 def GET(self, frame):
     frames = ['index', 'top', 'menu']
     if frame in frames:
         return web.template.frender('template/manage/' + frame + '.html')()
     if frame == 'main':
         totalpost =  model.Posts.count()
         return R.render('main', totalpost = totalpost)
Example #3
0
 def GET(self):
     home = os.getcwd()
     uploadDir = os.path.join(home, "static/uploads")
     if os.path.isdir(uploadDir):
         import time
         filedata = []
         for ifile in os.listdir(uploadDir):
             ifilepath = os.path.join(uploadDir, ifile)
             filetime = time.strftime(
                 '%Y-%m-%d %H:%M:%S',
                 time.localtime(os.stat(ifilepath).st_ctime))
             if os.path.isdir(ifilepath):
                 filedata.append({
                     'ftype': 'D',
                     'fname': ifile,
                     'fedittime': filetime
                 })
             else:
                 filedata.append({
                     'ftype': 'f',
                     'fname': ifile,
                     'fedittime': filetime
                 })
         print filedata
     return R.render('attachment', filedata=filedata)
Example #4
0
 def GET(self, page = 1):
     curpage = int(page)
     totalpost =  model.Posts.count()
     pagestr = page_navigation('', curpage, Setting.config['listnum'], totalpost)
     posts = model.Posts.get_all(None, Setting.config['listnum'], curpage)
     R.common_data()
     return R.render('index', posts = posts, pagestr = pagestr)
Example #5
0
 def GET(self, frame):
     frames = ['index', 'top', 'menu']
     if frame in frames:
         return web.template.frender('template/manage/' + frame + '.html')()
     if frame == 'main':
         totalpost = model.Posts.count()
         return R.render('main', totalpost=totalpost)
Example #6
0
 def POST(self, page = 1):
     spost = web.input(s = '')
     skey = spost.s
     skey = skey.encode("utf-8")
     pagestr = ''
     posts = model.execSql("select * from " + tablename("Posts") + " where post_title like '%" + skey + "%'")
     R.common_data()
     return R.render('index', posts = posts, pagestr = pagestr)
Example #7
0
 def GET(self, page=1):
     curpage = int(page)
     totalpost = model.Posts.count()
     pagestr = page_navigation('', curpage, Setting.config['listnum'],
                               totalpost)
     posts = model.Posts.get_all(None, Setting.config['listnum'], curpage)
     R.common_data()
     return R.render('index', posts=posts, pagestr=pagestr)
Example #8
0
 def POST(self, page=1):
     spost = web.input(s='')
     skey = spost.s
     skey = skey.encode("utf-8")
     pagestr = ''
     posts = model.execSql("select * from " + tablename("Posts") +
                           " where post_title like '%" + skey + "%'")
     R.common_data()
     return R.render('index', posts=posts, pagestr=pagestr)
Example #9
0
 def GET(self, pid=0):
     if pid:
         epost = model.Posts.get_by_id(pid)
     else:
         epost = model.Posts.model()
         epost.post_title = "在这里键入标题"
     tags = model.Tags.get_all()
     categorys = model.Category.get_all()
     return R.render('post', epost=epost, categorys=categorys, tags=tags)
Example #10
0
 def GET(self, pid = 0):
     if pid:
         epost = model.Posts.get_by_id(pid)
     else:
         epost = model.Posts.model()
         epost.post_title = "在这里键入标题"
     tags = model.Tags.get_all()
     categorys = model.Category.get_all()
     return R.render('post', epost=epost, categorys=categorys, tags=tags)
Example #11
0
 def GET(self, kname = "", page = 1):
     if kname:
         tagname = check_str(kname)
         curpage = int(page)
         totalpost =  model.Posts.count('tag', tagname)
         pagestr = page_navigation('/tag/' + kname, curpage, Setting.config['listnum'], totalpost)
         posts = model.Posts.get_by_tagname(tagname, Setting.config['listnum'], curpage)
         R.common_data()
         return R.render('index', posts = posts, pagestr = pagestr)
Example #12
0
 def POST(self):
     ninfo = web.input(newname='', oldpwd='', newpwd='', repwd='')
     if ninfo.oldpwd:
         userinfo = model.Kvdata.get(web.ctx.session.user)
         if userinfo:
             if userinfo['passwd'] == hash_md5(ninfo.oldpwd):
                 if ninfo.newname:
                     model.Kvdata.modify(web.ctx.session.user,
                                         ninfo.newname)
                     web.ctx.session.user = ninfo.newname
                     return R.render('user',
                                     user=web.ctx.session.user,
                                     msg="用户名修改成功")
                 if ninfo.newpwd and ninfo.newpwd == ninfo.repwd:
                     model.Kvdata.set(web.ctx.session.user,
                                      {'passwd': hash_md5(ninfo.newpwd)})
                     return R.render('user',
                                     user=web.ctx.session.user,
                                     msg="密码修改成功")
     raise web.seeother('/manage/user')
Example #13
0
 def GET(self):
     esetting = dict_to_object(model.Kvdata.get("setting"))
     home = os.getcwd()
     templateDir = os.path.join(home, "template")
     if os.path.isdir(templateDir):
         themes = []
         for ifile in os.listdir(templateDir):
             if ifile != 'manage':
                 ifilepath = os.path.join(templateDir, ifile)
                 if os.path.isdir(ifilepath):
                     themes.append(ifile)
     return R.render('setting', esetting=esetting, themes=themes)
Example #14
0
 def GET(self, kname = "", page = 1):
     if kname:
         category_shortname = check_str(kname)
         category = model.Category.get_by_short(category_shortname)
         if category.category_id:
             curpage = int(page)
             totalpost =  model.Posts.count('category', category.category_id)
             pagestr = page_navigation('/category/' + kname, curpage, Setting.config['listnum'], totalpost)
             posts = model.Posts.get_all(category.category_id, Setting.config['listnum'], curpage)
             R.common_data()
             return R.render('index', posts = posts, pagestr = pagestr)
         raise web.seeother('/')
Example #15
0
 def GET(self):
     esetting = dict_to_object(model.Kvdata.get("setting"))
     home = os.getcwd()
     templateDir = os.path.join(home, "template")
     if os.path.isdir(templateDir):
         themes = []
         for ifile in os.listdir(templateDir):
             if ifile != 'manage':
                 ifilepath = os.path.join(templateDir, ifile)
                 if os.path.isdir(ifilepath):
                     themes.append(ifile)
     return R.render('setting', esetting=esetting, themes=themes)
Example #16
0
 def GET(self, kname="", page=1):
     if kname:
         tagname = check_str(kname)
         curpage = int(page)
         totalpost = model.Posts.count('tag', tagname)
         pagestr = page_navigation('/tag/' + kname, curpage,
                                   Setting.config['listnum'], totalpost)
         posts = model.Posts.get_by_tagname(tagname,
                                            Setting.config['listnum'],
                                            curpage)
         R.common_data()
         return R.render('index', posts=posts, pagestr=pagestr)
Example #17
0
 def GET(self, action ='view', page = 1):
     if action == 'delete':
         model.Posts.delete(pid)
     cats = model.Category.get_all()
     curpage = int(page)
     totalpost =  model.Posts.count()
     pagestr = page_navigation('/manage/post', curpage, 15, totalpost)
     categorys = {}
     for c in cats:
         categorys[c.category_id] = c.category_name
     posts = model.Posts.get_all(None, 15, curpage)
     return R.render('postlist', posts=posts, categorys=categorys,
                     totalpost=totalpost, pagestr=pagestr)
Example #18
0
 def GET(self, kname="", page=1):
     if kname:
         category_shortname = check_str(kname)
         category = model.Category.get_by_short(category_shortname)
         if category.category_id:
             curpage = int(page)
             totalpost = model.Posts.count('category', category.category_id)
             pagestr = page_navigation('/category/' + kname, curpage,
                                       Setting.config['listnum'], totalpost)
             posts = model.Posts.get_all(category.category_id,
                                         Setting.config['listnum'], curpage)
             R.common_data()
             return R.render('index', posts=posts, pagestr=pagestr)
         raise web.seeother('/')
Example #19
0
 def GET(self):
     home = os.getcwd()
     uploadDir = os.path.join(home, "static/uploads")
     if os.path.isdir(uploadDir):
         import time
         filedata = []
         for ifile in os.listdir(uploadDir):
             ifilepath = os.path.join(uploadDir, ifile)
             filetime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(os.stat(ifilepath).st_ctime))
             if os.path.isdir(ifilepath):
                 filedata.append({'ftype':'D', 'fname':ifile, 'fedittime':filetime})
             else:
                 filedata.append({'ftype':'f', 'fname':ifile, 'fedittime':filetime})
         print filedata
     return R.render('attachment', filedata = filedata)
Example #20
0
 def GET(self, action='view', page=1):
     if action == 'delete':
         #            model.Posts.delete(pid)
         model.Posts.remove(page)
     cats = model.Category.get_all()
     curpage = int(page)
     totalpost = model.Posts.count()
     pagestr = page_navigation('/manage/post', curpage, 15, totalpost)
     categorys = {}
     for c in cats:
         categorys[c.category_id] = c.category_name
     posts = model.Posts.get_all(None, 15, curpage)
     return R.render('postlist',
                     posts=posts,
                     categorys=categorys,
                     totalpost=totalpost,
                     pagestr=pagestr)
Example #21
0
 def GET(self, kname):
     pname = check_str(kname)
     if is_int(pname):
         post = model.Posts.get_by_id(pname)
     else:
         post = model.Posts.get_by_title(pname)
     if post.post_id:
         model.Posts.viewcount(post.post_id)
         related_posts = model.Posts.get_related(post.post_category)
         related_comments = model.Comments.get_all(post.post_id)
         post_prev = model.Posts.get_next(post.post_id, 'down')
         post_next = model.Posts.get_next(post.post_id)
         R.common_data()
         R.addtplfunc('Md5', hash_md5)
         return R.render('post', post=post, related_posts=related_posts,
                         related_comments=related_comments,
                         post_prev=post_prev, post_next=post_next)
     raise web.seeother('/')
Example #22
0
 def GET(self, kname):
     pname = check_str(kname)
     if is_int(pname):
         post = model.Posts.get_by_id(pname)
     else:
         post = model.Posts.get_by_title(pname)
     if post.post_id:
         model.Posts.viewcount(post.post_id)
         related_posts = model.Posts.get_related(post.post_category)
         related_comments = model.Comments.get_all(post.post_id)
         post_prev = model.Posts.get_next(post.post_id, 'down')
         post_next = model.Posts.get_next(post.post_id)
         R.common_data()
         R.addtplfunc('Md5', hash_md5)
         return R.render('post',
                         post=post,
                         related_posts=related_posts,
                         related_comments=related_comments,
                         post_prev=post_prev,
                         post_next=post_next)
     raise web.seeother('/')
Example #23
0
 def GET(self, action='view', cid=0):
     ecategory = model.Category.get_by_id(cid)
     if action == 'delete':
         model.Category.delete(cid)
     categorys = model.Category.get_all()
     return R.render('category', ecategory=ecategory, categorys=categorys)
Example #24
0
 def GET(self, action='view', cid=0):
     if action == 'delete':
         model.Comments.remove(cid)
     comments = model.Comments.get_all()
     return R.render('comment', comments=comments)
Example #25
0
 def GET(self, action=''):
     return R.render('data')
Example #26
0
 def GET(self):
     return R.render('login')
Example #27
0
 def GET(self, action='view', lid=0):
     if action == 'delete':
         model.Links.remove(lid)
     elink = model.Links.get_by_id(lid)
     links = model.Links.get_all()
     return R.render('links', elink=elink, links=links)
Example #28
0
 def GET(self, tid=0):
     tags = model.Tags.get_all()
     etag = model.Tags.get_by_id(tid)
     return R.render('tags', etag=etag, tags=tags)
Example #29
0
 def GET(self):
     return R.render('user', user=web.ctx.session.user, msg='')
Example #30
0
 def GET(self):
     return R.render('user', user=web.ctx.session.user, msg='')
Example #31
0
 def GET(self, action = 'view', cid = 0):
     ecategory = model.Category.get_by_id(cid)
     if action == 'delete':
         model.Category.delete(cid)
     categorys = model.Category.get_all()
     return R.render('category', ecategory = ecategory, categorys = categorys)
Example #32
0
 def GET(self):
     return R.render('login')
Example #33
0
 def GET(self, tid = 0):
     tags = model.Tags.get_all()
     etag = model.Tags.get_by_id(tid)
     return R.render('tags', etag=etag, tags=tags)
Example #34
0
 def GET(self, action = 'view', lid = 0):
     if action == 'delete':
         model.Links.remove(lid)
     elink = model.Links.get_by_id(lid)
     links = model.Links.get_all()
     return R.render('links', elink=elink, links=links)
Example #35
0
 def GET(self, action = 'view', cid = 0):
     if action == 'delete':
         model.Comments.remove(cid)
     comments = model.Comments.get_all()
     return R.render('comment', comments=comments)
Example #36
0
 def GET(self, action = ''):
     return R.render('data')