def show_echoarea(ea, opts=''): if not '.' in ea: ea += '.11' opts = opts.split(',') + ['', '', ''] lim, page, rev = '/lim/100', '', '' pg = 1 if opts[0]: page = '/page/%s' % opts[0] pg = int(opts[0]) if opts[1]: lim = '/lim/%s' % opts[1] if opts[2] == 'rev': rev = '/rev/1' cnt = app_rq('echolist/none/addecho/%s/cnt/1' % ea)[0][1] msgs = app_rq('echo/%s%s%s%s' % (ea, lim, page, rev)) if opts[2] == 'intrev': msgdict = [] for n in msgs: msgdict.append(mydict(n._data)) msgs = msgdict[::-1] return template('tpl/echoarea.html', msgs=msgs, ea=ea, opts=opts, u=get_u(), cnt=cnt, page=pg)
def show_lite(ea, mid=''): if mid: rmsg = app_rq('msgs/%s/fmt/noempty' % mid) else: rmsg = mydict() msgs = app_rq('echo/%s/lim/30' % ea) return template('tpl/lite.html', msgs=msgs, ea=ea, u=get_u(), rmsg=rmsg)
def post_user(ea): if request.forms.outtxt: data = mydict(request.forms) uu = userbb.check_auth(data.uhash) if uu: data.update(uname=uu.uname.encode('utf-8'), addr='%s,%s' % (conf.STREET, uu.id)) else: return 'no hash - no msg' app_rq('point/user/ea/%s' % ea, data) redirect(request.forms.beback or '/:%s' % ea)
def show_msgid(msgs): msgs = msgs.replace('/', ':') lrq = app_rq('msgs/%s' % msgs) lst = mydict() for n in lrq: lst[n.mid] = mydict(n._data) return template('tpl/msg.html', msgs=msgs, lst=lst, u=get_u())
def json_ret(k, v): out = mydict() if k == 'msgs': for n in app_rq('msgs/%s' % v): out[n.mid] = mydict(n._data) - 'accepted' - 'id' elif k == 'echo': lim = 'lim/%s/' % request.params.lim if request.params.lim else '' for n in app_rq('%secho/%s' % (lim, v)): out.setdefault(n.echoarea, []) out[n.echoarea].append(n.mid) elif k == 'echolist': if request.params.cnt: out.echolist = mydict() for n in app_rq('echolist/%s/cnt/1' % v): out.echolist[n[0]] = n[1] else: out.echolist = app_rq_txt('echolist/%s' % v).splitlines() if request.params.callback: response.content_type = 'application/javascript; charset=utf-8' return '%s (\n%s\n)' % (request.params.callback, jout(out)) else: response.content_type = 'application/json; charset=utf-8' return jout(out)
def show_topic(tid): msgs = [] lrq = app_rq('topicid/%s/rev/1' % tid) lst = mydict() deftitle = '' for n in lrq: lst[n.mid] = mydict(n._data) msgs.append(n.mid) deftitle = n.title if not deftitle else deftitle return template('tpl/msg.html', msgs=':'.join(msgs), lst=lst, u=get_u(), deftitle=u'Topic: %s' % deftitle)
def reply_to(ea, repto): u = get_u() if not u: redirect('/user/me?redir=/reply/%s/%s' % (ea, repto)) rep = repto if repto != '-' else '' if rep: # fix msgs// ! rmsg = app_rq('msgs/%s/fmt/noempty' % rep) else: rmsg = mydict() return template('tpl/mform.html', rmsg=rmsg, ea=ea, repto=rep, u=u, zo=request.query.tn)
def show_topic(tid): msgs, deftitle = topic.get_topic(tid, request.query.flag) try: ea = dbj.msg.get(dbj.msg.mid == msgs.split(':')[0]).echoarea except: ea = '' lrq = app_rq('msgs/%s' % msgs) lst = mydict() for n in lrq: lst[n.mid] = mydict(n._data) return template('tpl/msg.html', msgs=msgs, lst=lst, u=get_u(), deftitle=u'Topic: %s' % deftitle, ea=ea, tn=deftitle)
def show_lite(ea, opts=''): msgs = app_rq('echo/%s/lim/30' % ea) return template('tpl/lite.html', msgs=msgs, ea=ea, u=get_u())
def lite_list(authstr=None): if authstr: response.set_cookie('uhash', authstr, path='/', max_age=7776000) return template('tpl/litelist.html', elist=app_rq('echolist/public'))