def mail(): userid = authed() offset = request.args.get('offset', 1) mails = getclient().listmails(offset=offset, limit=20) if 'error' in mails: return render_template('mailstatus.html', **mails) mails['offset'] = int(offset) return render_template('mail.html', limit=20, userid=userid, **mails)
def mail(): userid = authed() offset = request.args.get('offset', 1) mails = getclient().listmails(offset=offset, limit=20) if 'error' in mails : return render_template('mailstatus.html', **mails) mails['offset'] = int(offset) return render_template('mail.html', limit=20, userid=userid, **mails)
def sendmail(): if request.method == 'POST' : form = getfields(_require=('userid', 'title', 'text')) ret = getclient().do_sendmail(userid=form['userid'].encode('utf8'), title=form['title'].encode('utf8'), text=form['text'].encode('utf8')) return render_template('mailstatus.html', **ret) else : return render_template('sendmail.html')
def sendmail(): if request.method == 'POST': form = getfields(_require=('userid', 'title', 'text')) ret = getclient().do_sendmail(userid=form['userid'].encode('utf8'), title=form['title'].encode('utf8'), text=form['text'].encode('utf8')) return render_template('mailstatus.html', **ret) else: return render_template('sendmail.html')
def readmail(filename) : try: index = int(request.args.get('index')) except ValueError : return render_template('mailstatus.html', error=1, emsg=u'没有该邮件') mail = getclient().showmail(start=index) if mail.get('filename') == filename : mail['content'] = filter_ansi(open(getbbsfile(mail['@article']), encoding='gbk', errors='ignore').read()) return render_template('readmail.html', index=index, mail=mail) else : return render_template('mailstatus.html', error=1, emsg=u'没有该邮件')
def readmail(filename): try: index = int(request.args.get('index')) except ValueError: return render_template('mailstatus.html', error=1, emsg=u'没有该邮件') mail = getclient().showmail(start=index) if mail.get('filename') == filename: mail['content'] = filter_ansi( open(getbbsfile(mail['@article']), encoding='gbk', errors='ignore').read()) return render_template('readmail.html', index=index, mail=mail) else: return render_template('mailstatus.html', error=1, emsg=u'没有该邮件')
def board(boardname): db = getconn() board = getclient().showboard(board=boardname) if 'error' in board: abort(404) userid = getuserid() if userid: topics = db.query( u"SELECT herzog_topic.tid, owner, title, score, v, lastupdate," " lastreply, replynum, partnum, upvote, fromapp, readtime," " herzog_topicship.flag, content, upvote, boardname, herzog_topicship.flag as tsflag, readtime FROM herzog_topic" " LEFT JOIN herzog_topicship" " ON herzog_topicship.tid=herzog_topic.tid AND userid=%s" " WHERE boardname=%s" " ORDER BY score DESC LIMIT 16", userid, boardname) else: topics = db.query( u"SELECT tid, owner, title, score, v, lastupdate," " lastreply, replynum, partnum, upvote, fromapp," " flag, content, upvote, boardname FROM herzog_topic" " WHERE boardname=%s ORDER BY score DESC LIMIT 16", boardname) if len(topics) == 16: score = topics[-1].score del topics[15] else: score = -1 bsetting = getbsetting(boardname) or dict() print bsetting return render_template('board.html', board=board, bsetting=bsetting, topics=topics)
def starpost(): try: offset = int(request.args.get('offset', 0)) except: offset = 0 userid = authed() db = getconn() starpost = db.query( u"SELECT herzog_topic.tid,title" " FROM herzog_topic INNER JOIN herzog_topicship" " ON herzog_topic.tid = herzog_topicship.tid" " WHERE herzog_topicship.userid=%%s AND" " herzog_topicship.flag & 8" " ORDER BY herzog_topic.lastreply DESC" " LIMIT %s, 15" % offset, userid) # update touch time touch = db.get( u"SELECT touch_starpost FROM herzog_userdata" " WHERE userid=%s", userid) now = getnow() if touch: touch = touch.touch_starpost db.execute( u"UPDATE herzog_userdata SET touch_starpost=%s" " WHERE userid=%s", now, userid) else: db.execute( u"INSERT INTO herzog_userdata " " (userid, touch_notification, touch_starpost)" " VALUES (%s, %s, %s)", userid, now, now) return render_template('starpost.html', starpost=starpost, touch=touch)
def board(boardname): db = getconn() board = getclient().showboard(board=boardname) if 'error' in board : abort(404) userid = getuserid() if userid : topics = db.query(u"SELECT herzog_topic.tid, owner, title, score, v, lastupdate," " lastreply, replynum, partnum, upvote, fromapp, readtime," " herzog_topicship.flag, content, upvote, boardname, herzog_topicship.flag as tsflag, readtime FROM herzog_topic" " LEFT JOIN herzog_topicship" " ON herzog_topicship.tid=herzog_topic.tid AND userid=%s" " WHERE boardname=%s" " ORDER BY score DESC LIMIT 16", userid, boardname) else : topics = db.query(u"SELECT tid, owner, title, score, v, lastupdate," " lastreply, replynum, partnum, upvote, fromapp," " flag, content, upvote, boardname FROM herzog_topic" " WHERE boardname=%s ORDER BY score DESC LIMIT 16", boardname) if len(topics) == 16 : score = topics[-1].score del topics[15] else : score = -1 bsetting = getbsetting(boardname) or dict() print bsetting return render_template('board.html', board=board, bsetting=bsetting, topics=topics)
def index(): db = getconn() topics = db.query(u"SELECT tid, owner, title, score, v, lastupdate," " lastreply, replynum, partnum, upvote, fromapp," " flag, content, boardname FROM herzog_topic" " ORDER BY score DESC LIMIT 21") if len(topics) == 21 : score = topics[-1].score del topics[20] else : score = -1 boards = getclient().allboards() # Filter the topics use a whitelist fresh = groupup(topics) # TODO : topics may be NONE # TODO : perm filter # TODO : fresh and topten topten = [ dict(title=t.title, tid=t.tid, owner=t.owner) for t in topics[:10] ] img = hzd.get('page:fresh:image') goods = hzd.geta('page:fresh:goods') ad = hzd.geto('pgae:fresh:ad') return render_template('fresh.html', fresh=fresh, img=img, boards=boards, score=score, topten=topten, goods=goods, ad=ad)
def cms_manage(): db = getconn() pages = db.query(u"SELECT pid, pagepath, pagename, lastupdate, lastuserid" " FROM herzog_cms_page") res = db.query(u"SELECT rid, resname, lastupdate, lastuserid" " FROM herzog_cms_resource") return render_template("cms_manage.html", pages=pages, res=res)
def notification(): try: offset = int(request.args.get('offset', 0)) except: offset = 0 userid = authed() db = getconn() notification = db.query( u"SELECT nid,t,params,lastupdate" " FROM herzog_notification" " WHERE userid=%%s" " ORDER BY lastupdate DESC" " LIMIT %d, 15" % offset, userid) # update touch touch = db.get( u"SELECT touch_notification" " FROM herzog_userdata" " WHERE userid=%s", userid) now = getnow() if touch: touch = touch.touch_notification db.execute( u"UPDATE herzog_userdata SET " " touch_notification=%s" " WHERE userid=%s", now, userid) else: db.execute( u"INSERT INTO herzog_userdata " " (userid, touch_notification, touch_starpost)" " VALUES (%s, %s, %s)", userid, now, now) return render_template('notification.html', notification=notification, touch=touch)
def index(): db = getconn() topics = db.query(u"SELECT tid, owner, title, score, v, lastupdate," " lastreply, replynum, partnum, upvote, fromapp," " flag, content, boardname FROM herzog_topic" " ORDER BY score DESC LIMIT 21") if len(topics) == 21: score = topics[-1].score del topics[20] else: score = -1 boards = getclient().allboards() # Filter the topics use a whitelist fresh = groupup(topics) # TODO : topics may be NONE # TODO : perm filter # TODO : fresh and topten topten = [ dict(title=t.title, tid=t.tid, owner=t.owner) for t in topics[:10] ] img = hzd.get('page:fresh:image') goods = hzd.geta('page:fresh:goods') ad = hzd.geto('pgae:fresh:ad') return render_template('fresh.html', fresh=fresh, img=img, boards=boards, score=score, topten=topten, goods=goods, ad=ad)
def cms_manage(): db = getconn() pages = db.query(u"SELECT pid, pagepath, pagename, lastupdate, lastuserid" " FROM herzog_cms_page") res = db.query(u"SELECT rid, resname, lastupdate, lastuserid" " FROM herzog_cms_resource") return render_template("cms_manage.html", pages=pages, res=res)
def edit_resource(resname): userid = authed() res = getconn().get( u"SELECT * FROM herzog_cms_resource" " WHERE resname=%s", resname) res['ds'] = res['ds'] return render_template('edit_resource.html', res=res)
def newpost(boardname): boards = getboards() if boardname not in boards : abort(404) bsetting = { "image" : "/static/img/85.jpg" } tpl = request.form.get('template', None) return render_template('newpost.html', bsetting=bsetting, board=boards[boardname])
def page_preview(): form = getfields(_require=('pagepath', 'pagename', 'ds')) db = getconn() pagedata = db.get(u"SELECT tpl FROM herzog_cms_page" " WHERE pagepath=%s", form['pagepath']) if not pagedata: abort(404) return render_template('cms/%s.html' % pagedata.tpl, pagename=form['pagename'], **ds)
def replymail(filename): if request.method == 'POST' : form = getfields(_require=('userid', 'title', 'text', 'filenum')) ret = getclient().do_sendmail(userid=form['userid'].encode('utf8'), title=form['title'].encode('utf8'), filenum=form['filenum'], text=form['text'].encode('utf8')) return render_template('mailstatus.html', **ret) else : try: index = int(request.args.get('num')) except ValueError : return render_template('mailstatus.html', error=1, emsg=u'没有该邮件') mail = getclient().showmail(start=index) if mail.get('filename') == filename : title = quote_title(mail['title']) return render_template('replymail.html', title=title, index=index, mail=mail) else : return render_template('mailstatus.html', error=1, emsg=u'没有该邮件')
def page_preview() : form = getfields(_require=('pagepath', 'pagename', 'ds')) db = getconn() pagedata = db.get(u"SELECT tpl FROM herzog_cms_page" " WHERE pagepath=%s", form['pagepath']) if not pagedata : abort(404) return render_template('cms/%s.html' % pagedata.tpl, pagename=form['pagename'], **ds)
def allboards(): boards = getboards() sections = groupup(boards) bs = get_all_bsetting() if authed() : msg = getclient().getmessage() else : msg = None return render_template('allboards.html', secdatas=secdatas, boards=boards, sections=sections, bs=bs, msg=msg)
def replymail(filename): if request.method == 'POST': form = getfields(_require=('userid', 'title', 'text', 'filenum')) ret = getclient().do_sendmail(userid=form['userid'].encode('utf8'), title=form['title'].encode('utf8'), filenum=form['filenum'], text=form['text'].encode('utf8')) return render_template('mailstatus.html', **ret) else: try: index = int(request.args.get('num')) except ValueError: return render_template('mailstatus.html', error=1, emsg=u'没有该邮件') mail = getclient().showmail(start=index) if mail.get('filename') == filename: title = quote_title(mail['title']) return render_template('replymail.html', title=title, index=index, mail=mail) else: return render_template('mailstatus.html', error=1, emsg=u'没有该邮件')
def page(pagepath): db = getconn() pagedata = db.get(u'SELECT pagename, tpl, ds FROM herzog_cms_page' ' INNER JOIN herzog_cms_resource' ' ON herzog_cms_page.resname = ' ' herzog_cms_resource.rescname' ' WHERE pagepath=%s', pagepath) if not pagedata : abort(404) if '.' in pagedata.tpl : abort(404) return render_template('cms/%s.html' % pagedata.tpl, pagename=pagedata.pagename, **json.loads(pagedata.ds))
def allboards(): boards = getboards() sections = groupup(boards) bs = get_all_bsetting() if authed(): msg = getclient().getmessage() else: msg = None return render_template('allboards.html', secdatas=secdatas, boards=boards, sections=sections, bs=bs, msg=msg)
def page(pagepath): db = getconn() pagedata = db.get( u'SELECT pagename, tpl, ds FROM herzog_cms_page' ' INNER JOIN herzog_cms_resource' ' ON herzog_cms_page.resname = ' ' herzog_cms_resource.rescname' ' WHERE pagepath=%s', pagepath) if not pagedata: abort(404) if '.' in pagedata.tpl: abort(404) return render_template('cms/%s.html' % pagedata.tpl, pagename=pagedata.pagename, **json.loads(pagedata.ds))
def topic(tid): db = getconn() userid = authed() if userid : topic = db.get(u"SELECT herzog_topic.tid as tid, owner, title, score, v," " lastupdate, lastreply, replynum, partnum, upvote," " fromapp, herzog_topic.flag, content, upvote, boardname," " herzog_topicship.flag as tsflag, readtime FROM herzog_topic" " LEFT JOIN herzog_topicship" " ON herzog_topicship.tid=herzog_topic.tid" " AND herzog_topicship.userid=%s" " WHERE herzog_topicship.tid=%s", userid, tid) else : topic = db.get(u"SELECT tid, owner, title, score, v, lastupdate," " lastreply, replynum, partnum, upvote, fromapp," " flag, content, upvote, boardname FROM herzog_topic" " WHERE tid=%s", tid) if not topic : abort(404) if userid : replys0 = db.query(u"SELECT herzog_reply.rid, brid, replyid, owner," " lastupdate, fromapp, herzog_reply.flag, content," " upvote, herzog_replyship.flag as rsflag" " FROM herzog_reply LEFT JOIN herzog_replyship" " ON herzog_replyship.rid=herzog_reply.rid" " AND herzog_replyship.userid=%s" " WHERE tid=%s ORDER BY brid LIMIT 100", userid, tid) else : replys0 = db.query(u"SELECT herzog_reply.rid, brid, replyid, owner," " lastupdate, fromapp, flag, content, upvote" " herzog_replyship.flag as rsflag" " FROM herzog_reply" " WHERE tid=%s ORDER BY brid LIMIT 100", userid, tid) lastbranch = None lastcomments = None replys = [] for r in replys0 : if lastbranch is None or r.brid != lastbranch.brid : lastcomments = r['comments'] = [] lastbranch = r replys.append(r) else : lastcomments.append(r) topic['boarddesc'] = getboards()[topic['boardname']]['boarddesc'] return render_template('topic.html', topic=topic, replys=replys)
def fresh(): try : score = float(request.args.get('cursor')) except ValueError : return json_error('wrong cursor') topics = db.query(u"SELECT tid, owner, title, score, v, lastupdate," " lastreply, replynum, partnum, upvote, fromapp," " flag, content, boardname FROM herzog_topic" " WHERE score <= %s" " ORDER BY score DESC LIMIT 21", score) if len(topics) == 21 : score = topics[-1].score del topics[20] else : score = -1 fresh = groupup(topics) return render_template('fresh-append.html', fresh=fresh, score=score)
def fresh(): try: score = float(request.args.get('cursor')) except ValueError: return json_error('wrong cursor') topics = db.query( u"SELECT tid, owner, title, score, v, lastupdate," " lastreply, replynum, partnum, upvote, fromapp," " flag, content, boardname FROM herzog_topic" " WHERE score <= %s" " ORDER BY score DESC LIMIT 21", score) if len(topics) == 21: score = topics[-1].score del topics[20] else: score = -1 fresh = groupup(topics) return render_template('fresh-append.html', fresh=fresh, score=score)
def topic(tid): db = getconn() topic = db.get(u"SELECT tid, owner, title, score, v, lastupdate," " lastreply, replynum, partnum, upvote, fromapp," " flag, content FROM herzog_topic WHERE tid=%s", tid) if not topic : abort(404) replys0 = db.query(u"SELECT rid, brid, replyid, owner, lastupdate," " fromapp, flag, content FROM herzog_reply" " WHERE tid=%s ORDER BY brid LIMIT 100", tid) lastbranch = None lastcomments = None replys = [] for r in replys0 : if lastbranch is None or r.brid != lastbranch.brid : lastcomments = r['comments'] = [] lastbranch = r replys.append(r) else : lastcomments.append(r) return render_template('topic.html', topic=topic, replys=replys)
def topic(tid): db = getconn() topic = db.get( u"SELECT tid, owner, title, score, v, lastupdate," " lastreply, replynum, partnum, upvote, fromapp," " flag, content FROM herzog_topic WHERE tid=%s", tid) if not topic: abort(404) replys0 = db.query( u"SELECT rid, brid, replyid, owner, lastupdate," " fromapp, flag, content FROM herzog_reply" " WHERE tid=%s ORDER BY brid LIMIT 100", tid) lastbranch = None lastcomments = None replys = [] for r in replys0: if lastbranch is None or r.brid != lastbranch.brid: lastcomments = r['comments'] = [] lastbranch = r replys.append(r) else: lastcomments.append(r) return render_template('topic.html', topic=topic, replys=replys)
def testpage(): return render_template('test.html')
def edit_resource(resname): userid = authed() res = getconn().get(u"SELECT * FROM herzog_cms_resource" " WHERE resname=%s", resname) res['ds'] = res['ds'] return render_template('edit_resource.html', res=res)
def user(userid): user = getclient().queryuser(userid=userid) if '@plans' in user: user['plans'] = read_bbsfile(user['@plans']) return render_template('query_user.html', user=user)
def user(userid): user = getclient().queryuser(userid=userid) if '@plans' in user : user['plans'] = read_bbsfile(user['@plans']) return render_template('query_user.html', user=user)
def testpage(): return render_template('test.html')