예제 #1
0
def latest():
    incr, start, next, prev = parse_qs(request.args)
    quotes = db.latest(incr, start)
    admin = authDB.isAuthenticated(request)
    if request.wants_json():
        next_link = '/quotes?start=%s' % (next)
        prev_link = '/quotes?start=%s' % (prev)
        json = {
            'quotes':
            quotes,
            'links': [
                build_link(next_link, 'pyqdb/quotes/next',
                           Quote.list_json_mimetype),
                build_link(prev_link, 'pyqdb/quotes/prev',
                           Quote.list_json_mimetype)
            ]
        }
        rs = jsonify(json, Quote.list_json_mimetype)
        add_link_hdr(rs, next_link, 'pyqdb/quotes/next')
        if start > 0:
            add_link_hdr(rs, prev_link, 'pyqdb/quotes/prev')
        return rs
    return render_template('quotes.html',
                           nav=navs,
                           quotes=quotes,
                           page='quotes',
                           next=next,
                           prev=prev,
                           isAdmin=admin)
예제 #2
0
파일: pyqdb.py 프로젝트: Ramblurr/pyqdb
def latest():
    incr,start,next,prev = parse_qs(request.args)
    quotes = db.latest(incr, start)
    admin = authDB.isAuthenticated(request)
    if request.wants_json():
        next_link = '/quotes?start=%s' % (next)
        prev_link = '/quotes?start=%s' % (prev)
        json = {'quotes': quotes, 'links': [ 
            build_link(next_link, 'pyqdb/quotes/next', Quote.list_json_mimetype),
            build_link(prev_link, 'pyqdb/quotes/prev', Quote.list_json_mimetype) ]
        }
        rs = jsonify(json, Quote.list_json_mimetype)
        add_link_hdr(rs, next_link, 'pyqdb/quotes/next')
        if start > 0:
            add_link_hdr(rs, prev_link, 'pyqdb/quotes/prev')
        return rs
    return render_template('quotes.html', nav=navs, quotes=quotes, page='quotes', next=next, prev=prev, isAdmin=admin)
예제 #3
0
def new_quote():
    if request.wants_json():
        rs = jsonify(
            {
                'body':
                "Quote here",
                'tags': [],
                'link':
                build_link('/quotes',
                           'pyqdb/quote/new',
                           Quote.json_mimetype,
                           method='post',
                           title='Create a new quote')
            }, Quote.json_mimetype)
        add_link_hdr(rs, '/quotes', 'pyqdb/quote/new')
        return rs
    return render_template('submit.html', nav=navs)
예제 #4
0
파일: pyqdb.py 프로젝트: Ramblurr/pyqdb
def new_quote():
    if request.wants_json():
        rs = jsonify({'body': "Quote here", 'tags': [], 'link': build_link('/quotes', 'pyqdb/quote/new', Quote.json_mimetype, method='post', title='Create a new quote')}, Quote.json_mimetype)
        add_link_hdr(rs, '/quotes', 'pyqdb/quote/new')
        return rs
    return render_template('submit.html', nav=navs)