Exemple #1
0
def read_more():
    form = cgi.FieldStorage()
    typ = form.getfirst('type')
    if not typ:
        return
    id = form.getfirst('id')
    if not id:
        return

    json = {'lastid':None,'html':''}
    if typ == 'odai':
        for row in dbsubr.list_odai(id):
            json['html'] += format_odai(row)
            json['lastid'] = row['odai_id']
        print 'Content-Type: application/json;charset=utf-8'
        print
        simplejson.dump(json, sys.stdout)
    elif typ == 'comment':
        odai_id = dbsubr.get_odai_id_by_come(id)
        for row in dbsubr.list_come(odai_id, id):
            json['html'] += format_come(row)
            json['lastid'] = row['come_id']
        print 'Content-Type: application/json;charset=utf-8'
        print
        simplejson.dump(json, sys.stdout)
Exemple #2
0
def list_html():
    form = cgi.FieldStorage()

    print 'Content-Type: text/html;charset=utf-8'
    print

    print LIST_HTML_HEADER

    className = 'first'
    lastid = None
    print '<ul id="list" class="list">'
    for row in dbsubr.list_odai():
        print format_odai(row, className)
        if className:
            className = None
        lastid = row['odai_id']
    print '</ul>'

    print READMORE

    print '<script type="text/javascript">'
    print '$(function() {'
    if lastid:
        print 'lastid = %s;' % lastid
    minid = dbsubr.get_min_odai_id()
    if minid:
        print 'minid = %s;' % minid
    print 'init_odai();'
    print '});'
    print '</script>'

    print LIST_HTML_FOOTER