Exemplo n.º 1
0
def blog_list(ea=''):
    if not ea:
        ea = api.echolist()[0]
    blogs = api.lst('et/%s' % ea)
    comms = mydict({n:len(api.lst('topic/%s' % n))-6 for n in blogs})
    pge = request.query.page or '1'
    return template ('blog-list.html',ea=ea,blogs=blogs,comms=comms,pge=int(pge)-1)
Exemplo n.º 2
0
def del_all(itm):
    if api.lst('topic/%s' % itm):
        del_from_tags(itm)
        for n in api.lst('topic/%s' % itm)[5:]:
            del_msg(n)
        unlist('topic.list', itm)
        touch('data/topic.list')
        os.remove('data/topic/%s' % itm)
    else:
        del_msg(itm)
Exemplo n.º 3
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())
Exemplo n.º 4
0
def all_bundle():
    response.content_type = 'text/plain; charset=utf-8'
    out = ''
    el, fl = {}, api.lst('e.list')
    for ea in fl:
        el[ea] = api.lst('e/%s' % ea)
    for n in [x.split()[0] for x in api.lst('m.accepted')]:
        for ea in fl:
            if n in el[ea]:
                out += '%s:%s\n' % (n,ea)
                break
    return out
Exemplo n.º 5
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)
Exemplo n.º 6
0
def echo_bundle(f):
    response.content_type = 'text/plain; charset=utf-8'
    out = []
    for n in [x for x in f.split('/') if '.' in x]:
        out.append(n)
        out += [x for x in api.lst('e/%s' % n)]
    return '\n'.join(out)
Exemplo n.º 7
0
def carbon_copy(carbon,uname):
    mo = [n for n in reversed(api.lst('carbon/%s' % carbon))]
    if carbon.startswith('_'):
        title = 'Сообщения от пользователя %s' % uname
    else:
        title = 'Сообщения для пользователя %s' % uname
    return template('echoarea.html',mo=mo,title=title,u=u(),desc='Карбонки',ea='',pge=0)
Exemplo n.º 8
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
Exemplo n.º 9
0
def carbon_area(di, un, ea=''):
    if di in ('from', 'to'):
        uh = hsh(un) if di == 'to' else '_' + hsh(un)
        comm = rss.lastcomm(ea, 20, uh)
        return template('reg/lastcomm.html',
                        uname=un,
                        comms=comm,
                        u=u(),
                        admikey=ak(),
                        ea=ea)
    elif di == 'news':
        topic = api.lst('et/%s' % ea) if ea else api.lst('topic.list')
        um = set(api.lst('carbon/_' + hsh(un)))
        return template('reg/lastnews.html',
                        uname=un,
                        news=[x for x in topic if x in um][-15:],
                        u=u(),
                        ea=ea)
Exemplo n.º 10
0
def gettop(ea, cnt=6):
    if ea:
        ealist = set(get_ea(ea))
    topc = []
    for n in os.listdir('data/nuser'):
        un = rf('data/nuser/%s' % n)
        l = len([x for x in lst('carbon/_%s' % n) if not ea or (x in ealist)])
        if l:
            topc.append([l, un])
    return list(reversed(sorted(topc)))[:cnt]
Exemplo n.º 11
0
def unm(itm):
    out = api.lst('m.accepted')
    for n in out:
        mid, ts = n.split()
        if mid == itm:
            out.remove(n)
            if out:
                open('data/m.accepted', 'w').write('\n'.join(out) + '\n')
            else:
                open('data/m.accepted', 'w').write('')
            return True
Exemplo n.º 12
0
def unlist(fn, itm):
    print fn, itm
    out = api.lst(fn)
    print out
    if itm in out:
        out.remove(itm)
        print out
        if out:
            open('data/' + fn, 'w').write('\n'.join(out) + '\n')
        else:
            os.remove('data/' + fn)
            return True
Exemplo n.º 13
0
def start_page():
    mo = [x.split()[0] for x in reversed(api.lst('m.accepted'))]
    return template('start.html',out=api.forums_list(),mo=mo,u=u())
Exemplo n.º 14
0
def gen_blog(ea,num=30):
    topics = set(api.lst('topic.list'))
    comms = [x for x in api.get_ea(ea) if x in topics]
    return template('rss/rss.tpl',msgs=msglst(comms,num),title=ea,link='%s/blog/%s' % (conf.URL,ea),desc='%s: %s' % (ea,api.echo_desc(ea)))
Exemplo n.º 15
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)
Exemplo n.º 16
0
def list_txt():
    out = ''
    response.content_type = 'text/plain; charset=utf-8'
    for n in api.echolist():
        out += '%s:%s:%s\n' % (n, len(api.lst('e/%s' % n)), api.echo_desc(n) or 'no desc')
    return out
Exemplo n.º 17
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())
Exemplo n.º 18
0
def print_topic(topicid):
    topic = api.lst('topic/%s' % topicid)
    return template('print.html', jd=api.get_msg(topic[5]), u=u())
Exemplo n.º 19
0
def blog_select():
    return template('select-blog.html',
                    u=u(),
                    ea='',
                    out=[(n, len(api.lst('e/%s' % n)), api.echo_desc(n)
                          or 'no desc') for n in api.echolist()])
Exemplo n.º 20
0
def echo_list(ea):
    mo = [n for n in reversed(api.lst('e/%s' % ea))]
    pge = request.query.page or '1'
    return template('echoarea.html',mo=mo,title=ea,ea=ea,u=u(),desc=api.echo_desc(ea),pge=int(pge)-1)
Exemplo n.º 21
0
def gen_topic(topicid,num=30):
    comms = api.lst('topic/%s' % topicid)
    ea, desc = comms[2], comms[1]
    return template('rss/rss.tpl',msgs=msglst(comms[6:],num),title=ea,link='%s/msg/%s' % (conf.URL,topicid),desc=desc)
Exemplo n.º 22
0
def lenta_list():
    mo = [n.split()[0] for n in reversed(api.lst('m.accepted'))]
    return template('echoarea.html',mo=mo,title='Лента сообщений',u=u(),ea='',desc='все сообщения всех эх',pge=0)