Commit 8cd871183bfabc244ebf3c710aeb0bb2b9d464a8

  • avatar
  • arvind
  • Fri Dec 13 12:12:59 IST 2013
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
  
3939def start_page() :
4040 d = {}
4141 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.
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.
4343 try:
4444 a = urllib2.urlopen(myhandler1)
4545 if a.geturl() != d['foruri']:
119119
120120def setScripts():
121121 script_test = g.root.makeelement('script')
122 script_edit = g.root.makeelement('script')
122 # script_edit = g.root.makeelement('script')
123123 script_auth = g.root.makeelement('script')
124124 g.root.body.append(script_test)
125 g.root.body.append(script_edit)
125 # g.root.body.append(script_edit)
126126 g.root.body.append(script_auth)
127 script_test.set("src", conf.APPURL[0] + "/alipi/ui.js")
127 script_test.set("src", conf.APPURL[0] + "/alipi/pack.min.js")
128128 script_test.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")
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")
135135 script_auth.set("src", conf.SWEETURL[0] + "/authenticate")
136136 script_auth.set("type","text/javascript")
137137
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")
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")
142142
143143 style = g.root.makeelement('link')
144144 g.root.body.append(style)
145145 style.set("rel","stylesheet")
146146 style.set("type", "text/css")
147 style.set("href", conf.APPURL[0] + "/alipi/stylesheet.css")
147 style.set("href", conf.APPURL[0] + "/alipi/pack.min.css")
148148
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")
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")
153153
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)
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)
159159
160160def setSocialScript():
161161 info_button = g.root.makeelement('button')
401401 i['bxpath'] = ''
402402 collection.insert(i)
403403
404 print data
405
406 page['title'] = "Re-narration of " + content[0]['about']
407 page['name'] = "About " + content[0]['about']
404 page['title'] = "Re-narration of " + content[0]['attr']['about']
405 page['name'] = "About " + content[0]['attr']['about']
408406 page['content'] = content
409407
410 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)
411410 sweet(data)
412411 reply = make_response()
413412 return reply
416416 """ A function to sweet the data that is inserted. Accepts a <list of dicts>. """
417417 for i in data:
418418 if 'type' in i:
419 print i
420419 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"]+'}'}])
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"]+'}'}])
422421 return True
423422 # data = json.dumps(data)
424423 # req = requests.api.post(conf.SWEETURL[0]+"/add",{'data':data})
alipi/ui.js
(29 / 11)
  
1717 {
1818 if(document.getElementById('social_overlay') != null)
1919 document.body.removeChild(document.getElementById('social_overlay'));
20 $(document).ready(function(){$('body *').contents().filter(function(){
20 $(document).ready(function(){
21 try{
22 $('body *').not('iframe').contents().filter(function(){
2123 try{
22 if(this.nodeType === 3 && !($(this).hasClass('alipi'))){
23 return (this.nodeType === 3) && this.nodeValue.match(/\S/);}}
24 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);
2529 }
26 }).parent().attr('m4pageedittype','text')});
30 }).parent().attr('m4pageedittype','text');
31 }
32 catch(e){
33 console.log(this);
34 }
35 });
2736
2837 vimg = document.getElementsByTagName('img');
2938 for(i=0; i<vimg.length; i++)
326326 },
327327 loadOverlay: function()
328328 {
329 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">'+
330335 '<button id="outter-down-button" class="alipi" onclick="a11ypi.outterToggle();" up="true" title="Move this bar to top">Move</button> '+
331336 '<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> '+
337 '<button id="edit-current" class="alipi" title="Allow to edit this page">Re-narrate</button> '+
333338 '<button id="see-narration" class="alipi" onclick="a11ypi.showBox();" title="See other renarrations, which are in same or other languages"> '+
334339 'Re-narrations</button>'+
335340 // '<button id="see-comment" class="alipi" onclick="a11ypi.showComment();" title="5el"> '+
377377 $('#go').button({disabled : true});
378378 $('#undo-button').button({ disabled: true});
379379 $('#publish-button').button({ disabled: true});
380 $('input:.alipi, select:.alipi').button();
380 $('input[class="alipi"], select[class="alipi"]').button();
381381
382382 $("#outter-down-button").button({icons:{primary:"ui-icon-circle-arrow-n"},text:false}); $('#outter-down-button').children().addClass('alipi');
383383 $("#outter-up-button").button({icons:{primary:"ui-icon-circle-arrow-s"},text:false}); $('#outter-up-button').children().addClass('alipi');
404404 $("#delete-image").button({icons:{primary:"ui-icon-trash"}}); $('#delete-image').children().addClass('alipi');
405405 $("#close-element").button({icons:{primary:"ui-icon-circle-close"},text:false}); $("#close-element").children().addClass('alipi');
406406
407 $("#edit-current").button();
408 $("#edit-current").on("click", a11ypi.editPage);
409
407410 $('#renarrated_overlay').addClass('barOnTop');
408411 a11ypi.ajax();
409412 a11ypi.ajaxLinks1();
429429 $('#orig-button').insertAfter($('#go')); $('#orig-button').show();
430430 $('#share-box').append($('#fb-like')); $('#share-box').append($('#tweet-root'));
431431 }
432 }}]);
432433 },
433434 checkSelect: function()
434435 {
888888 });
889889 },
890890 editPage: function() {
891 this.hideAll();
891 //this.hideAll();
892892 a11ypi.testContext();
893893 $('#pub_overlay').show(); $('#pub_overlay').addClass('barOnTop');
894894 $('#icon-down').show();
895895 $('#renarrated_overlay').hide();
896 $('body *').contents().filter(function(){
896 $('body *').not('iframe').contents().filter(function(){
897897 {
898898 try{
899899 if(!($(this).hasClass('alipi')) && $(this).attr('m4pageedittype') )
906906 }
907907 }).click(pageEditor.startEdit);
908908
909 $('body *').contents().filter(function(){
909 $('body *').not('iframe').contents().filter(function(){
910910 {
911911 try{
912912 if(!($(this).hasClass('alipi')) || $(this).attr('m4pageedittype'))