Commit 031803b2a1571ad7c6612ce7837b174f111354c4
- Diff rendering mode:
- inline
- side by side
server.py
(10 / 3)
  | |||
34 | 34 | resource = "default" | |
35 | 35 | if request.args.has_key('uri'): | |
36 | 36 | resource = request.args['uri'] | |
37 | for i in collection.find({'resource':resource}): | ||
37 | for i in collection.find({'uri':resource}): | ||
38 | 38 | del(i['_id']) | |
39 | 39 | ret[x] = i | |
40 | 40 | x = x + 1 | |
41 | else: | ||
42 | for i in collection.find(): | ||
43 | del(i['_id']) | ||
44 | ret[x] = i | ||
45 | x = x + 1 | ||
41 | 46 | if len(ret) == 0: | |
42 | 47 | ret['error'] = "Sorry! No re-treats for you." | |
43 | 48 | return jsonify(ret) | |
44 | 49 | ||
50 | @app.route('/sweets', methods=['GET']) | ||
51 | def displaySweet(): | ||
52 | return render_template('sweets.html') | ||
45 | 53 | ||
46 | 54 | @app.route('/search', methods=['GET']) | |
47 | 55 | def search(): | |
… | … | ||
65 | 65 | try: | |
66 | 66 | if keyword in i['nodes']: | |
67 | 67 | del(i['_id']) | |
68 | i['text'] = urllib.unquote_plus(i['text']) | ||
69 | 68 | ret[y] = i | |
70 | 69 | y = y + 1 | |
71 | 70 | except: | |
… | … | ||
126 | 126 | ||
127 | 127 | bs_js = root.makeelement('script') | |
128 | 128 | bs_js.set('src', 'static/bootstrap.js') | |
129 | |||
129 | |||
130 | 130 | jit = root.makeelement('script') | |
131 | 131 | jit.set('src', 'static/jit.js') | |
132 | 132 |
static/tree.js
(8 / 7)
  | |||
4 | 4 | iStuff = ua.match(/iPhone/i) || ua.match(/iPad/i), | |
5 | 5 | typeOfCanvas = typeof HTMLCanvasElement, | |
6 | 6 | nativeCanvasSupport = (typeOfCanvas == 'object' || typeOfCanvas == 'function'), | |
7 | textSupport = nativeCanvasSupport | ||
7 | textSupport = nativeCanvasSupport | ||
8 | 8 | && (typeof document.createElement('canvas').getContext('2d').fillText == 'function'); | |
9 | 9 | //I'm setting this based on the fact that ExCanvas provides text support for IE | |
10 | 10 | //and that as of today iPhone/iPad current text support is lame | |
… | … | ||
121 | 121 | } | |
122 | 122 | //Log.write('centering node ', node.name); | |
123 | 123 | console.log('centering node', node.name); | |
124 | RGraph.onClick(node.id, { | ||
125 | hideLabels: false, | ||
126 | onComplete: function() { | ||
127 | //Log.write("done"); | ||
124 | RGraph.onClick(node.id, { | ||
125 | hideLabels: false, | ||
126 | onComplete: function() { | ||
127 | //Log.write("done"); | ||
128 | 128 | } | |
129 | }); | ||
129 | }); | ||
130 | 130 | var html = '<h4>' + node.name + '</h4><b>Links To:</b>:<ul>'; | |
131 | 131 | node.eachAdjacency(function(adj) { | |
132 | 132 | html += '<li><a class="list-nodes" href="#" id="list-' + adj.nodeTo.id + '">' + | |
… | … | ||
159 | 159 | }, | |
160 | 160 | save: function() { | |
161 | 161 | var resource = window.location.search ? window.location.search.split('=')[1] : | |
162 | 'default'; | ||
162 | window.location.href; | ||
163 | 163 | resource = decodeURIComponent(resource).replace('"', '', 'gi'); | |
164 | 164 | var data = { | |
165 | 165 | user: user, | |
166 | 166 | type: this.type, | |
167 | 167 | uri: resource, | |
168 | 168 | nodes: this.nodes, | |
169 | name: attribs.name | ||
169 | 170 | }; | |
170 | 171 | if(attribs.hasOwnProperty('top') && | |
171 | 172 | attribs.hasOwnProperty('bottom') && |
templates/sweets.html
(41 / 0)
  | |||
1 | <!DOCTYPE html> | ||
2 | <html> | ||
3 | <head> | ||
4 | <meta charset="utf-8"> | ||
5 | <meta http-equiv='imagetoolbar' content='no'/> | ||
6 | <title> Web Annotation </title> | ||
7 | <link rel="stylesheet" type="text/css" href="static/bootstrap.css"></link> | ||
8 | <script type="text/javascript" src="static/jquery-1.9.1.min.js"></script> | ||
9 | <script type="text/javascript" src="static/bootstrap.js"></script> | ||
10 | <style type="text/css"> | ||
11 | .container { | ||
12 | margin-top: 30px; | ||
13 | } | ||
14 | .box{ | ||
15 | border: 1px solid black; | ||
16 | padding: 10px; | ||
17 | margin: 10px; | ||
18 | } | ||
19 | </style> | ||
20 | </head> | ||
21 | <body> | ||
22 | <div class="container"></div> | ||
23 | <script> | ||
24 | window.onload = function(){ | ||
25 | |||
26 | $.get('{{ url_for('fetch') }}', function(data){ | ||
27 | var html = ''; | ||
28 | for(var i in data){ | ||
29 | html += "<div class='box'><ul>"; | ||
30 | for(var j in data[i]){ | ||
31 | html += "<li>"+j+" : "+data[i][j]+"</li>"; | ||
32 | } | ||
33 | html+= "</ul></div>"; | ||
34 | } | ||
35 | $(".container").html(html); | ||
36 | }); | ||
37 | } | ||
38 | </script> | ||
39 | |||
40 | </body> | ||
41 | </html> |