Commit c6d359e0d93c019dc8a6c40499d2a570ef951858
- Diff rendering mode:
- inline
- side by side
fetch.py
(36 / 12)
  | |||
10 | 10 | import lxml.html | |
11 | 11 | import urllib2 | |
12 | 12 | import StringIO | |
13 | import json | ||
13 | 14 | ||
14 | 15 | app = Flask(__name__) | |
15 | 16 | ||
… | … | ||
47 | 47 | c = pymongo.Connection() | |
48 | 48 | db = c['mural'] | |
49 | 49 | coll = db['data'] | |
50 | try: | ||
51 | for i in d: | ||
52 | coll.insert(request.args['data']) | ||
53 | response = make_response() | ||
54 | response.status = '200 OK' | ||
55 | response.status_code = 200 | ||
56 | return response | ||
57 | except: | ||
58 | response = make_response() | ||
59 | response.status = "500" | ||
60 | response.data = "Your post could not be saved. Try posting again." | ||
61 | return response | ||
50 | for i in request.form['data']: | ||
51 | coll.insert(i) | ||
52 | response = make_response() | ||
53 | response.status = "200 OK" | ||
54 | return response | ||
62 | 55 | ||
56 | @app.route('/web', methods=['GET']) | ||
57 | def web(): | ||
58 | return render_template('web.html') | ||
63 | 59 | ||
64 | 60 | @app.route('/SWeeText', methods=['GET']) | |
65 | 61 | def SWeeText(): | |
… | … | ||
74 | 74 | # inject the JS toolbar to annotate text | |
75 | 75 | script = root.makeelement('script') | |
76 | 76 | script.set('src', 'static/text-annotation.js') | |
77 | tree = root.makeelement('script') | ||
78 | tree.set('src', 'static/tree.js') | ||
79 | bs_js = root.makeelement('script') | ||
80 | bs_js.set('src', 'static/bootstrap.js') | ||
81 | jq = root.makeelement('script') | ||
82 | jq.set('src', 'static/jquery-1.9.1.min.js') | ||
83 | jit = root.makeelement('script') | ||
84 | jit.set('src', 'static/jit.js') | ||
85 | us = root.makeelement('script') | ||
86 | us.set('src', 'static/underscore-min-1.4.4.js') | ||
87 | |||
77 | 88 | link = root.makeelement('link') | |
78 | 89 | link.set('href', 'static/text-annotation.css') | |
79 | 90 | link.set('type', 'text/css') | |
80 | 91 | link.set('rel', 'stylesheet') | |
92 | bs = root.makeelement('link') | ||
93 | bs.set('href', 'static/bootstrap.css') | ||
94 | bs.set('type', 'text/css') | ||
95 | bs.set('rel', 'stylesheet') | ||
96 | tree_css = root.makeelement('link') | ||
97 | tree_css.set('href', 'static/tree.css') | ||
98 | tree_css.set('type', 'text/css') | ||
99 | tree_css.set('rel', 'stylesheet') | ||
81 | 100 | ||
101 | root.body.append(jq) | ||
102 | root.body.append(bs_js) | ||
103 | root.body.append(jit) | ||
104 | root.body.append(us) | ||
105 | root.body.append(tree) | ||
82 | 106 | root.body.append(script) | |
107 | |||
108 | root.head.append(bs) | ||
83 | 109 | root.head.append(link) | |
110 | root.head.append(tree_css) | ||
84 | 111 | ||
85 | 112 | return lxml.html.tostring(root) | |
86 | 113 |
static/tree.js
(50 / 9)
  | |||
