Commit 5c78a2713049e5ce4c91c691972f635d2ae5d78b

  • avatar
  • arvind
  • Sun Jun 17 16:18:28 IST 2012
Adding python files and now tags are displayed with the content
fetch.py
(19 / 0)
  
1import json
2import pymongo
3#from bson.code import *
4#from urllib import unquote_plus
5def application(environ, start_response):
6 status = '200 OK'
7 response_headers = [('Content-type', 'application/json'),('Access-Control-Allow-Origin', '*')]
8 start_response(status, response_headers)
9 c = pymongo.Connection()
10 db = c['mural']
11 coll = db['data']
12 ret = {}
13 x = 0
14 for i in coll.find():
15 del(i['_id'])
16 ret[x] = i
17 x = x + 1
18 #return repr(recieved)
19 return json.dumps(ret)
myVector.js
(50 / 12)
  
1212];
1313var myJSON = [];
1414var ans = {
15 ans: []
15 ans: [],
16 count: 0
17
1618};
1719// avoid pink tiles
1820OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
5959};
6060function onFeatureSelect(feature)
6161{
62 for(var i in ans.ans)
63 {
64 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'])
65 {
66 str = {};
67 if(ans.ans[i]['character'])
68 str['character'] = ans.ans[i]['character'];
69 else
70 {
71 str['material'] = ans.ans[i]['material'];
72 // str['jewellery'] = ans.ans[i]['jewellery']
73 }
74 z = new OpenLayers.Popup.FramedCloud(
75 "test",
76 feature.geometry.getBounds().getCenterLonLat(),
77 new OpenLayers.Size(640,480),
78 JSON.stringify(str,null,' '),null,true);
79 feature.popup = z;
80 z.panMapIfOutOfView = true;
81 map.addPopup(z);
82 break;
83 }
84 else{
85 if(i == ans.count-1)
86 {
87 z = new OpenLayers.Popup.FramedCloud(
88 "test",
89 feature.geometry.getBounds().getCenterLonLat(),
90 new OpenLayers.Size(640,480),
91 '<iframe width="480" height="360" src="http://www.youtube.com/embed/WwNUnmZ_aww" frameborder="0" allowfullscreen></iframe>',null,true);
92 feature.popup = z;
93 z.panMapIfOutOfView = true;
94 map.addPopup(z);
95 }
96 }
97 }
98
99}
100function onFeatureSelect1(feature)
101{
62102 z = new OpenLayers.Popup.FramedCloud(
63103 "test",
64104 feature.geometry.getBounds().getCenterLonLat(),
114114 "test",
115115 new OpenLayers.LonLat(x, y), // Always should be at the center of the map, not the center of viewport.
116116 new OpenLayers.Size(640,480),
117 "<pre>"+JSON.stringify(json,null,'\t')+"</pre>"
117 "<pre>"+JSON.stringify(json,null,' ')+"</pre>"
118118 ,null,true);
119119 feature.popup = z;
120120 z.panMapIfOutOfView = true;
134134 ans.ans = JSON.parse(data);
135135 for(var i in ans.ans)
136136 {
137 ans.count+=1;
137138 makeBoxes(ans.ans[i]);
138139 }
139140
242242 function makeBoxes(x)
243243{
244244
245 box4 = new OpenLayers.Layer.Vector( "Tags");
246245 bounds = new OpenLayers.Bounds(x['left'], x['bottom'], x['right'], x['top']);
247246 box = new OpenLayers.Feature.Vector(bounds.toGeometry());
248 box4.addFeatures(box);
249 map.addLayer(box4);
247 box3.addFeatures(box);
250248 addLabel(x['left'],x['top'],x['name']);
251249 }
252function onmouse(data){
253 console.log(data);
254}
250// function onmouse(data){
251// console.log(data);
252// }
255253function myfeatureadded(myObj)
256254{
257255 var renderer = OpenLayers.Util.getParameters(window.location.href).renderer;
288288 favColor: 'blue',
289289 };
290290 labelFeature.attributes['name'] = prompt("Enter a name");
291 console.log(labelFeature.attributes['name']);
292291 if(labelFeature.attributes['name'])
293292 {
294 console.log(myObj.feature.geometry.bounds.top); //Use this to get the bounds.
295293 topValue = myObj.feature.geometry.bounds.top;
296294 bottom = myObj.feature.geometry.bounds.bottom;
297295 left = myObj.feature.geometry.bounds.left;
369369onresize=function(){ resize();};
370370function publish()
371371{
372 console.log(myJSON);
373372 $.post("http://192.168.100.56:82/submit", JSON.stringify(myJSON), function(data)
374373 {
375 alert(data);
374 alert("Posted");
376375 }
377376 );
378377}
  
4242 attribs["character"] = $("#character-value").text();
4343 attribs["material"] = $("#material-value").text();
4444 myJSON.push(attribs);
45 $("#publish").attr("disbaled", false);
45 $("#publish").attr("disabled", false);
4646 }
4747 </script>
4848 </head>
submit.wsgi
(14 / 0)
  
1import json
2import pymongo
3def application(environ, start_response):
4 status = '200 OK'
5 response_headers = [('Content-type', 'text/html'),('Access-Control-Allow-Origin', '*')]
6 start_response(status, response_headers)
7 recieved = environ['wsgi.input'].read(int(environ['CONTENT_LENGTH']))
8 c = pymongo.Connection()
9 db = c['mural']
10 coll = db['data']
11 d = json.loads(recieved)
12 for i in d:
13 coll.insert(d)
14 return 'ok'