Beispiel #1
0
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())
Beispiel #2
0
def index(req, p):
    users_db = req.settings[u'users_db']
    p(u'Frishy.  Squish your friends!')
    p(html.br())
    p(html.a('/signin', 'sign in'))
    profiles = users_db.view('_design/users/_view/user_profiles', 
                             limit=10, include_docs=True)
    p(html.h2('Profiles:'))
    with html.ul(p):
        for p in profiles:
            url = profile.url(p.doc[u'name'].replace(' ', '_')+u'/'+p.doc.id+u'/')
            p(html.li(html.a(url, p.doc[u'name'])))
Beispiel #3
0
def partial_list(p, things):
    with p(html.ol()):
        for t in things:
            p(html.li(t))
Beispiel #4
0
def template_list_puzzle(p, ids):
    with p(html.ol()):
        for id in ids:
            p(html.li(html.a(ask_matrix.url(id), id)))
Beispiel #5
0
def template_index(p, files):
    with p(html.ul()):
        for file in files:
            p(html.li(html.a(view_csv.url(file), file)))