Commit 658cf57802dbce0ec6027e740b094bc722c9a698

  • avatar
  • Arvind <arvinkhadri @gm…l.com>
  • Mon Jul 01 13:09:41 IST 2013
API migration from wsgi/ to flask app.  /domain can be queried for pages re-narrated in a domain, e.g all re-narrated pages in foo.com
  
455455 connection.disconnect()
456456 return "empty"
457457
458
459@app.route("/domain")
460def serve_domain_info():
461 collection = g.db['post']
462 url = request.args['url']
463 #all re-narrations of the same xpath are grouped
464 query = collection.group(
465 key = None,
466 condition={"about" :{'$regex':url+'*'}},
467 initial={'narration': []},
468 reduce=Code('function(doc,out){out.narration.push(doc["about"]);}')
469 )
470
471 string=''
472 if len(query)==0:
473 return 'empty'
474 else:
475 otherlist = []
476 mylist = query[0]['narration']
477 for i in mylist:
478 if i in otherlist:
479 pass
480 else:
481 otherlist.append(str(i))
482 return json.dumps(otherlist)
483
484
458485import logging,os
459486from logging import FileHandler
460487
alipi/ui.js
(23 / 19)
  
653653 },
654654
655655 ajaxLinks1: function() {
656 var xhr = new XMLHttpRequest();
657 xhr.onreadystatechange = function()
658 {
659 if(xhr.readyState == 4)
660 {
661 if(xhr.responseText == "empty")
662 { }
663 else
664 {
665 $('#see-links').show();
666 a11ypi.showlinks = JSON.parse(xhr.responseText);
667 }
668 }
669 }
670 xhr.open("POST",config.root+"/domain",true);
671 xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
672 d = window.location.search.split('?')[1];
673 a = a11ypi.getParams();
674 xhr.send('url='+a['foruri'])
656 // var xhr = new XMLHttpRequest();
657 // xhr.onreadystatechange = function()
658 // {
659 // if(xhr.readyState == 4)
660 // {
661 // if(xhr.responseText == "empty")
662 // { }
663 // else
664 // {
665 // $('#see-links').show();
666 // a11ypi.showlinks = JSON.parse(xhr.responseText);
667 // }
668 // }
669 // }
670 // xhr.open("POST",config.deploy+"/domain",true);
671 // xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
672 // d = window.location.search.split('?')[1];
673 // a = a11ypi.getParams();
674 // xhr.send('url='+a['foruri'])
675
676 $.get(config.deploy+"/domain", {"url":a['foruri']}, function(data){
677 a11ypi.showlinks = JSON.parse(data);
678 });
675679 },
676680 showBox1: function() {
677681 this.hideAll();