Пример #1
0
def _msg(o,ml):
    allstart()
    if o == 'msg':
        mo = api.get_msg(ml) + {'msgid':ml}
        local.r.page_title =  mo.subj + ' @ ' + mo.echoarea
        lst = [mo]
    elif o == 'lst':
        lst=[api.get_msg(n) + {'msgid':n} for n in ml.split('/')]
        local.r.page_title = u'Список сообщений'
    return template('iitpl/msg.html',lst=[mo] if o != 'lst' else lst,r=local.r)
Пример #2
0
def _msg(o, ml):
    allstart()
    if o == 'msg':
        mo = api.get_msg(ml) + {'msgid': ml}
        local.r.page_title = mo.subj + ' @ ' + mo.echoarea
        lst = [mo]
    elif o == 'lst':
        lst = [api.get_msg(n) + {'msgid': n} for n in ml.split('/')]
        local.r.page_title = u'Список сообщений'
    return template('iitpl/msg.html',
                    lst=[mo] if o != 'lst' else lst,
                    r=local.r)
Пример #3
0
def js_page(pge):
    response.content_type = 'application/javascript; charset=utf-8'
    if pge == 'lenta.js':
        mo = [api.get_msg(n.split()[0]) for n in reversed(api.lst('m.accepted'))]
        if request.query.lim:
            mo = mo[:int(request.query.lim)]
    return template('js.tpl',mo=mo,rq=request.query)
Пример #4
0
def msglst(l,num):
    out = []
    for x in reversed(l[-num:]):
        n = api.get_msg(x)
        n.update({'url': '%s/msg/%s#go_%s' % (conf.URL,n.topicid,n.msgid),'pubDate': datetime.datetime.fromtimestamp(n.date)})
        out.append(n)
    return out
Пример #5
0
def create_message_point():
    ud = udata(request.forms.pauth.encode('utf-8'))
    dta = b64d(request.forms.tmsg.encode('utf-8')).decode('utf-8').splitlines()
    repto, tags = '', ''
    if dta[4].startswith('@repto:'):
        repto = dta[4][7:]
        if len(repto) != 20:
            return 'wrong repto!'
        txt = '\n'.join(dta[5:])
    elif dta[4].startswith('@tags:'):
        tags = dta[4][6:]
        txt = '\n'.join(dta[5:])
    else:
        txt = '\n'.join(dta[4:])
    mo = mydict(ea=dta[0],
                txt=txt,
                repto=repto,
                tags=tags,
                to=dta[1],
                title=dta[2] or '***')
    if repto:
        mo.topicid = api.get_msg(repto).topicid
    if ud.check() and ud.uname:
        nmsg = api.create_msg(mo, ud)
    return 'msg ok:%s' % nmsg
Пример #6
0
def index_list(ea, repto):
    allstart()
    cfg = config(CONFIG)
    local.r.NODE = cfg['server']['address']
    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)
Пример #7
0
def del_msg(itm):
    if not unm(itm):
        return
    o = api.get_msg(itm)
    unlist('carbon/%s' % api.hsh(o.to.encode('utf-8')), itm)
    unlist('carbon/_%s' % api.hsh(o.who.encode('utf-8')), itm)
    unlist('e/%s' % o.ea, itm)
    unlist('et/%s' % o.ea, itm)
    unlist('topic/%s' % o.topicid, itm)
    os.remove('data/m/%s' % itm)
Пример #8
0
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)
Пример #9
0
def index_list(ea,repto):
    allstart()
    cfg = config(CONFIG)
    local.r.NODE = cfg['server']['address']
    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)
Пример #10
0
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)
Пример #11
0
def gen_rss(ea,url,num):
    if not flt.echo_flt(ea): return ea
    msgs = [api.get_msg(n) + {'msgid': n} for n in reversed(api.get_echoarea_f(ea)[-num:])]
    items = [PyRSS2Gen.RSSItem(
        title=n.subj,description=sx.rend(n.msg),link='http://%s/%s#%s' % (url,ea,n.msgid),
        guid='http://%s/%s#%s' % (url,ea,n.msgid),
        pubDate=datetime.datetime.fromtimestamp(n.date)
    ) for n in msgs ]
    rssout = PyRSS2Gen.RSS2(title=ea,link='http://%s/%s' % (url,ea),description='Echoarea: %s' % ea,
    lastBuildDate=datetime.datetime.now(),items=items)
    return rssout.to_xml('utf-8')
