def template_answered_matrix(p, matrix_id, f, answer, guessed): with p(html.html()): with p(html.head()): p(html.title('Answered a matrix')) with p(html.body()): if answer == guessed: p(html.h1('Correct!')) else: p(html.h1('Sorry, wrong answer :(')) p(html.h2('You guessed: ')) p(html.p(html.img(figure_image.url(guessed)))) p(html.p(html.a(ask_matrix.url(matrix_id), 'Back to this matrix'))) p(html.p(html.a(generate_random_matrix.url(), 'or Generate a new matrix'))) p(html.p(html.img(matrix_guess.url(matrix_id))))
def profile(req, p, remaining): users_db = req.settings[u'users_db'] updates_db = req.settings[u'updates_db'] session = req.environ['beaker.session'] session[u'counter'] = session.get('counter', 0) + 1 session.save() user = session[u'user'] if u'user' in session else None user_profiles = profiles_of_user(users_db, user) p(html.br()) name, id, _ = remaining.split(u'/', 2) updates = updates_db.view('_design/updates/_view/updates_by_profile', startkey=[id], endkey=[id, {}], include_docs=True) p(html.h1(name.replace('_', ' '))) if user is not None: p(u'<form action="%s" method="POST">' % '/say') p(u'%s ' % name.replace('_', ' ')) p(u'<input type="hidden" name="profile" value="%s" />' % id) p(u'<input type="text" name="message" value="is "') if id in user_profiles: p(u'disabled="true"') p(u'/>') p(u'<input type="submit" value="Say"') if id in user_profiles: p(u'disabled="true"') p(u' />') p(u'</form>') if id in user_profiles: p(u'<p style="font-size:smaller"><em>This is your profile</em>. You may not edit your profile.</p>') p(html.br()) p(html.br()) updates = list(updates) updates.reverse() for u in updates: p(u[u'value']) p(u' <b style="font-size:x-small;">') p(webify.templates.helpers.time.fuzzy_time_diff(datetime.datetime.fromtimestamp(u.doc['date']))) p(u' ago') p(u' <a href="/" style="font-size:xx-small">(by Joseph)</a>') p(u'</b>') p(html.br()) friends = users_db.view('_design/users/_view/friends', startkey=[id], endkey=[id, {}], include_docs=True) p(html.h2(u'Friends:')) with html.ul(p): for f in friends: if f[u'key'][1] == 1: url = profile.url(f.doc[u'name'].replace(' ', '_')+u'/'+f.doc.id+u'/') p(html.li(html.a(url, f.doc[u'name']))) p(u'Pageviews: %s' % session['counter']) p(html.br())
def template_originals(t, ticker, url, page): with t(html.div()): t(html.h1('Originals SEC Financials in 10K for %s' % ticker)) t(u'Downloaded today from %s' % html.a(url, url)) t(html.hr()) t(unicode(page))