Commit 10b11592ab7fa534355c937aef89087b042d9c90
- Diff rendering mode:
- inline
- side by side
server.py
(1 / 2)
  | |||
90 | 90 | del(i['_id']) | |
91 | 91 | ret[y] = i | |
92 | 92 | y = y + 1 | |
93 | |||
94 | return render_template('blank.html', content = ret) | ||
93 | return render_template('blank.html', content = ret, flag = request.args['flag']) | ||
95 | 94 | ||
96 | 95 | ||
97 | 96 | @app.route('/submit', methods=['POST']) |
static/config.js.sample
(3 / 0)
  | |||
1 | var config = { | ||
2 | 'indexer':'http://127.0.0.1:5000' | ||
3 | } |
static/myVector.js
(44 / 23)
  | |||
62 | 62 | { | |
63 | 63 | for(var i in ans.ans) | |
64 | 64 | { | |
65 | if(feature.geometry.bounds['left'] == ans.ans[i]['left'] && feature.geometry.bounds['right'] == ans.ans[i]['right'] && feature.geometry.bounds['top'] == ans.ans[i]['top'] && feature.geometry.bounds['bottom'] == ans.ans[i]['bottom']) | ||
66 | { | ||
65 | // if(feature.geometry.bounds['left'] == ans.ans[i]['left'] && feature.geometry.bounds['right'] == ans.ans[i]['right'] && feature.geometry.bounds['top'] == ans.ans[i]['top'] && feature.geometry.bounds['bottom'] == ans.ans[i]['bottom']) | ||
66 | // { | ||
67 | 67 | str = {}; | |
68 | 68 | if(ans.ans[i]['character']) | |
69 | 69 | str['character'] = ans.ans[i]['character']; | |
… | … | ||
72 | 72 | str['material'] = ans.ans[i]['material']; | |
73 | 73 | // str['jewellery'] = ans.ans[i]['jewellery'] | |
74 | 74 | } | |
75 | |||
75 | if(ans.ans[i]["how"]) | ||
76 | { | ||
76 | 77 | z = new OpenLayers.Popup.FramedCloud( | |
77 | 78 | "test", | |
78 | 79 | feature.geometry.getBounds().getCenterLonLat(), | |
79 | 80 | new OpenLayers.Size(640,480), | |
80 | '<iframe src='+config.indexer+"/search?data="+JSON.stringify({'nodes': ans.ans[i]["nodes"]})+" ></iframe>",null,true); | ||
81 | '<iframe src='+config.indexer+"/search?flag=0&data="+JSON.stringify({'nodes': ans.ans[i]["how"]})+" ></iframe>",null,true); | ||
82 | } | ||
83 | else | ||
84 | { | ||
85 | z = new OpenLayers.Popup.FramedCloud( | ||
86 | "test", | ||
87 | feature.geometry.getBounds().getCenterLonLat(), | ||
88 | new OpenLayers.Size(640,480), | ||
89 | '<iframe src='+config.indexer+"/search?flag=0&data="+JSON.stringify({'nodes': ans.ans[i]["nodes"]})+" ></iframe>",null,true); | ||
90 | |||
91 | } | ||
92 | |||
81 | 93 | feature.popup = z; | |
82 | 94 | z.panMapIfOutOfView = true; | |
83 | 95 | map.addPopup(z); | |
84 | 96 | break; | |
85 | } | ||
86 | else{ | ||
87 | if(i == ans.count-1) | ||
88 | { | ||
89 | z = new OpenLayers.Popup.FramedCloud( | ||
90 | "test", | ||
91 | feature.geometry.getBounds().getCenterLonLat(), | ||
92 | new OpenLayers.Size(640,480), | ||
93 | '<iframe width="480" height="360" src="http://www.youtube.com/embed/WwNUnmZ_aww" frameborder="0" allowfullscreen></iframe>',null,true); | ||
94 | feature.popup = z; | ||
95 | z.panMapIfOutOfView = true; | ||
96 | map.addPopup(z); | ||
97 | } | ||
98 | } | ||
97 | //} | ||
98 | //else{ | ||
99 | // if(i == ans.count-1) | ||
100 | // { | ||
101 | // z = new OpenLayers.Popup.FramedCloud( | ||
102 | // "test", | ||
103 | // feature.geometry.getBounds().getCenterLonLat(), | ||
104 | // new OpenLayers.Size(640,480), | ||
105 | // '<iframe width="480" height="360" src="http://www.youtube.com/embed/WwNUnmZ_aww" frameborder="0" allowfullscreen></iframe>',null,true); | ||
106 | // feature.popup = z; | ||
107 | // z.panMapIfOutOfView = true; | ||
108 | // map.addPopup(z); | ||
109 | // } | ||
110 | //} | ||
99 | 111 | } | |
100 | 112 | ||
101 | 113 | } | |
… | … | ||
196 | 196 | $.get(config.indexer+"/fetch",{uri:"default"} , function(data){ | |
197 | 197 | if (data != undefined) | |
198 | 198 | { | |
199 | console.log(data); | ||
199 | 200 | ans.ans = data; | |
200 | 201 | for(var i in ans.ans) | |
201 | 202 | { | |
… | … | ||
329 | 329 | } | |
330 | 330 | function makeBoxes(x) | |
331 | 331 | { | |
332 | |||
332 | if(x.left) | ||
333 | { | ||
333 | 334 | bounds = new OpenLayers.Bounds(x['left'], x['bottom'], x['right'], x['top']); | |
334 | 335 | box = new OpenLayers.Feature.Vector(bounds.toGeometry()); | |
335 | 336 | box3.addFeatures(box); | |
336 | 337 | addLabel(x['left'],x['top'],x['name']); | |
338 | } | ||
339 | else if(x.where) | ||
340 | { | ||
341 | position = JSON.parse(x.where.split("#")[1]); | ||
342 | console.log(position); | ||
343 | bounds = new OpenLayers.Bounds(position[2], position[1], position[3], position[0]); | ||
344 | box = new OpenLayers.Feature.Vector(bounds.toGeometry()); | ||
345 | box3.addFeatures(box); | ||
346 | addLabel(position[2],position[0],x['name']); | ||
347 | |||
348 | } | ||
337 | 349 | } | |
338 | 350 | // function onmouse(data){ | |
339 | 351 | // console.log(data); | |
… | … | ||
496 | 496 | myJSON = []; | |
497 | 497 | }); | |
498 | 498 | }); | |
499 | } | ||
500 | var config = { | ||
501 | 'postTweetUrl':'http://demo.swtr.us/add', | ||
502 | 'indexer':'http://folkhampi.openrun.net/mural-annotation' | ||
503 | 499 | } |
static/text-annotation.css
(4 / 0)
  | |||
