def index_list(names): write_to_log("u/e/%s" % names) response.set_header('content-type', 'text/plain; charset=utf-8') result = "" r = False s = 0 e = 0 names = names.split("/") if ":" in names[-1]: s = int(names[-1].split(":")[0]) e = int(names[-1].split(":")[1]) r = True names = names[0:-1] for echoarea in names: result = result + echoarea + "\n" try: ss = s if s < 0 and s + int(api.get_echoarea_count(echoarea)) < 0: ss = 0 elif s > int(api.get_echoarea_count(echoarea)): ss = e * -1 if r: if s + e == 0: msglist = api.get_echoarea(echoarea)[ss:] else: msglist = api.get_echoarea(echoarea)[ss:ss + e] else: msglist = api.get_echoarea(echoarea) result = result + "\n".join(msglist) + "\n" except: result = result + "" return result
def echoes(subscription): allechoareas = [] for echoarea in subscription: temp = echoarea if not request.get_cookie(echoarea[0]): response.set_cookie(echoarea[0], api.get_last_msgid(echoarea[0]), path="/", max_age=180 * 24 * 60 * 60, secret='some-secret-key') current = request.get_cookie(echoarea[0], secret='some-secret-key') if not current: current = api.get_last_msgid(echoarea[0]) echoarea_msglist = api.get_echoarea(echoarea[0]) new = 0 last = False if len(echoarea_msglist) > 0: if current in echoarea_msglist: new = int(api.get_echoarea_count( echoarea[0])) - echoarea_msglist.index(current) - 1 if new > 0: last = echoarea_msglist[-new] else: last = echoarea_msglist[-1] temp.append(new) temp.append(last) if last and len(last) > 0: temp.append(get_page(api.get_echoarea(echoarea[0]).index(last))) else: temp.append(get_page(len(api.get_echoarea(echoarea[0])))) allechoareas.append(temp) return allechoareas
def index_list(names): write_to_log("u/e/%s" % names) response.set_header('content-type','text/plain; charset=utf-8') result = "" r = False s = 0 e = 0 names = names.split("/") if ":" in names[-1]: s = int(names[-1].split(":")[0]) e = int(names[-1].split(":")[1]) r = True names = names[0:-1] for echoarea in names: result = result + echoarea + "\n" try: ss = s if s < 0 and s + int(api.get_echoarea_count(echoarea)) < 0: ss = 0 elif s > int(api.get_echoarea_count(echoarea)): ss = e * -1 if r: if s + e == 0: msglist = api.get_echoarea(echoarea)[ss:] else: msglist = api.get_echoarea(echoarea)[ss:ss + e] else: msglist = api.get_echoarea(echoarea) result = result + "\n".join(msglist) + "\n" except: result = result + "" return result
def index(): api.load_config() echoareas = [] s = request.get_cookie("subscription", secret='some-secret-key') if not s: subscription = [] for ea in api.echoareas: subscription.append(ea[0]) response.set_cookie("subscription", subscription, path="/", max_age=180 * 24 * 60 * 60, secret='some-secret-key') s = subscription if api.nosubscription: subscription = api.echoareas else: subscription = [] for ea in s: flag = False for e in api.echoareas: if ea in e: flag = True subscription.append(e) if not flag: subscription.append([ea, ""]) ea = [[echoarea[0], echoarea[1], api.get_time(echoarea[0])] for echoarea in subscription] for echoarea in sorted(ea, key=lambda ea: ea[2], reverse=True)[0:5]: last = request.get_cookie(echoarea[0], secret='some-secret-key') if not last in api.get_echo_msgids(echoarea[0]): last = False if not last or len(last) == 0: last = api.get_last_msgid(echoarea[0]) if last and len(last) > 0: page = get_page(api.get_echoarea(echoarea[0]).index(last)) else: page = get_page(len(api.get_echoarea(echoarea[0]))) echoareas.append({ "echoname": echoarea[0], "count": api.get_echoarea_count(echoarea[0]), "dsc": echoarea[1], "msg": api.get_last_msg(echoarea[0]), "last": last, "page": page }) allechoareas = echoes(subscription) auth = request.get_cookie("authstr") msgfrom, addr = points.check_point(auth) return template("tpl/index.tpl", nodename=api.nodename, dsc=api.nodedsc, echoareas=echoareas, allechoareas=allechoareas, addr=addr, auth=auth, background=api.background, nosubscription=api.nosubscription)
def qua(ea, s): items = api.get_echoarea(ea) if len(s) < 6 and s.isdigit(): return items[-int(s):] else: if s not in items: return items return items[items.index(s) + 1:]
def ffeed(echoarea, msgid, page): api.load_config() msglist = api.get_echoarea(echoarea) result = [] last = request.get_cookie(echoarea, secret='some-secret-key') if not last in api.get_echoarea(echoarea): last = False if not last or len(last) == 0: last = api.get_last_msgid(echoarea) if not page: if not last: page = get_page(len(msglist)) if page == 0: page = 1 else: page = get_page(msglist.index(last)) page = int(page) start = page * 50 - 50 end = start + 50 for mid in msglist[start:end]: msg = api.get_msg(mid).split("\n") if len(msg) > 1: result.append([mid, msg]) ea = [ea for ea in api.echoareas if ea[0] == echoarea] if len(ea) != 1: ea = [echoarea, ""] else: ea = ea[0] auth = request.get_cookie("authstr") if len(msglist) <= end: end = api.get_last_msgid(echoarea) else: end = msglist[end] response.set_cookie(echoarea, end, path="/", max_age=180 * 24 * 60 * 60, secret='some-secret-key') return template("tpl/feed.tpl", nodename=api.nodename, dsc=api.nodedsc, echoarea=ea, page=page, msgs=result, msgid=msgid, background=api.background, auth=auth)
def qua(ea, s): items = api.get_echoarea(ea) if len(s) < 6 and s.isdigit(): return items[-int(s) :] else: if not s in items: return items return items[items.index(s) + 1 :]
def parse_echos(el): echos = el.split("/") pool = [] for ea in echos: if ":" in ea: items = qua(*ea.split(":", 1)) else: items = api.get_echoarea(ea) for x in items: if not x in pool: pool.append(x) return pool
def parse_echos(el): echos = el.split('/') pool = [] for ea in echos: if ':' in ea: items = qua(*ea.split(':', 1)) else: items = api.get_echoarea(ea) for x in items: if x not in pool: pool.append(x) return pool
def showmsg(msgid): api.load_config() if api.msg_filter(msgid): body = api.get_msg(msgid).split("\n") if body != [""]: msgfrom, addr = points.check_point(request.get_cookie("authstr")) kludges = body[0].split("/") if "repto" in kludges: repto = kludges[kludges.index("repto") + 1] else: repto = False if len(body) > 0: echoarea = [ea for ea in api.echoareas if ea[0] == body[1]] if len(echoarea) == 0: echoarea = [body[1], ""] else: echoarea = echoarea[0] else: echoarea = ["", ""] t = api.formatted_time(body[2]) point = body[3] address = body[4] to = body[5] subj = body[6] body = body[8:] index = api.get_echoarea(echoarea[0]) current = index.index(msgid) response.set_cookie(echoarea[0], msgid, max_age=180 * 24 * 60 * 60, secret='some-secret-key') auth = request.get_cookie("authstr") return template("tpl/message.tpl", nodename=api.nodename, echoarea=echoarea, index=index, msgid=msgid, repto=repto, current=current, time=t, point=point, address=address, to=to, subj=subj, body=body, msgfrom=msgfrom, background=api.background, auth=auth) else: redirect("/") else: redirect("/")
def echoreas(e1, e2, msgid=False, page=False): echoarea = e1 + "." + e2 if not request.get_cookie(echoarea): response.set_cookie(echoarea, api.get_last_msgid(echoarea), max_age=180 * 24 * 60 * 60, secret='some-secret-key') last = msgid or request.get_cookie(echoarea, secret='some-secret-key') if not last in api.get_echoarea(echoarea): last = False if not last or len(last) == 0: last = api.get_last_msgid(echoarea) index = api.get_echoarea(echoarea) if len(index) > 0 and index[-1] != last and last in index: last = index[index.index(last) + 1] if len(index) == 0: last = False if echoarea != "favicon.ico": if last: redirect("/" + last) else: redirect("/new/" + echoarea)
def rss(echoarea): response.set_header("content-type", "application/rss+xml; charset=utf-8") api.load_config() msglist = api.get_echoarea(echoarea) msgs = [] for msgid in msglist[-50:]: msgs.append([msgid, api.get_msg(msgid).split("\n")]) return template("tpl/rss.tpl", nodename=api.nodename, dsc=api.nodedsc, nodeurl=api.nodeurl, msgs=reversed(msgs), echoarea=echoarea)
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 msg_list(echoarea, page=False, msgid=False): api.load_config() msglist = api.get_echoarea(echoarea) result = [] for mid in msglist: msg = api.get_msg(mid).split("\n") try: subject = msg[6] f = msg[3] t = msg[5] result.append({ "msgid": mid, "subject": subject, "from": f, "to": t }) except: None ea = [ea for ea in api.echoareas if ea[0] == echoarea] if len(ea) == 0: ea = [echoarea, ''] else: ea = ea[0] if not page: if not msgid: page = get_page(len(msglist)) else: page = get_page(msglist.index(msgid)) if page == 0: page = 1 return template("tpl/msglist.tpl", nodename=api.nodename, dsc=api.nodedsc, page=int(page), echoarea=ea, msgid=msgid, msglist=result, topiclist=False, background=api.background)
def get_echolist(echoarea): response.set_header ('content-type','text/plain; charset=utf-8') return api.get_echoarea(echoarea,True)
def e(echoarea): write_to_log("e/%s" % echoarea) response.set_header("content-type", "text/plain; charset=utf-8") return "\n".join(api.get_echoarea(echoarea))
def get_echolist(echoarea): response.set_header('content-type', 'text/plain; charset=utf-8') return api.get_echoarea(echoarea, True)