Commit 031803b2a1571ad7c6612ce7837b174f111354c4

  • avatar
  • arvind
  • Tue Apr 16 23:17:17 IST 2013
Hyd demo
  • Diff rendering mode:
  • inline
  • side by side

server.py

34 resource = "default"34 resource = "default"
35 if request.args.has_key('uri'):35 if request.args.has_key('uri'):
36 resource = request.args['uri']36 resource = request.args['uri']
37 for i in collection.find({'resource':resource}):
37 for i in collection.find({'uri':resource}):
38 del(i['_id'])38 del(i['_id'])
39 ret[x] = i39 ret[x] = i
40 x = x + 140 x = x + 1
41 else:
42 for i in collection.find():
43 del(i['_id'])
44 ret[x] = i
45 x = x + 1
41 if len(ret) == 0:46 if len(ret) == 0:
42 ret['error'] = "Sorry! No re-treats for you."47 ret['error'] = "Sorry! No re-treats for you."
43 return jsonify(ret)48 return jsonify(ret)
4449
50@app.route('/sweets', methods=['GET'])
51def displaySweet():
52 return render_template('sweets.html')
4553
46@app.route('/search', methods=['GET'])54@app.route('/search', methods=['GET'])
47def search():55def search():
65 try:65 try:
66 if keyword in i['nodes']:66 if keyword in i['nodes']:
67 del(i['_id'])67 del(i['_id'])
68 i['text'] = urllib.unquote_plus(i['text'])
69 ret[y] = i68 ret[y] = i
70 y = y + 169 y = y + 1
71 except:70 except:
126126
127 bs_js = root.makeelement('script')127 bs_js = root.makeelement('script')
128 bs_js.set('src', 'static/bootstrap.js')128 bs_js.set('src', 'static/bootstrap.js')
129
129
130 jit = root.makeelement('script')130 jit = root.makeelement('script')
131 jit.set('src', 'static/jit.js')131 jit.set('src', 'static/jit.js')
132132

static/tree.js

4 iStuff = ua.match(/iPhone/i) || ua.match(/iPad/i),4 iStuff = ua.match(/iPhone/i) || ua.match(/iPad/i),
5 typeOfCanvas = typeof HTMLCanvasElement,5 typeOfCanvas = typeof HTMLCanvasElement,
6 nativeCanvasSupport = (typeOfCanvas == 'object' || typeOfCanvas == 'function'),6 nativeCanvasSupport = (typeOfCanvas == 'object' || typeOfCanvas == 'function'),
7 textSupport = nativeCanvasSupport
7 textSupport = nativeCanvasSupport
8 && (typeof document.createElement('canvas').getContext('2d').fillText == 'function');8 && (typeof document.createElement('canvas').getContext('2d').fillText == 'function');
9 //I'm setting this based on the fact that ExCanvas provides text support for IE9 //I'm setting this based on the fact that ExCanvas provides text support for IE
10 //and that as of today iPhone/iPad current text support is lame10 //and that as of today iPhone/iPad current text support is lame
121 }121 }
122 //Log.write('centering node ', node.name);122 //Log.write('centering node ', node.name);
123 console.log('centering node', node.name);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 var html = '<h4>' + node.name + '</h4><b>Links To:</b>:<ul>';130 var html = '<h4>' + node.name + '</h4><b>Links To:</b>:<ul>';
131 node.eachAdjacency(function(adj) {131 node.eachAdjacency(function(adj) {
132 html += '<li><a class="list-nodes" href="#" id="list-' + adj.nodeTo.id + '">' +132 html += '<li><a class="list-nodes" href="#" id="list-' + adj.nodeTo.id + '">' +
159 },159 },
160 save: function() {160 save: function() {
161 var resource = window.location.search ? window.location.search.split('=')[1] :161 var resource = window.location.search ? window.location.search.split('=')[1] :
162 'default';
162 window.location.href;
163 resource = decodeURIComponent(resource).replace('"', '', 'gi');163 resource = decodeURIComponent(resource).replace('"', '', 'gi');
164 var data = {164 var data = {
165 user: user,165 user: user,
166 type: this.type,166 type: this.type,
167 uri: resource,167 uri: resource,
168 nodes: this.nodes,168 nodes: this.nodes,
169 name: attribs.name
169 };170 };
170 if(attribs.hasOwnProperty('top') &&171 if(attribs.hasOwnProperty('top') &&
171 attribs.hasOwnProperty('bottom') &&172 attribs.hasOwnProperty('bottom') &&

templates/sweets.html

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>