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)
def detail_html(): odai_id = os.getenv('PATH_INFO').strip('/') row = dbsubr.get_odai(odai_id) print 'Content-Type: text/html;charset=utf-8' print print DETAIL_HTML_HEADER % row['odai_text'].encode('utf8') print '<h2>没企画概要</h2>' print '<ul class="list">' print format_odai(row, 'first', 'border:solid 1px #cccccc; padding:1ex', False) print '</ul>' print '<p>「この企画は物足りない」<br />' print '「こうすれば実現するんじゃないの?」<br />' print 'などなど、この企画に対してのご意見がございましたら、ぜひコメントしていってください。</p>' print '<form method="post" action="#" onsubmit="post_comment(this); return false" id="post_form">' print '<p><textarea cols="60" rows="5" name="m"></textarea></p>' print '<p>あなたのお名前(任意)' print '<input type="hidden" name="id" value="%s" />' % odai_id print '<input type="text" name="n" />' print '<input class="button" type="submit" value="投稿する" /></p>' print '</form>' className = 'first' lastid = None print '<ul id="list" class="list">' for row in dbsubr.list_come(odai_id): print format_come(row, className) if className: className = None lastid = row['come_id'] print '</ul>' print READMORE print '<script type="text/javascript">' print '$(function() {' if lastid: print 'lastid = %s;' % lastid minid = dbsubr.get_min_come_id(odai_id) if minid: print 'minid = %s;' % minid print 'init_comment();' print '});' print '</script>' print LIST_HTML_FOOTER