18 | 18 | width: 500px; | |
19 | 19 | margin: -250px 0 0 28%; | |
20 | 20 | } | |
21 | .highlight{ | ||
22 | background-color: rgba(255, 212, 0, 0.6); | ||
23 | |||
24 | } |
static/text-annotation.js
(17 / 2)
  | |||
14 | 14 | modal.id = 'modal-wrap'; | |
15 | 15 | document.body.appendChild(modal); | |
16 | 16 | modal.innerHTML = modal_template(); | |
17 | $('#publish').click(function() { | ||
17 | $("#list-anno").on("hidden", function(){ | ||
18 | $(".well a").off("click"); | ||
19 | $(".highlight").removeClass("highlight"); | ||
20 | |||
21 | }) | ||
22 | $('#publish').click(function() { | ||
18 | 23 | sweet.publish(); | |
19 | 24 | }); | |
20 | 25 | }; | |
… | … | ||
42 | 42 | }; | |
43 | 43 | window.listAnno = function() { // list annotations of current page | |
44 | 44 | console.log('listing annotations'); | |
45 | $.get(config.indexer + '/search?data=' + | ||
45 | |||
46 | $.get(config.indexer + '/search?flag=1&data=' + | ||
46 | 47 | JSON.stringify({'where': window.location.search.split('url=')[1]}), | |
47 | 48 | function(data) { | |
48 | 49 | //console.log(data); | |
… | … | ||
51 | 51 | $('#list-anno').modal({ | |
52 | 52 | backdrop: false, | |
53 | 53 | }); | |
54 | $('.well a').click(function(event){ | ||
55 | xpath = $(event.currentTarget).text().split('#')[1]; | ||
56 | var nodes = document.evaluate(xpath, document, null, XPathResult.ANY_TYPE,null); | ||
57 | result = nodes.iterateNext(); | ||
58 | while(result){ | ||
59 | $(result).addClass("highlight"); | ||
60 | result = nodes.iterateNext(); | ||
61 | } | ||
62 | }); | ||
54 | 63 | }); | |
55 | 64 | }; | |
56 | 65 |
templates/blank.html
(20 / 2)
  | |||
1 | <!doctype html> | ||
2 | <body> | ||
3 | {% if flag == '1' %} | ||
1 | 4 | {% for obj in content %} | |
2 | 5 | <div class="well"> | |
3 | {% for key in content[obj].keys() %} | ||
4 | <p><b>{{ key }}</b>: {{ content[obj][key] }}</p> | ||
6 | {% for key in content[obj].keys() %} | ||
7 | {% if key == "where" or key == "xpath" %} | ||
8 | <p><b>{{ key }}</b>:<a href="#"> {{ content[obj][key] }}</a></p> | ||
9 | {% else %} | ||
10 | <p><b>{{ key }}</b>: {{ content[obj][key] }}</p> | ||
11 | {% endif %} | ||
12 | {% endfor %} | ||
13 | </div> | ||
5 | 14 | {% endfor %} | |
15 | {% else %} | ||
16 | {% for obj in content %} | ||
17 | <div class="well"> | ||
18 | {% for key in content[obj].keys() %} | ||
19 | <p><b>{{ key }}</b>: {{ content[obj][key] }}</p> | ||
20 | {% endfor %} | ||
6 | 21 | </div> | |
7 | 22 | {% endfor %} | |
23 | {% endif %} | ||
24 | </body> | ||
25 | </html> |
templates/index.html
(1 / 0)
  | |||
14 | 14 | <script type="text/javascript" src="static/tree.js"></script> | |
15 | 15 | <script type="text/javascript" src="static/myVector.js"></script> | |
16 | 16 | <script type="text/javascript" src="static/bootstrap.js"></script> | |
17 | <script type="text/javascript" src="{{ url_for('static',filename='config.js') }}"></script> | ||
17 | 18 | </head> | |
18 | 19 | {% if url %} | |
19 | 20 | <body onload='init({{ url|string|safe }});'> |