Mercurial > code > home > repos > href
annotate lookup.py @ 6:ce779bdd2fb3
links to peers
Ignore-this: 31f60d68f279b53eee2f38b1f570c6c9
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Fri, 01 Mar 2013 01:24:05 -0800 |
parents | f8c4c7ce5f4a |
children | 93d94f327e82 |
rev | line source |
---|---|
2
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
1 #!bin/python |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
2 """ |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
3 serve some queries over bookmarks: |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
4 |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
5 /user |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
6 /user/tag+tag+tag |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
7 |
5
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
8 and the add-bookmark stuff |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
9 |
2
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
10 """ |
5
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
11 import pymongo, bottle, time, urllib, datetime, json, restkit |
2
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
12 from urllib2 import urlparse |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
13 from dateutil.tz import tzlocal |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
14 from bottle import static_file |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
15 from jadestache import Renderer |
5
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
16 from pagetitle import PageTitle |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
17 from link import Links, NotFound |
2
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
18 db = pymongo.Connection('bang', tz_aware=True)['href'] |
5
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
19 pageTitle = PageTitle(db) |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
20 links = Links(db) |
2
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
21 renderer = Renderer(search_dirs=['template'], debug=bottle.DEBUG) |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
22 |
5
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
23 siteRoot = 'https://bigasterisk.com/href' |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
24 |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
25 def getLoginBar(): |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
26 openidProxy = restkit.Resource("http://bang:9023/") |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
27 return openidProxy.get("_loginBar", |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
28 headers={"Cookie" : bottle.request.headers.get('cookie')}).body_string() |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
29 |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
30 def getUser(): |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
31 agent = bottle.request.headers.get('x-foaf-agent', None) |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
32 username = db['user'].find_one({'_id':agent})['username'] if agent else None |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
33 return username, agent |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
34 |
2
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
35 @bottle.route('/static/<filename>') |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
36 def server_static(filename): |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
37 return static_file(filename, root='static') |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
38 |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
39 def recentTags(user, tags=None): |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
40 out = {'links':[]} |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
41 t1 = time.time() |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
42 spec = {'user':user} |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
43 if tags: |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
44 spec['extracted.tags'] = {'$all' : tags} |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
45 for doc in db['links'].find(spec, sort=[('t', -1)], limit=50): |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
46 del doc['_id'] |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
47 doc['t'] = doc['t'].astimezone(tzlocal()).isoformat() |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
48 if not doc['description'].strip(): |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
49 doc['displayDescription'] = doc['href'] |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
50 else: |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
51 doc['displayDescription'] = doc['description'] |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
52 |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
53 doc['tagWords'] = [{'word' : w} for w in doc['tag'].split(None)] |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
54 doc['domain'] = urlparse.urlparse(doc['href']).netloc |
5
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
55 doc['editLink'] = 'addLink?' + urllib.urlencode([('url', doc['href'])]) |
2
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
56 |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
57 out['links'].append(doc) |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
58 out['stats'] = {'queryTimeMs' : round((time.time() - t1) * 1000, 2)} |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
59 return out |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
60 |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
61 def renderWithTime(name, data): |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
62 t1 = time.time() |
4 | 63 rendered = renderer.render_name(name, data) |
2
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
64 dt = (time.time() - t1) * 1000 |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
65 rendered = rendered.replace('TEMPLATETIME', "%.02f ms" % dt) |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
66 return rendered |
4 | 67 |
68 @bottle.route('/addLink') | |
69 def addLink(): | |
5
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
70 out = { |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
71 'toRoot': '.', |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
72 'absRoot': siteRoot, |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
73 'user': getUser()[0], |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
74 'withKnockout': True, |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
75 'fillHrefJson': json.dumps(bottle.request.params.get('url', '')), |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
76 'loginBar': getLoginBar(), |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
77 } |
4 | 78 return renderWithTime('add.jade', out) |
79 | |
80 @bottle.route('/addOverlay') | |
81 def addOverlay(): | |
82 p = bottle.request.params | |
83 | |
84 return "" | |
85 | |
5
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
86 |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
87 @bottle.route('/addLink/proposedUri') |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
88 def proposedUri(): |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
89 uri = bottle.request.params.uri |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
90 user, _ = getUser() |
4 | 91 |
5
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
92 try: |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
93 prevDoc = links.find(uri) |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
94 except NotFound: |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
95 prevDoc = None |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
96 |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
97 return { |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
98 'description': prevDoc['description'] if prevDoc else pageTitle.pageTitle(uri), |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
99 'tag' : prevDoc['tag'] if prevDoc else '', |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
100 'extended' : prevDoc['extended'] if prevDoc else '', |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
101 'suggestedTags':['tag1', 'tag2'], |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
102 'existed':prevDoc is not None, |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
103 } |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
104 |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
105 if 0: |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
106 pass#proposal check existing links, get page title (stuff that in db), get tags from us and other serviecs. maybe the deferred ones ater |
4 | 107 |
2
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
108 |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
109 @bottle.route('/<user>/') |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
110 def userSlash(user): |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
111 bottle.redirect("/%s" % urllib.quote(user)) |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
112 |
4 | 113 @bottle.route('/<user>', method='GET') |
2
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
114 def userAll(user): |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
115 data = recentTags(user, tags=None) |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
116 |
5
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
117 data['loginBar'] = getLoginBar() |
2
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
118 data['desc'] = "%s's recent links" % user |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
119 data['toRoot'] = "." |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
120 data['stats']['template'] = 'TEMPLATETIME' |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
121 return renderWithTime('links.jade', data) |
4 | 122 |
123 @bottle.route('/<user>', method='POST') | |
124 def userAddLink(user): | |
125 p = bottle.request.params | |
5
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
126 if getUser()[0] != user: |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
127 raise ValueError("not logged in as %s" % user) |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
128 links.insertOrUpdate(dict( |
4 | 129 user=user, |
130 description=p.description, | |
131 extended=p.extended, | |
132 href=p.href, | |
133 #private=p.private, == checked, | |
134 #shared ?? | |
135 tag=p.tag, | |
136 t=datetime.datetime.now(tzlocal()), | |
5
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
137 )) |
4 | 138 |
5
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
139 bottle.redirect(siteRoot + '/' + user) |
2
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
140 |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
141 @bottle.route('/<user>/<tags>') |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
142 def userLinks(user, tags): |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
143 tags = tags.split('+') |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
144 data = recentTags(user, tags) |
5
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
145 data['loginBar'] = getLoginBar() |
2
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
146 data['desc'] = "%s's recent links tagged %s" % (user, tags) |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
147 data['toRoot'] = ".." |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
148 |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
149 data['pageTags'] = [{"word":t} for t in tags] |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
150 data['stats']['template'] = 'TEMPLATETIME' |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
151 return renderWithTime('links.jade', data) |
5
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
152 |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
153 @bottle.route('/') |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
154 def root(): |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
155 data = { |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
156 'loginBar': getLoginBar(), |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
157 'toRoot': ".", |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
158 'stats': {'template': 'TEMPLATETIME'}, |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
159 'users': [{'user':doc['username']} for doc in db['user'].find()], |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
160 } |
f8c4c7ce5f4a
lots of href additions: add/edit, nav fixes
Drew Perttula <drewp@bigasterisk.com>
parents:
4
diff
changeset
|
161 return renderWithTime('index.jade', data) |
2
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
162 |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
163 if __name__ == '__main__': |
80b11112c9e0
web app for query urls like /user and /user/tag+tag
Drew Perttula <drewp@bigasterisk.com>
parents:
diff
changeset
|
164 bottle.run(server='gunicorn', host='0.0.0.0', port=10002, workers=4) |