Commit 8cd871183bfabc244ebf3c710aeb0bb2b9d464a8
API changes, Bug fixes
- Sweet maker now sends out the URL of the blog in the sweet
- iframes were causing JS thread to stop execution, avoiding them now
- Using yepnope now to detect if jquery is needed.
- CSS and JS are now minfied and served
- alipi/alipi.py 60 -------------------------------+++++++++++++++++++++++++++++
- alipi/ui.js 40 -----------+++++++++++++++++++++++++++++
| | | | 39 | def start_page() : | 39 | def start_page() : |
---|
40 | d = {} | 40 | d = {} |
---|
41 | d['foruri'] = request.args['foruri'] | 41 | d['foruri'] = request.args['foruri'] |
---|
42 | myhandler1 = urllib2.Request(d['foruri'],headers={'User-Agent':"Mozilla/5.0 (X11; U; Linux i686) Gecko/20071127 Firefox/2.0.0.11"}) #A fix to send user-agents, so that sites render properly. | | myhandler1 = urllib2.Request(d['foruri'],headers={'User-Agent':"Mozilla/5.0 (X11; U; Linux i686) Gecko/20071127 Firefox/2.0.0.11"}) #A fix to send user-agents, so that sites render properly. |
---|
| | 42 | myhandler1 = urllib2.Request(d['foruri'],headers={'User-Agent':"Mozilla/5.0 (X11; Linux x86_64; rv:25.0) Gecko/20100101 Firefox/25.0)"}) #A fix to send user-agents, so that sites render properly. | 43 | try: | 43 | try: |
---|
44 | a = urllib2.urlopen(myhandler1) | 44 | a = urllib2.urlopen(myhandler1) |
---|
45 | if a.geturl() != d['foruri']: | 45 | if a.geturl() != d['foruri']: |
---|
… | | … | |
---|
119 | | 119 | |
---|
120 | def setScripts(): | 120 | def setScripts(): |
---|
121 | script_test = g.root.makeelement('script') | 121 | script_test = g.root.makeelement('script') |
---|
122 | script_edit = g.root.makeelement('script') | | script_edit = g.root.makeelement('script') |
---|
| | 122 | # script_edit = g.root.makeelement('script') | 123 | script_auth = g.root.makeelement('script') | 123 | script_auth = g.root.makeelement('script') |
---|
124 | g.root.body.append(script_test) | 124 | g.root.body.append(script_test) |
---|
125 | g.root.body.append(script_edit) | | g.root.body.append(script_edit) |
---|
| | 125 | # g.root.body.append(script_edit) | 126 | g.root.body.append(script_auth) | 126 | g.root.body.append(script_auth) |
---|
127 | script_test.set("src", conf.APPURL[0] + "/alipi/ui.js") | | script_test.set("src", conf.APPURL[0] + "/alipi/ui.js") |
---|
| | 127 | script_test.set("src", conf.APPURL[0] + "/alipi/pack.min.js") | 128 | script_test.set("type", "text/javascript") | 128 | script_test.set("type", "text/javascript") |
---|
129 | script_edit.set("src", conf.APPURL[0] + "/alipi/wsgi/pageEditor.js") | | script_edit.set("src", conf.APPURL[0] + "/alipi/wsgi/pageEditor.js") |
---|
130 | script_edit.set("type","text/javascript") | | script_edit.set("type","text/javascript") |
---|
131 | script_config = g.root.makeelement('script') | | script_config = g.root.makeelement('script') |
---|
132 | g.root.body.append(script_config) | | g.root.body.append(script_config) |
---|
133 | script_config.set("src", conf.APPURL[0] + "/alipi/config.js") | | script_config.set("src", conf.APPURL[0] + "/alipi/config.js") |
---|
134 | script_config.set("type", "text/javascript") | | script_config.set("type", "text/javascript") |
---|
| | 129 | # script_edit.set("src", conf.APPURL[0] + "/alipi/wsgi/pageEditor.js") | | | 130 | # script_edit.set("type","text/javascript") |
---|
| | 131 | # script_config = g.root.makeelement('script') |
---|
| | 132 | # g.root.body.append(script_config) |
---|
| | 133 | # script_config.set("src", conf.APPURL[0] + "/alipi/config.js") |
---|
| | 134 | # script_config.set("type", "text/javascript") |
---|
135 | script_auth.set("src", conf.SWEETURL[0] + "/authenticate") | 135 | script_auth.set("src", conf.SWEETURL[0] + "/authenticate") |
---|
136 | script_auth.set("type","text/javascript") | 136 | script_auth.set("type","text/javascript") |
---|
137 | | 137 | |
---|
138 | script_jq_mini = g.root.makeelement('script') | | script_jq_mini = g.root.makeelement('script') |
---|
139 | g.root.body.append(script_jq_mini) | | g.root.body.append(script_jq_mini) |
---|
140 | script_jq_mini.set("src", conf.JQUERYURL[0] + "/jquery.min.js") | | script_jq_mini.set("src", conf.JQUERYURL[0] + "/jquery.min.js") |
---|
141 | script_jq_mini.set("type", "text/javascript") | | script_jq_mini.set("type", "text/javascript") |
---|
| | 138 | # script_jq_mini = g.root.makeelement('script') | | | 139 | # g.root.body.append(script_jq_mini) |
---|
| | 140 | # script_jq_mini.set("src", conf.JQUERYURL[0] + "/jquery.min.js") |
---|
| | 141 | # script_jq_mini.set("type", "text/javascript") |
---|
142 | | 142 | |
---|
143 | style = g.root.makeelement('link') | 143 | style = g.root.makeelement('link') |
---|
144 | g.root.body.append(style) | 144 | g.root.body.append(style) |
---|
145 | style.set("rel","stylesheet") | 145 | style.set("rel","stylesheet") |
---|
146 | style.set("type", "text/css") | 146 | style.set("type", "text/css") |
---|
147 | style.set("href", conf.APPURL[0] + "/alipi/stylesheet.css") | | style.set("href", conf.APPURL[0] + "/alipi/stylesheet.css") |
---|
| | 147 | style.set("href", conf.APPURL[0] + "/alipi/pack.min.css") | 148 | | 148 | |
---|
149 | script_jq_cust = g.root.makeelement('script') | | script_jq_cust = g.root.makeelement('script') |
---|
150 | g.root.body.append(script_jq_cust) | | g.root.body.append(script_jq_cust) |
---|
151 | script_jq_cust.set("src", conf.JQUERYUI[0] + "/jquery-ui.min.js") | | script_jq_cust.set("src", conf.JQUERYUI[0] + "/jquery-ui.min.js") |
---|
152 | script_jq_cust.set("type", "text/javascript") | | script_jq_cust.set("type", "text/javascript") |
---|
| | 149 | # script_jq_cust = g.root.makeelement('script') | | | 150 | # g.root.body.append(script_jq_cust) |
---|
| | 151 | # script_jq_cust.set("src", conf.JQUERYUI[0] + "/jquery-ui.min.js") |
---|
| | 152 | # script_jq_cust.set("type", "text/javascript") |
---|
153 | | 153 | |
---|
154 | style_cust = g.root.makeelement('link') | | style_cust = g.root.makeelement('link') |
---|
155 | style_cust.set("rel","stylesheet") | | style_cust.set("rel","stylesheet") |
---|
156 | style_cust.set("type", "text/css") | | style_cust.set("type", "text/css") |
---|
157 | style_cust.set("href", conf.JQUERYCSS[0] + "/jquery-ui.css") | | style_cust.set("href", conf.JQUERYCSS[0] + "/jquery-ui.css") |
---|
158 | g.root.body.append(style_cust) | | g.root.body.append(style_cust) |
---|
| | 154 | # style_cust = g.root.makeelement('link') | | | 155 | # style_cust.set("rel","stylesheet") |
---|
| | 156 | # style_cust.set("type", "text/css") |
---|
| | 157 | # style_cust.set("href", conf.JQUERYCSS[0] + "/jquery-ui.css") |
---|
| | 158 | # g.root.body.append(style_cust) |
---|
159 | | 159 | |
---|
160 | def setSocialScript(): | 160 | def setSocialScript(): |
---|
161 | info_button = g.root.makeelement('button') | 161 | info_button = g.root.makeelement('button') |
---|
… | | … | |
---|
401 | i['bxpath'] = '' | 401 | i['bxpath'] = '' |
---|
402 | collection.insert(i) | 402 | collection.insert(i) |
---|
403 | | 403 | |
---|
404 | print data | | print data |
---|
405 | | | |
---|
406 | page['title'] = "Re-narration of " + content[0]['about'] | | page['title'] = "Re-narration of " + content[0]['about'] |
---|
407 | page['name'] = "About " + content[0]['about'] | | page['name'] = "About " + content[0]['about'] |
---|
| | 404 | page['title'] = "Re-narration of " + content[0]['attr']['about'] | | | 405 | page['name'] = "About " + content[0]['attr']['about'] |
---|
408 | page['content'] = content | 406 | page['content'] = content |
---|
409 | | 407 | |
---|
410 | requests.api.post(conf.CUSTOM_BLOG_POST_URL[0], json.dumps(page), headers={"content-type":"application/json"}) | | requests.api.post(conf.CUSTOM_BLOG_POST_URL[0], json.dumps(page), headers={"content-type":"application/json"}) |
---|
| | 408 | g.response_from_blogger = requests.api.post(conf.CUSTOM_BLOG_POST_URL[0], json.dumps(page), headers={"content-type":"application/json"}) | | | 409 | print "response from blogger " + repr(g.response_from_blogger) |
---|
411 | sweet(data) | 410 | sweet(data) |
---|
412 | reply = make_response() | 411 | reply = make_response() |
---|
413 | return reply | 412 | return reply |
---|
… | | … | |
---|
416 | """ A function to sweet the data that is inserted. Accepts a <list of dicts>. """ | 416 | """ A function to sweet the data that is inserted. Accepts a <list of dicts>. """ |
---|
417 | for i in data: | 417 | for i in data: |
---|
418 | if 'type' in i: | 418 | if 'type' in i: |
---|
419 | print i | | print i |
---|
420 | del(i['_id']) | 419 | del(i['_id']) |
---|
421 | sweetmaker.sweet(conf.SWEET_STORE_ADD[0], [{"what":i['type'], "who":i['author'], "where":i['about']+i['xpath'], "how":i['data']+' {lang: '+i["lang"]+',loc: '+i["location"]+'}'}]) | | sweetmaker.sweet(conf.SWEET_STORE_ADD[0], [{"what":i['type'], "who":i['author'], "where":i['about']+i['xpath'], "how":i['data']+' {lang: '+i["lang"]+',loc: '+i["location"]+'}'}]) |
---|
| | 420 | sweetmaker.sweet(conf.SWEET_STORE_ADD[0], [{"what":i['type'], "who":i['author'], "where":i['about']+i['xpath'], "how":conf.CUSTOM_BLOG_URL[0]+"/#"+g.response_from_blogger.json()['name']+' {lang: '+i["lang"]+',loc: '+i["location"]+'}'}]) | 422 | return True | 421 | return True |
---|
423 | # data = json.dumps(data) | 422 | # data = json.dumps(data) |
---|
424 | # req = requests.api.post(conf.SWEETURL[0]+"/add",{'data':data}) | 423 | # req = requests.api.post(conf.SWEETURL[0]+"/add",{'data':data}) |
---|
| | | | 17 | { | 17 | { |
---|
18 | if(document.getElementById('social_overlay') != null) | 18 | if(document.getElementById('social_overlay') != null) |
---|
19 | document.body.removeChild(document.getElementById('social_overlay')); | 19 | document.body.removeChild(document.getElementById('social_overlay')); |
---|
20 | $(document).ready(function(){$('body *').contents().filter(function(){ | | $(document).ready(function(){$('body *').contents().filter(function(){ |
---|
| | 20 | $(document).ready(function(){ | | | 21 | try{ |
---|
| | 22 | $('body *').not('iframe').contents().filter(function(){ |
---|
21 | try{ | 23 | try{ |
---|
22 | if(this.nodeType === 3 && !($(this).hasClass('alipi'))){ | | if(this.nodeType === 3 && !($(this).hasClass('alipi'))){ |
---|
23 | return (this.nodeType === 3) && this.nodeValue.match(/\S/);}} | | return (this.nodeType === 3) && this.nodeValue.match(/\S/);}} |
---|
24 | catch(err){ | | catch(err){ |
---|
| | 24 | | | | 25 | if(this.nodeType == 3 && !($(this).hasClass('alipi'))){ |
---|
| | 26 | return (this.nodeType == 3) && this.nodeValue.match(/\S/);}} |
---|
| | 27 | catch(err){ |
---|
| | 28 | console.log(err); |
---|
25 | } | 29 | } |
---|
26 | }).parent().attr('m4pageedittype','text')}); | | }).parent().attr('m4pageedittype','text')}); |
---|
| | 30 | }).parent().attr('m4pageedittype','text'); | | | 31 | } |
---|
| | 32 | catch(e){ |
---|
| | 33 | console.log(this); |
---|
| | 34 | } |
---|
| | 35 | }); |
---|
27 | | 36 | |
---|
28 | vimg = document.getElementsByTagName('img'); | 37 | vimg = document.getElementsByTagName('img'); |
---|
29 | for(i=0; i<vimg.length; i++) | 38 | for(i=0; i<vimg.length; i++) |
---|
… | | … | |
---|
326 | }, | 326 | }, |
---|
327 | loadOverlay: function() | 327 | loadOverlay: function() |
---|
328 | { | 328 | { |
---|
329 | var overlay_template = '<div id="renarrated_overlay" class="alipi ui-widget-header ui-corner-all">'+ | | var overlay_template = '<div id="renarrated_overlay" class="alipi ui-widget-header ui-corner-all">'+ |
---|
| | 329 | yepnope([{ | | | 330 | test: window.jQuery, |
---|
| | 331 | nope:['//code.jquery.com/jquery-1.10.2.min.js'], |
---|
| | 332 | load:['//code.jquery.com/ui/1.10.3/jquery-ui.js'], |
---|
| | 333 | complete:function(){ |
---|
| | 334 | var overlay_template = '<div id="renarrated_overlay" class="alipi ui-widget-header ui-corner-all">'+ |
---|
330 | '<button id="outter-down-button" class="alipi" onclick="a11ypi.outterToggle();" up="true" title="Move this bar to top">Move</button> '+ | 335 | '<button id="outter-down-button" class="alipi" onclick="a11ypi.outterToggle();" up="true" title="Move this bar to top">Move</button> '+ |
---|
331 | '<button id="outter-up-button" class="alipi" onclick="a11ypi.outterToggle();" title="Move this bar to bottom">Move</button> '+ | 336 | '<button id="outter-up-button" class="alipi" onclick="a11ypi.outterToggle();" title="Move this bar to bottom">Move</button> '+ |
---|
332 | '<button id="edit-current" class="alipi" onclick="a11ypi.editPage();" title="Allow to edit this page">Re-narrate</button> '+ | | '<button id="edit-current" class="alipi" onclick="a11ypi.editPage();" title="Allow to edit this page">Re-narrate</button> '+ |
---|
| | 337 | '<button id="edit-current" class="alipi" title="Allow to edit this page">Re-narrate</button> '+ | 333 | '<button id="see-narration" class="alipi" onclick="a11ypi.showBox();" title="See other renarrations, which are in same or other languages"> '+ | 338 | '<button id="see-narration" class="alipi" onclick="a11ypi.showBox();" title="See other renarrations, which are in same or other languages"> '+ |
---|
334 | 'Re-narrations</button>'+ | 339 | 'Re-narrations</button>'+ |
---|
335 | // '<button id="see-comment" class="alipi" onclick="a11ypi.showComment();" title="5el"> '+ | 340 | // '<button id="see-comment" class="alipi" onclick="a11ypi.showComment();" title="5el"> '+ |
---|
… | | … | |
---|
377 | $('#go').button({disabled : true}); | 377 | $('#go').button({disabled : true}); |
---|
378 | $('#undo-button').button({ disabled: true}); | 378 | $('#undo-button').button({ disabled: true}); |
---|
379 | $('#publish-button').button({ disabled: true}); | 379 | $('#publish-button').button({ disabled: true}); |
---|
380 | $('input:.alipi, select:.alipi').button(); | | $('input:.alipi, select:.alipi').button(); |
---|
| | 380 | $('input[class="alipi"], select[class="alipi"]').button(); | 381 | | 381 | |
---|
382 | $("#outter-down-button").button({icons:{primary:"ui-icon-circle-arrow-n"},text:false}); $('#outter-down-button').children().addClass('alipi'); | 382 | $("#outter-down-button").button({icons:{primary:"ui-icon-circle-arrow-n"},text:false}); $('#outter-down-button').children().addClass('alipi'); |
---|
383 | $("#outter-up-button").button({icons:{primary:"ui-icon-circle-arrow-s"},text:false}); $('#outter-up-button').children().addClass('alipi'); | 383 | $("#outter-up-button").button({icons:{primary:"ui-icon-circle-arrow-s"},text:false}); $('#outter-up-button').children().addClass('alipi'); |
---|
… | | … | |
---|
404 | $("#delete-image").button({icons:{primary:"ui-icon-trash"}}); $('#delete-image').children().addClass('alipi'); | 404 | $("#delete-image").button({icons:{primary:"ui-icon-trash"}}); $('#delete-image').children().addClass('alipi'); |
---|
405 | $("#close-element").button({icons:{primary:"ui-icon-circle-close"},text:false}); $("#close-element").children().addClass('alipi'); | 405 | $("#close-element").button({icons:{primary:"ui-icon-circle-close"},text:false}); $("#close-element").children().addClass('alipi'); |
---|
406 | | 406 | |
---|
| | 407 | $("#edit-current").button(); |
---|
| | 408 | $("#edit-current").on("click", a11ypi.editPage); |
---|
| | 409 | |
---|
407 | $('#renarrated_overlay').addClass('barOnTop'); | 410 | $('#renarrated_overlay').addClass('barOnTop'); |
---|
408 | a11ypi.ajax(); | 411 | a11ypi.ajax(); |
---|
409 | a11ypi.ajaxLinks1(); | 412 | a11ypi.ajaxLinks1(); |
---|
… | | … | |
---|
429 | $('#orig-button').insertAfter($('#go')); $('#orig-button').show(); | 429 | $('#orig-button').insertAfter($('#go')); $('#orig-button').show(); |
---|
430 | $('#share-box').append($('#fb-like')); $('#share-box').append($('#tweet-root')); | 430 | $('#share-box').append($('#fb-like')); $('#share-box').append($('#tweet-root')); |
---|
431 | } | 431 | } |
---|
| | 432 | }}]); |
---|
432 | }, | 433 | }, |
---|
433 | checkSelect: function() | 434 | checkSelect: function() |
---|
434 | { | 435 | { |
---|
… | | … | |
---|
888 | }); | 888 | }); |
---|
889 | }, | 889 | }, |
---|
890 | editPage: function() { | 890 | editPage: function() { |
---|
891 | this.hideAll(); | | this.hideAll(); |
---|
| | 891 | //this.hideAll(); | 892 | a11ypi.testContext(); | 892 | a11ypi.testContext(); |
---|
893 | $('#pub_overlay').show(); $('#pub_overlay').addClass('barOnTop'); | 893 | $('#pub_overlay').show(); $('#pub_overlay').addClass('barOnTop'); |
---|
894 | $('#icon-down').show(); | 894 | $('#icon-down').show(); |
---|
895 | $('#renarrated_overlay').hide(); | 895 | $('#renarrated_overlay').hide(); |
---|
896 | $('body *').contents().filter(function(){ | | $('body *').contents().filter(function(){ |
---|
| | 896 | $('body *').not('iframe').contents().filter(function(){ | 897 | { | 897 | { |
---|
898 | try{ | 898 | try{ |
---|
899 | if(!($(this).hasClass('alipi')) && $(this).attr('m4pageedittype') ) | 899 | if(!($(this).hasClass('alipi')) && $(this).attr('m4pageedittype') ) |
---|
… | | … | |
---|
906 | } | 906 | } |
---|
907 | }).click(pageEditor.startEdit); | 907 | }).click(pageEditor.startEdit); |
---|
908 | | 908 | |
---|
909 | $('body *').contents().filter(function(){ | | $('body *').contents().filter(function(){ |
---|
| | 909 | $('body *').not('iframe').contents().filter(function(){ | 910 | { | 910 | { |
---|
911 | try{ | 911 | try{ |
---|
912 | if(!($(this).hasClass('alipi')) || $(this).attr('m4pageedittype')) | 912 | if(!($(this).hasClass('alipi')) || $(this).attr('m4pageedittype')) |
---|