111 | 111 | event.stopPropagation(); | |
112 | 112 | } | |
113 | 113 | //Log.write('centering node ', node.name); | |
114 | console.log('centering node', node.name); | ||
114 | 115 | RGraph.onClick(node.id, { | |
115 | 116 | hideLabels: false, | |
116 | 117 | onComplete: function() { | |
… | … | ||
151 | 151 | user: user, | |
152 | 152 | type: this.type, | |
153 | 153 | uri: resource, | |
154 | top: attribs.top, | ||
155 | bottom: attribs.bottom, | ||
156 | left: attribs.left, | ||
157 | right: attribs.right, | ||
158 | 154 | nodes: this.nodes, | |
159 | 155 | }; | |
156 | if(attribs.hasOwnProperty('top') && | ||
157 | attribs.hasOwnProperty('bottom') && | ||
158 | attribs.hasOwnProperty('right') && | ||
159 | attribs.hasOwnProperty('left')) { | ||
160 | data.top = attribs.top; | ||
161 | data.bottom = attribs.bottom; | ||
162 | data.left = attribs.left; | ||
163 | data.right = attribs.right; | ||
164 | } | ||
165 | if(attribs.hasOwnProperty('xpath')) { | ||
166 | data.xpath = attribs.xpath; | ||
167 | } | ||
160 | 168 | this.swts.push(data); | |
161 | 169 | this.nodes = []; | |
162 | 170 | }, | |
… | … | ||
173 | 173 | return; | |
174 | 174 | } | |
175 | 175 | $('#publish').attr('disabled', 'disabled'); | |
176 | //$('#posted').show(); | ||
177 | var swts = ''; | ||
178 | for(var i in this.swts) { | ||
179 | var data = this.swts[i]; | ||
180 | var swt = '@'+data.user+' '+data.type+' '+data.uri; | ||
181 | if(data.hasOwnProperty('xpath')) { | ||
182 | swt += ' xpath: '+data.xpath; | ||
183 | } | ||
184 | if(data.hasOwnProperty('top')) { | ||
185 | swt += ' #['+data.top+','+data.right+','+data.bottom+','+data.left+']'; | ||
186 | } | ||
187 | swt += ' ' + data.nodes; | ||
188 | swts += swt + '\n'; | ||
189 | } | ||
190 | $('#sweet').html(swts); | ||
191 | $('#sweeted').show(); | ||
176 | 192 | $.ajax({ | |
177 | 193 | type: 'POST', | |
178 | 194 | url: config.indexer + '/submit', | |
179 | data: {'data': JSON.stringify(this.swts)}, | ||
195 | data: {'data': this.swts}, | ||
180 | 196 | success: function() { | |
181 | $.ajax({ | ||
197 | /*$.ajax({ | ||
182 | 198 | type: 'POST', | |
183 | 199 | url: config.postTweetUrl, | |
184 | 200 | data: {'data': JSON.stringify(this.swts)}, | |
… | … | ||
205 | 205 | error: function() { | |
206 | 206 | $('#fail-posting').show(); | |
207 | 207 | } | |
208 | }); | ||
208 | });*/ | ||
209 | $('#posted').show(); | ||
210 | var swts = ''; | ||
211 | for(var i in this.swts) { | ||
212 | var data = this.swts[i]; | ||
213 | var swt = '@'+data.user+' '+data.type+' '+data.uri; | ||
214 | if(data.hasOwnProperty('xpath')) { | ||
215 | swt += ' xpath: '+data.xpath; | ||
216 | } | ||
217 | if(data.hasOwnProperty('top')) { | ||
218 | swt += ' #['+data.top+','+data.right+','+data.bottom+','+data.left+']'; | ||
219 | } | ||
220 | swt += ' ' + data.nodes; | ||
221 | swts += swt + '\n'; | ||
222 | } | ||
223 | $('#sweet').html(swts); | ||
224 | this.swts = []; | ||
209 | 225 | }, | |
210 | 226 | error: function() { | |
211 | $('#fail-posting').show(); | ||
227 | //$('#fail-posting').show(); | ||
212 | 228 | } | |
213 | 229 | }); | |
214 | 230 | } | |
… | … | ||
266 | 266 | size: 14 | |
267 | 267 | }, | |
268 | 268 | interpolation: 'polar', | |
269 | transition: $jit.Trans.Sine.easeInOut, | ||
269 | transition: $jit.Trans.Sine.easeIn, | ||
270 | 270 | levelDistance: 150, | |
271 | 271 | onCreateLabel: function(domElement, node) { | |
272 | 272 | console.log('oncreatelabel'); |
templates/index.html
(1 / 0)
  | |||
70 | 70 | <!-- PLEASE, LET THIS NOTE ABOUT AUTHOR AND PROJECT SOMEWHERE ON YOUR WEBSITE, OR AT LEAST IN THE COMMENT IN HTML. THANK YOU --> | |
71 | 71 | </div> | |
72 | 72 | ||
73 | </div> | ||
73 | 74 | </div> | |
74 | 75 | ||
75 | 76 | <script type="text/javascript" >resize();</script> |