예제 #1
0
파일: blog.py 프로젝트: radjah/point-www
def comments(page=1, unread=False):
    if not env.owner or env.owner.id != env.user.id:
        return Response(redirect='%s://%s.%s%s' % \
                        (env.request.protocol,
                         env.user.login.lower(), settings.domain,
                         env.request.path))

    try:
        page = int(page)
    except (TypeError, ValueError):
        page = 1
    if not page:
        page = 1

    offset = (page - 1) * settings.page_limit

    plist = posts.recent_commented_posts(unread=unread,
                                         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('/comments.html', section='comments',
                  unread=unread, posts=plist, page=page)
예제 #2
0
def comments(page=1, unread=False):
    if not env.owner or env.owner.id != env.user.id:
        return Response(redirect='%s://%s.%s%s' % \
                        (env.request.protocol,
                         env.user.login.lower(), settings.domain,
                         env.request.path))

    try:
        page = int(page)
    except (TypeError, ValueError):
        page = 1
    if not page:
        page = 1

    offset = (page - 1) * settings.page_limit

    plist = posts.recent_commented_posts(unread=unread,
                                         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('/comments.html',
                  section='comments',
                  unread=unread,
                  posts=plist,
                  page=page)
예제 #3
0
def comments():
    before = env.request.args("before")
    if before:
        try:
            before = long(before)
        except ValueError:
            before = None

    plist = posts.recent_commented_posts(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
파일: blog.py 프로젝트: skobkin/point
def comments():
    before = env.request.args("before")
    if before:
        try:
            before = long(before)
        except ValueError:
            before = None

    plist = posts.recent_commented_posts(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}