Commit 8109b619fa86e9c003f8e75554a636e0c1655580
- Diff rendering mode:
- inline
- side by side
alipi/alipi.py
(30 / 1)
  | |||
12 | 12 | from urllib import quote_plus | |
13 | 13 | from urllib import unquote_plus | |
14 | 14 | import conf | |
15 | import sweetmaker | ||
15 | 16 | import oursql | |
16 | 17 | import requests | |
17 | 18 | from flask import jsonify | |
… | … | ||
232 | 232 | response = jsonify(d) | |
233 | 233 | response.headers['Access-Control-Allow-Origin'] = '*' | |
234 | 234 | return response | |
235 | |||
235 | 236 | @app.route('/blank', methods=['GET']) | |
236 | 237 | def serve_blank(): | |
237 | 238 | return render_template('blank.html') | |
… | … | ||
357 | 357 | return response | |
358 | 358 | ||
359 | 359 | ||
360 | @app.route("/askSWeeT",methods=['POST']) | ||
360 | @app.route('/publish', methods=['POST']) | ||
361 | def publish(): | ||
362 | print "entered" | ||
363 | data = json.loads(request.form['data']) | ||
364 | collection = g.db['post'] | ||
365 | for i in data: | ||
366 | i['bxpath'] = '' | ||
367 | collection.insert(i) | ||
368 | sweet(data) | ||
369 | reply = make_response() | ||
370 | return reply | ||
371 | |||
372 | |||
373 | def sweet(data): | ||
374 | """ A function to sweet the data that is inserted. Accepts a <list of dicts>. """ | ||
375 | for i in data: | ||
376 | del(i['_id']) | ||
377 | sweet = sweetmaker.make(i['type'], i['author'], i['about'], i['data']) | ||
378 | sweetmaker.send(sweet) | ||
379 | return True | ||
380 | # data = json.dumps(data) | ||
381 | # req = requests.api.post(conf.SWEETURL[0]+"/add",{'data':data}) | ||
382 | # if req.status_code == 200: | ||
383 | # reply = make_response() | ||
384 | # return reply | ||
385 | |||
386 | |||
387 | @app.route("/askSWeeT", methods=['POST']) | ||
361 | 388 | def askSweet(): | |
362 | 389 | data = json.loads(request.form['data']) | |
363 | 390 | for i in data: |
alipi/sweetmaker.py
(21 / 0)
  | |||
1 | import requests | ||
2 | import json | ||
3 | import conf | ||
4 | def make(what, who, where, how): | ||
5 | sweet = {} | ||
6 | sweet['what'] = what | ||
7 | sweet['who'] = who | ||
8 | sweet['where'] = where | ||
9 | sweet['how'] = how | ||
10 | print sweet | ||
11 | sweet_list = [] | ||
12 | sweet_list.append(sweet) | ||
13 | return sweet_list | ||
14 | |||
15 | |||
16 | def send(sweet): | ||
17 | request = requests.api.post(conf.SWEET_STORE_ADD[0],{'data':json.dumps(sweet)}) | ||
18 | if request.status_code == 200: | ||
19 | return True | ||
20 | else: | ||
21 | return False |
alipi/ui.js
(6 / 6)
  | |||
36 | 36 | ||
37 | 37 | createMenu: function(type) { | |
38 | 38 | var xyz = ''; | |
39 | if(type === '1.0') | ||
39 | if(type === 're-narration') | ||
40 | 40 | xyz = document.getElementById("show-box"); | |
41 | 41 | else | |
42 | 42 | xyz = document.getElementById("show-comment"); | |
… | … | ||
49 | 49 | var para = document.createElement("p"); | |
50 | 50 | var newel = document.createElement("a"); | |
51 | 51 | newel.textContent = a11ypi.showbox[i]['lang']; | |
52 | if(type === '1.0') | ||
52 | if(type === 're-narration') | ||
53 | 53 | $(newel).attr("href",config.deploy+"/?foruri="+a['foruri']+"&lang="+a11ypi.showbox[i]['lang']+"&interactive=1"+"&type="+type); | |
54 | 54 | else | |
55 | 55 | $(newel).attr("href",config.deploy+"/?foruri="+a['foruri']+"&tags="+a11ypi.showbox[i]['lang']+"&interactive=0"+"&type="+type); | |
… | … | ||
119 | 119 | if(a['type']) | |
120 | 120 | type = a['type']; | |
121 | 121 | else | |
122 | type = '1.0' | ||
122 | type = 're-narration' | ||
123 | 123 | var lang = ''; | |
124 | 124 | ||
125 | if( type != '1.0') | ||
125 | if( type != 're-narration') | ||
126 | 126 | lang = a['tags']; | |
127 | 127 | else | |
128 | 128 | lang = a['lang']; | |
… | … | ||
152 | 152 | { | |
153 | 153 | console.log(e); | |
154 | 154 | } | |
155 | if(a['type'] == '1.0') | ||
155 | if(a['type'] == 're-narration') | ||
156 | 156 | { | |
157 | 157 | try{ | |
158 | 158 | var result = nodes.iterateNext(); | |
… | … | ||
612 | 612 | d = window.location.search.split('?')[1]; | |
613 | 613 | var a = a11ypi.getParams(); | |
614 | 614 | if (a['blog'] === undefined ) { | |
615 | a11ypi.createMenu('1.0'); | ||
615 | a11ypi.createMenu('re-narration'); | ||
616 | 616 | } | |
617 | 617 | else { | |
618 | 618 | $('#show-box').attr('title', 'Choose a re-narration from the blog you specified.'); |
alipi/wsgi/pageEditor.js
(6 / 9)
  | |||
399 | 399 | }); | |
400 | 400 | }); | |
401 | 401 | }); | |
402 | $.post(config.sweet+'/add', {data : JSON.stringify(util.buildDataString())}, | ||
403 | function(data){ | ||
404 | // data = JSON.parse(data); | ||
405 | $.post(config.deploy+'/askSWeeT',{'data':data},function(){ | ||
406 | window.location.reload(); | ||
407 | // console.log("success!!"); | ||
408 | }); | ||
402 | $.post(config.deploy+'/publish', {data : JSON.stringify(util.buildDataString())}, | ||
403 | function(data){ | ||
404 | window.location.reload(); | ||
405 | }); | ||
409 | 406 | ||
410 | }); //+'&title='+encodeURIComponent(document.title) | ||
407 | //+'&title='+encodeURIComponent(document.title) | ||
411 | 408 | // }).done(function(){ | |
412 | 409 | // console.log("test"); | |
413 | 410 | //window.location.reload(); | |
… | … | ||
444 | 444 | var buff = []; | |
445 | 445 | util.forEach(util.history, function(index, command) { | |
446 | 446 | var dict = {}; | |
447 | dict['type'] = 1; //TYPE refers to the sweet type. The application says the type, 1 is re-narration. | ||
447 | dict['type'] = "re-narration"; //TYPE | ||
448 | 448 | dict['about'] = decodeURIComponent(window.location.search.split('=')[1]); | |
449 | 449 | dict['lang'] = $('#lang-select').val(); | |
450 | 450 | dict["location"] = $('#loc-select').val(); |