Пример #1
0
def private_posts(show=False, offset=None, limit=None):
    if offset:
        offset = int(offset)
    if limit:
        limit = int(limit)
    else:
        offset = 0
        limit = 10

    plist = posts.private_unread(offset=offset, limit=limit)
    if not plist:
        plist = posts.private_incoming(offset=offset, limit=limit)
    plist.reverse()

    return xmpp_template('posts', posts=plist)
Пример #2
0
def private_posts(show=False, offset=None, limit=None):
    if offset:
        offset = int(offset)
    if limit:
        limit = int(limit)
    else:
        offset = 0
        limit = 10

    plist = posts.private_unread(offset=offset, limit=limit)
    if not plist:
        plist = posts.private_incoming(offset=offset, limit=limit)
    plist.reverse()

    return xmpp_template('posts', posts=plist)
Пример #3
0
def messages_incoming():
    before = env.request.args("before")
    if before:
        try:
            before = long(before)
        except ValueError:
            before = None

    plist = posts.private_incoming(limit=settings.page_limit + 1, before=before)

    if len(plist) > settings.page_limit:
        plist = plist[: settings.page_limit]
        has_next = True
    else:
        has_next = False

    return {"posts": plist, "has_next": has_next}
Пример #4
0
def messages_incoming(page=1):
    try:
        page = int(page)
    except (TypeError, ValueError):
        page = 1
    if not page:
        page = 1

    offset = (page - 1) * settings.page_limit

    plist = posts.private_incoming(offset=offset, limit=settings.page_limit+1)

    if env.request.is_xhr:
        for p in plist:
            p['created'] = timestamp(p['created'])
        return Response(json.dumps(plist), mimetype='application/json')

    return render('/messages/incoming.html', section='messages', posts=plist, page=page)
Пример #5
0
def messages_incoming():
    before = env.request.args("before")
    if before:
        try:
            before = long(before)
        except ValueError:
            before = None

    plist = posts.private_incoming(limit=settings.page_limit + 1,
                                   before=before)

    if len(plist) > settings.page_limit:
        plist = plist[:settings.page_limit]
        has_next = True
    else:
        has_next = False

    return {"posts": plist, "has_next": has_next}
Пример #6
0
def messages_incoming(page=1):
    try:
        page = int(page)
    except (TypeError, ValueError):
        page = 1
    if not page:
        page = 1

    offset = (page - 1) * settings.page_limit

    plist = posts.private_incoming(offset=offset, limit=settings.page_limit+1)

    if env.request.is_xhr:
        for p in plist:
            p['created'] = timestamp(p['created'])
        return Response(json.dumps(plist), mimetype='application/json')

    return render('/messages/incoming.html', section='messages', posts=plist, page=page)