Пример #12
0
def outmsg(msgids):
    response.set_header ('content-type','text/plain; charset=utf-8')
    result = ""
    for msgid in msgids.split("/"):
        result = result + msgid + ":"
        try:
            msg = str.encode(api.get_msg(msgid))
            result = result + (base64.b64encode(msg)).decode("utf-8") + "\n"
        except:
            result = result + "\n"
    return result
Пример #13
0
def outmsg(msgids):
    response.set_header('content-type', 'text/plain; charset=utf-8')
    result = ""
    for msgid in msgids.split("/"):
        result = result + msgid + ":"
        try:
            msg = str.encode(api.get_msg(msgid))
            result = result + (base64.b64encode(msg)).decode("utf-8") + "\n"
        except:
            result = result + "\n"
    return result
Пример #14
0
def reply_form(ea, topicid, repto):
    if repto and repto != '-':
        prev = api.get_msg(repto)
    else:
        prev = mydict()
    return template('frmnews.html',
                    u=u(),
                    prev=prev,
                    typ='blog',
                    ea=ea,
                    topicid=topicid,
                    repto=repto)
Пример #15
0
def blog_tag(tag):
    blogs = api.lst('tags/%s' % hsh(tag))
    comms = mydict({n: len(api.lst('topic/%s' % n)) - 6 for n in blogs})
    msgs = mydict({n: api.get_msg(n) for n in blogs})
    return template('blog-list.html',
                    blogs=blogs,
                    msgs=msgs,
                    comms=comms,
                    tag=tag,
                    ea='',
                    pge=-1,
                    u=u())
Пример #16
0
Файл: web.py Проект: jmaks/iing
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("/")
Пример #17
0
Файл: web.py Проект: jmaks/iing
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)
Пример #18
0
Файл: web.py Проект: jmaks/iing
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)
Пример #19
0
Файл: web.py Проект: jmaks/iing
def reply(e1, e2, msgid=False):
    echoarea = e1 + "." + e2
    auth = request.get_cookie("authstr")
    if msgid:
        msg = api.get_msg(msgid).split("\n")
    else:
        msg = False
    return template("tpl/reply.tpl",
                    nodename=api.nodename,
                    dsc=api.nodedsc,
                    echoarea=echoarea,
                    msgid=msgid,
                    msg=msg,
                    auth=auth,
                    hidehome=False,
                    topiclist=False,
                    background=api.background)
Пример #20
0
def lastcomm(ea,num,userdir=''):
    if ea:
        dl = api.lst('e/%s' % ea)
    else:
        dl = [n.split()[0] for n in api.lst('m.accepted')]
    if userdir:
        dl = [n for n in api.lst('carbon/%s' % userdir) if n in dl]
    cntr = 0
    msgs = []
    for n in reversed(dl):
        tmp = api.get_msg(n)
        if tmp.repto:
            msgs.append(tmp)
            cntr += 1
        if cntr >= num:
            break
    return msgs
Пример #21
0
Файл: web.py Проект: jmaks/iing
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)
Пример #22
0
def m(msgid):
    response.set_header("content-type", "text/plain; charset=utf-8")
    try:
        return api.get_msg(msgid)
    except:
        return ""
Пример #23
0
def print_topic(topicid):
    topic = api.lst('topic/%s' % topicid)
    return template('print.html', jd=api.get_msg(topic[5]), u=u())
Пример #24
0
def topic_list(topicid):
    topic = api.lst('topic/%s' % topicid)
    msgs = mydict({n:api.get_msg(n) for n in topic[5:]})
    return template('forum-topic.html',topicid=topicid,topic=topic,msgs=msgs,u=u())
Пример #25
0
def m(msgid):
    response.set_header("content-type", "text/plain; charset=utf-8")
    try:
        return api.get_msg(msgid)
    except:
        return ""
Пример #26
0
def blog_topic(topicid):
    topic = api.lst('topic/%s' % topicid)
    mo = [api.get_msg(n) for n in topic[5:]]
    return template ('blog-topic.html',mo=mo)