def index_list(echo,year): allstart() ea = '%s.%s' % (echo,year) if not flt.echo_flt(ea): return ea elist = api.load_echo(True) local.r.update(page_title=ea,echolist=elist,ea=ea) return template('iitpl/echoarea.html',r=local.r,j=api.get_echoarea_f(ea))
def index_list(echo, year): allstart() ea = '%s.%s' % (echo, year) if not flt.echo_flt(ea): return ea cfg = api.load_echo(True) local.r.update(page_title=ea, echolist=cfg[1:], ea=ea) return template('iitpl/echoarea.html', r=local.r, j=api.get_echoarea_f(ea))
def msg_post(ea): allstart() fz = local.r.fz cfg = api.load_echo(False) ufor = request.forms.msgfrom.encode('utf-8') if not flt.echo_flt(ea): return ea if not fz.msg or not fz.subj: return 'empty msg or subj' uname, uaddr = points.check_hash(ufor) if uaddr: mo = sx.mydict() for _ in ('subj', 'msg', 'repto'): mo[_] = fz[_].decode('utf-8') mo['msgfrom'] = uname mo['msg'] = mo['msg'].replace('\r\n', '\n') mo['date'] = str(sx.gts()) mo.update(addr='%s, %s' % (cfg[0][1], uaddr), msgto=request.forms.msgto, echoarea=ea) api.savemsg(mo) else: return 'no auth' if ufor != local.r.auth: response.set_cookie('auth', ufor, path='/', max_age=7776000) return ( '<html><head><meta http-equiv="refresh" content="0; /%s" /></head><body></body></html>' % ea) else: redirect('/%s' % ea)
def list_txt(): response.set_header ('content-type','text/plain; charset=utf-8') lst = api.load_echo(False)[1:] if request.query.n: return '\n'.join([t[0] for t in lst]) else: return '\n'.join(['%s:%s:%s' % t for t in lst])
def index_list(ea,repto): allstart() cfg = api.load_echo() local.r.NODE = cfg[0][1] if repto and repto != '-': local.r.repto = repto local.r.rmsg = api.get_msg(repto) if not flt.echo_flt(ea): return ea local.r.page_title = u'message to ' + ea return template('iitpl/mform.html',r=local.r,ea=ea)
def index_list(ea, repto): allstart() cfg = api.load_echo() local.r.NODE = cfg[0][1] if repto and repto != '-': local.r.repto = repto local.r.rmsg = api.get_msg(repto) if not flt.echo_flt(ea): return ea local.r.page_title = u'message to ' + ea return template('iitpl/mform.html', r=local.r, ea=ea)
def start_page(): allstart() cfg = api.load_echo(True) if local.r.kuk.myel: myel = [e for e in local.r.kuk.myel.splitlines() if flt.echo_flt(e)] else: myel = [] if not myel: myel = cfg[1:] else: myel = api.separate_myel(myel, cfg[1:]) #print myel lst = [(e, api.get_echoarea_f(e)) for e, c, d in myel] local.r.page_title = u'ii : всё для хорошего общения' return template('iitpl/index.html', r=local.r, lst=lst)
def list_txt(): response.set_header('content-type', 'text/plain; charset=utf-8') lst = api.load_echo(False)[1:] if request.query.el: el = request.query.el.split('/') descs = dict([(a, c.decode('utf-8')) for a, b, c in lst]) lst = [(x, api.echoarea_count(x), descs[x] if x in descs else '') for x in el] if request.query.n: return '\n'.join([t[0] for t in lst]) elif request.query.h: return '\n'.join([ '%s:%s:hsh/%s' % (t[0], t[1], sx.hsh(api.get_echoarea(t[0], True))) for t in lst ]) else: return '\n'.join(['%s:%s:%s' % t for t in lst])
def _point_msg(pauth, tmsg): msgfrom, addr = points.check_hash(pauth) if not addr: return 'auth error!' cfg = api.load_echo(False) mo = api.toss(msgfrom, '%s, %s' % (cfg[0][1], addr), tmsg.strip()) if mo.msg.startswith('@repto:'): tmpmsg = mo.msg.splitlines() mo.repto = tmpmsg[0][7:] mo.msg = '\n'.join(tmpmsg[1:]) if len(mo.msg.encode('utf-8')) < 64100: h = api.point_newmsg(mo) if h: return 'msg ok:%s: <a href="/%s">%s</a>' % (h, mo.echoarea, mo.echoarea) else: return 'error:unknown' else: return 'msg big!'
def _point_msg(pauth,tmsg): msgfrom, addr = points.check_hash(pauth) if not addr: return 'auth error!' cfg = api.load_echo(False) mo = api.toss(msgfrom,'%s,%s' % (cfg[0][1],addr),tmsg.strip()) if mo.msg.startswith('@repto:'): tmpmsg = mo.msg.splitlines() mo.repto = tmpmsg[0][7:] mo.msg = '\n'.join(tmpmsg[1:]) # а ещё лучше - засунуть это в api.toss if len(mo.msg.encode('utf-8')) < 64100: h = api.point_newmsg(mo) if h: return 'msg ok:%s: <a href="/%s">%s</a>' % (h, mo.echoarea, mo.echoarea) else: return 'error:unknown' else: return 'msg big!'
def msg_post(ea): allstart(); fz = local.r.fz cfg = api.load_echo(False) ufor = request.forms.msgfrom.encode('utf-8') if not flt.echo_flt(ea): return ea if not fz.msg or not fz.subj: return 'empty msg or subj' uname, uaddr = points.check_hash(ufor or local.r.auth) if uaddr: mo = sx.mydict() for _ in ('subj', 'msg', 'repto'): mo[_] = fz[_].decode('utf-8') mo['msgfrom'] = uname mo['msg']=mo['msg'].replace('\r\n','\n') mo.update(addr='%s,%s' % (cfg[0][1], uaddr),msgto=request.forms.msgto,echoarea=ea) h = api.point_newmsg(mo) if not h: return 'bad message' else: return 'no auth' redir = fz.goback or '/%s' % ea if ufor: response.set_cookie('auth',ufor,path='/',max_age=7776000) return ('<html><head><meta http-equiv="refresh" content="0; %s" /></head><body></body></html>' % redir) else: redirect (redir)
def rss_echo(echo,year,num=50): cfg = api.load_echo(True) response.set_header('content-type','application/rss+xml; charset=utf-8') return rssg.gen_rss('%s.%s' % (echo, year),cfg[0][0],num)
def start_page(): allstart() cfg = api.load_echo(True) lst=[(e,api.get_echoarea_f(e)) for e,c,d in cfg[1:]] local.r.page_title = u'ii : ваше домашнее фидо' return template('iitpl/index.html',r=local.r,lst=lst)
def rss_echo(echo, year, num=50): cfg = api.load_echo(True) response.set_header('content-type', 'application/rss+xml; charset=utf-8') return rssg.gen_rss('%s.%s' % (echo, year), cfg[0][0], num)