From 048020ff9811dde7b00454cc517551fa523641e5 Mon Sep 17 00:00:00 2001 From: Arvind Date: Wed, 1 May 2013 16:45:22 +0530 Subject: [PATCH] Bug fixes - Moving /server to /alipi. - Standardizing how data is sent to APIs --- alipi/alipi.py | 428 ++++++++++++++++ alipi/index.html | 49 ++ alipi/launcher.wsgi | 4 + alipi/login.js | 309 ++++++++++++ alipi/sampleConf.py | 8 + alipi/sampleConfig.js | 6 + alipi/stylesheet.css | 214 ++++++++ alipi/templates/blank.html | 62 +++ alipi/templates/directory.html | 22 + alipi/templates/error.html | 6 + alipi/templates/feeds.html | 67 +++ alipi/ui.js | 1024 +++++++++++++++++++++++++++++++++++++++ alipi/wsgi/pageEditor.js | 582 ++++++++++++++++++++++ server/alipi.py | 426 ---------------- server/index.html | 49 -- server/launcher.wsgi | 4 - server/login.js | 309 ------------ server/sampleConf.py | 8 - server/sampleConfig.js | 6 - server/stylesheet.css | 214 -------- server/templates/blank.html | 62 --- server/templates/directory.html | 22 - server/templates/error.html | 6 - server/templates/feeds.html | 67 --- server/ui.js | 1024 --------------------------------------- server/wsgi/pageEditor.js | 582 ---------------------- 26 files changed, 2781 insertions(+), 2779 deletions(-) create mode 100755 alipi/alipi.py create mode 100755 alipi/index.html create mode 100755 alipi/launcher.wsgi create mode 100644 alipi/login.js create mode 100644 alipi/sampleConf.py create mode 100644 alipi/sampleConfig.js create mode 100755 alipi/stylesheet.css create mode 100644 alipi/templates/blank.html create mode 100644 alipi/templates/directory.html create mode 100644 alipi/templates/error.html create mode 100644 alipi/templates/feeds.html create mode 100644 alipi/ui.js create mode 100755 alipi/wsgi/pageEditor.js delete mode 100755 server/alipi.py delete mode 100755 server/index.html delete mode 100755 server/launcher.wsgi delete mode 100644 server/login.js delete mode 100644 server/logme delete mode 100644 server/sampleConf.py delete mode 100644 server/sampleConfig.js delete mode 100755 server/stylesheet.css delete mode 100644 server/templates/blank.html delete mode 100644 server/templates/directory.html delete mode 100644 server/templates/error.html delete mode 100644 server/templates/feeds.html delete mode 100644 server/ui.js delete mode 100755 server/wsgi/pageEditor.js diff --git a/alipi/alipi.py b/alipi/alipi.py new file mode 100755 index 0000000..8132067 --- /dev/null +++ b/alipi/alipi.py @@ -0,0 +1,428 @@ +from flask import Flask +from flask import request +from flask import render_template +from flask import make_response +import lxml.html +import pymongo +from bson import Code +import urllib2 +import StringIO +from flask import g +from flask import redirect +from urllib import quote_plus +from urllib import unquote_plus +import conf +import oursql +import requests +from flask import jsonify +import json + + +app = Flask(__name__) +@app.before_request +def first(): + g.connection = pymongo.MongoClient('localhost',27017) #Create the object once and use it. + g.db = g.connection[conf.MONGODB[0]] +@app.teardown_request +def close(exception): + g.connection.disconnect() +@app.route('/') +def start_page() : + d = {} + d['foruri'] = request.args['foruri'] + 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. + try: + a = urllib2.urlopen(myhandler1) + if a.geturl() != d['foruri']: + return "There was a server redirect, please click on the link to continue.".format(quote_plus(a.geturl())) + else: + page = a.read() + a.close() + except ValueError: + return "The link is malformed, click here to be redirected.".format(quote_plus(unquote_plus(d['foruri'].encode('utf-8'))),request.args['lang']) + except urllib2.URLError: + return render_template('error.html') + try: + page = unicode(page,'utf-8') #Hack to fix improperly displayed chars on wikipedia. + except UnicodeDecodeError: + pass #Some pages may not need be utf-8'ed + try: + g.root = lxml.html.parse(StringIO.StringIO(page)).getroot() + except ValueError: + g.root = lxml.html.parse(d['foruri']).getroot() #Sometimes creators of the page lie about the encoding, thus leading to this execption. http://lxml.de/parsing.html#python-unicode-strings + if request.args.has_key('lang') == False and request.args.has_key('blog') == False: + g.root.make_links_absolute(d['foruri'], resolve_base_href = True) + for i in g.root.iterlinks(): + if i[1] == 'href' and i[0].tag != 'link': + try: + i[0].attrib['href'] = 'http://{0}?foruri={1}'.format(conf.DEPLOYURL[0],quote_plus(i[0].attrib['href'])) + except KeyError: + i[0].attrib['href'] = '{0}?foruri={1}'.format(conf.DEPLOYURL[0],quote_plus(i[0].attrib['href'].encode('utf-8'))) + setScripts() + g.root.body.set("onload","a11ypi.loadOverlay();") + return lxml.html.tostring(g.root) + + elif request.args.has_key('lang') == True and request.args.has_key('interactive') == True and request.args.has_key('blog') == False: + setScripts() + setSocialScript() + g.root.body.set("onload","a11ypi.ren();a11ypi.tweet(); a11ypi.facebook(); a11ypi.loadOverlay();") + g.root.make_links_absolute(d['foruri'], resolve_base_href = True) + return lxml.html.tostring(g.root) + + elif request.args.has_key('lang') == True and request.args.has_key('blog') == False: + script_jq_mini = g.root.makeelement('script') + g.root.body.append(script_jq_mini) + script_jq_mini.set("src", conf.JQUERYURL[0] + "/jquery.min.js") + script_jq_mini.set("type", "text/javascript") + d['lang'] = request.args['lang'] + script_test = g.root.makeelement('script') + g.root.body.append(script_test) + script_test.set("src", conf.APPURL[0] + "/alipi/ui.js") + script_test.set("type", "text/javascript") + g.root.body.set("onload","a11ypi.ren()"); + return lxml.html.tostring(g.root) + + elif request.args.has_key('interactive') == True and request.args.has_key('blog') == True and request.args.has_key('lang') == True: + setScripts() + setSocialScript() + g.root.body.set("onload","a11ypi.filter(); a11ypi.tweet(); a11ypi.facebook(); a11ypi.loadOverlay();"); + g.root.make_links_absolute(d['foruri'], resolve_base_href = True) + return lxml.html.tostring(g.root) + + elif request.args.has_key('interactive') == False and request.args.has_key('blog') == True: + setScripts() + g.root.make_links_absolute(d['foruri'], resolve_base_href = True) + g.root.body.set('onload', 'a11ypi.loadOverlay();') + return lxml.html.tostring(g.root) + +def setScripts(): + script_test = g.root.makeelement('script') + script_edit = g.root.makeelement('script') + g.root.body.append(script_test) + g.root.body.append(script_edit) + script_test.set("src", conf.APPURL[0] + "/alipi/ui.js") + script_test.set("type", "text/javascript") + script_edit.set("src", conf.APPURL[0] + "/alipi/wsgi/pageEditor.js") + script_edit.set("type","text/javascript") + script_config = g.root.makeelement('script') + g.root.body.append(script_config) + script_config.set("src", conf.APPURL[0] + "/alipi/config.js") + script_config.set("type", "text/javascript") + + + script_jq_mini = g.root.makeelement('script') + g.root.body.append(script_jq_mini) + script_jq_mini.set("src", conf.JQUERYURL[0] + "/jquery.min.js") + script_jq_mini.set("type", "text/javascript") + + style = g.root.makeelement('link') + g.root.body.append(style) + style.set("rel","stylesheet") + style.set("type", "text/css") + style.set("href", conf.APPURL[0] + "/alipi/stylesheet.css") + + script_jq_cust = g.root.makeelement('script') + g.root.body.append(script_jq_cust) + script_jq_cust.set("src", conf.JQUERYUI[0] + "/jquery-ui.min.js") + script_jq_cust.set("type", "text/javascript") + + style_cust = g.root.makeelement('link') + style_cust.set("rel","stylesheet") + style_cust.set("type", "text/css") + style_cust.set("href", conf.JQUERYCSS[0] + "/jquery-ui.css") + g.root.body.append(style_cust) + +def setSocialScript(): + info_button = g.root.makeelement('button') + g.root.body.append(info_button) + info_button.set("id", "info") + info_button.set("class", "alipi") + info_button.set("onClick", "a11ypi.showInfo(a11ypi.responseJSON);") + info_button.text = "Info" + info_button.set("title", "Have a look at the information of each renarrated element") + + share_button = g.root.makeelement('button') + g.root.body.append(share_button) + share_button.set("id", "share") + share_button.set("class", "alipi") + share_button.set("onClick", "a11ypi.share();") + share_button.text = "Share" + share_button.set("title", "Share your contribution in your social network") + + see_orig = g.root.makeelement('button') + g.root.body.append(see_orig) + see_orig.set("id", "orig-button") + see_orig.set("class", "alipi") + see_orig.set("onClick", "a11ypi.showOriginal();") + see_orig.text = "Original Page" + see_orig.set("title", "Go to Original link, the original page of this renarrated") + + tweetroot = g.root.makeelement("div") + tweetroot.set("id", "tweet-root") + tweetroot.set("class", "alipi") + tweetroot.set("style", "display:none;padding:10px;") + g.root.body.append(tweetroot) + + tweet = g.root.makeelement("a") + tweet.set("id", "tweet") + tweet.set("href", "https://twitter.com/share") + tweet.set("class", "alipi twitter-share-button") + tweet.set("data-via", "a11ypi") + tweet.set("data-lang", "en") + tweet.set("data-url", "http://y.a11y.in/web?foruri={0}&lang={1}&interactive=1".format(quote_plus(request.args['foruri']),(request.args['lang']).encode('unicode-escape'))) + tweet.textContent = "Tweet" + tweetroot.append(tweet) + + fblike = g.root.makeelement("div") + fblike.set("id", "fb-like") + fblike.set("class", "alipi fb-like") + fblike.set("style", "display:none;padding:10px;") + fblike.set("data-href", "http://y.a11y.in/web?foruri={0}&lang={1}&interactive=1".format(quote_plus(request.args['foruri']),(request.args['lang']).encode('unicode-escape'))) + fblike.set("data-send", "true") + fblike.set("data-layout", "button_count") + fblike.set("data-width", "50") + fblike.set("data-show-faces", "true") + fblike.set("data-font", "arial") + g.root.body.append(fblike) + + style = g.root.makeelement('link') + g.root.body.append(style) + style.set("rel","stylesheet") + style.set("type", "text/css") + style.set("href", "http://y.a11y.in/alipi/stylesheet.css") + + +@app.route('/directory') +def show_directory(): + collection = g.db['post'] + query = collection.group( + key = Code('function(doc){return {"about" : doc.about,"lang":doc.lang}}'), + condition={"about":{'$regex':'^[/\S/]'}}, + initial={'na': []}, + reduce=Code('function(doc,out){out.na.push(doc.blog)}') + ) + query.reverse() + return render_template('directory.html', name=query, mymodule = quote_plus, myset=set, mylist= list) + +@app.route('/getLoc', methods=['GET']) +def get_loc(): + + term = request.args['term'] + connection = oursql.Connection(conf.DBHOST[0],conf.DBUSRNAME[0],conf.DBPASSWD[0],db=conf.DBNAME[0]) + cursor = connection.cursor(oursql.DictCursor) + cursor.execute('select l.name, c.country_name from `location` as l, `codes` as c where l.name like ? and l.code=c.code limit ?', (term+'%', 5)) + r = cursor.fetchall() + connection.close() + d = {} + d['return'] = r + response = jsonify(d) + response.headers['Access-Control-Allow-Origin'] = '*' + return response +@app.route('/getLang', methods=['GET']) +def get_lang(): + term = request.args['term'] + connection = oursql.Connection(conf.DBHOST[0],conf.DBUSRNAME[0],conf.DBPASSWD[0],db=conf.DBNAME[0]) + cursor = connection.cursor(oursql.DictCursor) + cursor.execute('select * from `languages` as l where l.name like ? limit ?', (term+'%',5)) + r = cursor.fetchall() + connection.close() + d = {} + d['return'] = r + response = jsonify(d) + response.headers['Access-Control-Allow-Origin'] = '*' + return response +@app.route('/blank', methods=['GET']) +def serve_blank(): + return render_template('blank.html') + +@app.route('/info', methods=['GET']) +def serve_info(): + coll = g.db['post'] + d = {} + cntr = 0 + for i in coll.find({"about":unquote_plus(request.args['about']),"lang":request.args['lang']}): + i['_id'] = str(i['_id']) + d[cntr] = i + cntr+=1 + response = jsonify(d) + response.headers['Access-Control-Allow-Origin'] = '*' + return response + + +@app.route("/replace", methods=['GET']) +def replace(): + collection = g.db['post'] + lang = request.args['lang'] + url = request.args['url'] + query = collection.group( + key = Code('function(doc){return {"xpath" : doc.xpath, "about": doc.url}}'), + condition={"about" : url, "lang" : lang,"elementtype":"text"}, + initial={'narration': []}, + reduce=Code('function(doc,out){out.narration.push(doc);}') + ) + + print query + + audio_query =collection.group( + key = Code('function(doc){return {"xpath" : doc.xpath, "about": doc.url}}'), + condition={"about" : url, "lang" : lang, 'elementtype':"audio/ogg"}, + initial={'narration': []}, + reduce=Code('function(doc,out){out.narration.push(doc);}') + ) + + image_query =collection.group( + key = Code('function(doc){return {"xpath" : doc.xpath, "about": doc.url}}'), + condition={"about" : url, "lang" : lang, 'elementtype':"image"}, + initial={'narration': []}, + reduce=Code('function(doc,out){out.narration.push(doc);}') + ) + try: + for i in audio_query: + query.append(i) + except IndexError: + pass + try: + for i in image_query: + query.append(i) + except IndexError: + pass + + for i in query: + for y in i['narration']: + del(y['_id']) + d = {} + d['r'] = query + response = jsonify(d) + response.headers['Access-Control-Allow-Origin'] = '*' + return response + +@app.route('/feeds', methods=['GET']) +def serve_feed_temp(): + return render_template("feeds.html") + +@app.route('/feed', methods=['GET']) +def serve_feed(): + coll = g.db['post'] + d = {} + cntr = 0 + for i in coll.find().sort('_id',direction=-1): + if i['data'] != '
': + i['_id'] = str(i['_id']) + d[cntr] = i + cntr+=1 + response = jsonify(d) + response.headers['Access-Control-Allow-Origin'] = '*' + return response + +@app.route('/about', methods=['GET']) +def serve_authors(): + coll = g.db['post'] + d = {} + cntr = 0 + for i in coll.find({"about":unquote_plus(request.args['about'])}): + i['_id'] = str(i['_id']) + d[cntr] = i + cntr+=1 + response = jsonify(d) + response.headers['Access-Control-Allow-Origin'] = '*' + return response +#Retrieve all information about a specific $about and a given $author. +@app.route('/author', methods=['GET']) +def serve_author(): + coll = g.db['post'] + d = {} + cntr = 0 + for i in coll.find({"about":unquote_plus(request.args['about']),"author":unquote_plus(request.args['author'])}): + i['_id'] = str(i['_id']) + d[cntr] = i + cntr += 1 + response = jsonify(d) + response.headers['Access-Control-Allow-Origin'] = '*' + return response + +@app.route('/getAllLang', methods=['GET']) +def get_lang(): + term = request.args['term'] + connection = oursql.Connection(conf.DBHOST[0],conf.DBUSRNAME[0],conf.DBPASSWD[0],db=conf.DBNAME[0]) + cursor = connection.cursor(oursql.DictCursor) + cursor.execute('select * from `languages` as l where l.name like ?', (term+'%',)) + r = cursor.fetchall() + connection.close() + d = {} + d['return'] = r + response = jsonify(d) + response.headers['Access-Control-Allow-Origin'] = '*' + return response + + +@app.route("/askSWeeT",methods=['POST']) +def askSweet(): + data = json.loads(request.form['data']) + for i in data: + response = requests.api.get(conf.SWEETURL[0]+"/query/"+i['id']) + collection = g.db['post'] + rep = response.json() + rep['bxpath'] = '' + if response.status_code == 200: + collection.insert(rep) + reply = make_response() + return reply + +@app.route("/menu",methods=['GET']) +def menuForDialog(): + if request.args.has_key('option') == False: + collection = g.db['post'] + c = {} + cntr = 0 + print request.args['url'] + for i in collection.find({"about":request.args['url']}).distinct('lang'): + for j in collection.find({"about":request.args['url'],'lang':i}).distinct('type'): + d = {} + d['lang'] = i + d['type'] = j + c[cntr] = d + cntr += 1 + print c + return jsonify(c) + else: + collection = g.db['post'] + #get the ren languages for the received url + langForUrl = collection.group( + key = Code('function(doc){return {"about" : doc.about}}'), + condition={"about" : d['url'],"blog":{'$regex':'/'+d['option']+'.*/'}}, + initial={'lang': []}, + reduce=Code('function(doc, out){if (out.lang.indexOf(doc.lang) == -1) out.lang.push(doc.lang)}') #here xpath for test + ) + + #send the response + if (langForUrl): + connection.disconnect() + return json.dumps(langForUrl[0]['lang']) + else: + connection.disconnect() + return "empty" + + +@app.route('/info', methods=['GET']) +def serve_info(): + coll = g.db['post'] + d = {} + cntr = 0 + for i in coll.find({"about":unquote_plus(request.args['about']),"lang":request.args['lang']}): + i['_id'] = str(i['_id']) + d[cntr] = i + cntr+=1 + response = jsonify(d) + response.headers['Access-Control-Allow-Origin'] = '*' + return response + + +import logging,os +from logging import FileHandler + +fil = FileHandler(os.path.join(os.path.dirname(__file__),'logme'),mode='a') +fil.setLevel(logging.ERROR) +app.logger.addHandler(fil) + +if __name__ == '__main__': + app.run(debug=True, host='0.0.0.0') diff --git a/alipi/index.html b/alipi/index.html new file mode 100755 index 0000000..5c80edb --- /dev/null +++ b/alipi/index.html @@ -0,0 +1,49 @@ + + + + Alipi + + + + +
+ Enter a URL + + +
+ + diff --git a/alipi/launcher.wsgi b/alipi/launcher.wsgi new file mode 100755 index 0000000..124d43f --- /dev/null +++ b/alipi/launcher.wsgi @@ -0,0 +1,4 @@ +import sys +import os.path +sys.path.insert(0, os.path.dirname(__file__)) +from alipi import app as application diff --git a/alipi/login.js b/alipi/login.js new file mode 100644 index 0000000..469c491 --- /dev/null +++ b/alipi/login.js @@ -0,0 +1,309 @@ +/* Copyright (c) 2007 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @fileoverview Sample code for Blogger's JavaScript client library. + * Provides an embeded blog post editor which grabs the title and location + * of the current page for promotion on a user's blog. + * @author api.jscudder@gmail.com (Jeffrey Scudder) + */ + +// Load the Google data Blogger JavaScript library. +google.load('gdata', '2.x', {packages: ['blogger']}); +google.setOnLoadCallback(addEditorToPage); + +// Global object to hold constants and "global" variables. +var blogThis = { + // URL constants. + BLOG_LIST_URL: 'https://www.blogger.com/feeds/default/blogs', + AUTH_URL: 'https://www.blogger.com/feeds', + // Document element ID constants. + SAMPLE_CONTAINER: 'blog_this', + POST_BODY_INPUT: 'blog_post_body', + EDITOR_DIV: 'blog_this_div', + LOGIN_BUTTON: 'login_button', + BLOG_SELECTOR: 'available_blogs', + TITLE_INPUT: 'blog_post_title', + TAGS_INPUT: 'blog_post_tags', + RESULT_DIV: 'status_display' +}; + +/** + * Simple error handler which displays the error in an alert box. + * @param {Object} e An error passed in from the google.gdata.service + * object when the HTTP call failed. + */ +function handleError(e) { + var statusDiv = document.getElementById(blogThis.RESULT_DIV); + statusDiv.appendChild(document.createTextNode('Error: ' + + (e.cause ? e.cause.statusText : e.message))); + statusDiv.appendChild(document.createElement('br')); +}; + +/** + * Performs HTML escapes on special characters like double quotes, + * less-than, greater-than, and the ampersand. This function is used + * on the page title to ensure that special characters do not lead to + * invalid HTML when it is included in the atom:content. + * I recommend using something like this on any text that you want + * to be treated as plaintext within HTML content. + * @param {String} inputString The string which will be scrubbed. + * @return {String} The input string with special characters replaced + * by their HTML-safe equivalents. + */ +function htmlEscape(inputString) { + return inputString.replace(/&/g, '&').replace(/"/g, '"' + ).replace(//g, '>'); +}; + +/** + * Adds the HTML for the login and blog post editor to the sample + * container div. It also populates the contents of the blog post edit form + * with a link to the current page. The current page's title is used as the + * anchor text. + */ +function addEditorToPage() { + var sampleContainerDiv = document.getElementById(blogThis.SAMPLE_CONTAINER); + sampleContainerDiv.innerHTML = [ + '
', + ' ', + '
', + '', + '
'].join(''); + + // Create the Blogger client object which talks to the blogger servers. + blogThis.service = new google.gdata.blogger.BloggerService( + 'GoogleInc-blogThisEmbeddedEditor-1') + // Get the title and address of the current page. + var currentPageUrl = window.location.href; + var pageTitle = document.title; + // Set the contents of the body input field. + var blogPostBody = document.getElementById(blogThis.POST_BODY_INPUT); + // blogPostBody.value = ['',htmlEscape(pageTitle), ''].join(''); + y = localStorage.myContent.split('###'); + abc = []; + for(var i=0;i',decodeURIComponent(abc[i].data),decodeURIComponent(abc[i].about),decodeURIComponent(abc[i].xpath),decodeURIComponent(abc[i].lang),decodeURIComponent(abc[i].elementtype),decodeURIComponent(abc[i].location),decodeURIComponent(abc[i].author),decodeURIComponent(abc[i].style)); + postData = postData + aud + '
'; + } + else if(abc[i].elementtype.match('image')) + { + var width = decodeURIComponent(abc[i].data).split(',')[0].split('x')[0]; + var height = decodeURIComponent(abc[i].data).split(',')[0].split('x')[1]; + var img = sprintf('',decodeURIComponent(abc[i].data).split(',')[1],decodeURIComponent(abc[i].about),decodeURIComponent(abc[i].xpath),decodeURIComponent(abc[i].lang),decodeURIComponent(abc[i].elementtype),decodeURIComponent(abc[i].location),decodeURIComponent(abc[i].author),decodeURIComponent(abc[i].style),height, width); + postData =postData + img + '
'; + } + else + { + var p = sprintf('

%s

',decodeURIComponent(abc[i].about),decodeURIComponent(abc[i].xpath),decodeURIComponent(abc[i].lang),decodeURIComponent(abc[i].elementtype),decodeURIComponent(abc[i].location),decodeURIComponent(abc[i].author),decodeURIComponent(abc[i].style),decodeURIComponent(abc[i].data)); + postData = postData + p + '
'; + } + } + blogPostBody.innerHTML = postData; + determineEditorVisibility(); +}; + +/** + * Populates the contents of the blog post edit form with a link to the + * current page. The current page's title is used as the anchor text. + */ +function initializeBlogPostInput() { + // Create the Blogger client object which talks to the blogger servers. + blogThis.service = new google.gdata.blogger.BloggerService( + 'GoogleInc-blogThisEmbeddedEditor-1') + // Get the title and address of the current page. + var currentPageUrl = window.location.href; + var pageTitle = document.title; + // Set the contents of the body input field. + var blogPostBody = document.getElementById(blogThis.POST_BODY_INPUT); + blogPostBody.value = ['', + htmlEscape(pageTitle), ''].join(''); + determineEditorVisibility(); +}; + +/** + * Makes the blog post editor div visible if the user is authenticated. If + * the user is not authenticated with Blogger, the editor div is hidden + * and the login button is made visible. + */ +function determineEditorVisibility() { + var blogThisDiv = document.getElementById(blogThis.EDITOR_DIV); + var loginButton = document.getElementById(blogThis.LOGIN_BUTTON); + if (google.accounts.user.checkLogin(blogThis.AUTH_URL)) { + // If the user is logged in, show the blow editor. + blogThisDiv.style.display = 'inline'; + loginButton.style.display = 'none'; + // Request the feed to populate the editor's blog selection menu. + blogThis.service.getBlogFeed(blogThis.BLOG_LIST_URL, receiveBlogList, + handleError); + } else { + // The user cannot get a list of blogs, so display the login button. + blogThisDiv.style.display = 'none'; + loginButton.style.display = 'inline'; + } +}; + +/** + * Requests an AuthSub token for interaction with the Calendar service. + */ +function login() { + var token = google.accounts.user.login(blogThis.AUTH_URL); + determineEditorVisibility(); +}; + +/** + * Creates options in the blog editor's drop down blog selector box. + * This method receives the results of a query for a list of the current + * viewer's blogs. + * @param {Object} blogList An object containing a + * google.gdata.blogger.BlogFeed. + */ +function receiveBlogList(blogList) { + // Clear any existing options from the blog selector. + var selector = document.getElementById(blogThis.BLOG_SELECTOR); + selector.innerHTML = ''; + // Find the titles and post links for each blog and populate the + // blog select options. + var numBlogs = blogList.feed.getEntries().length; + var newOption; + for (var i = 0, entry; entry = blogList.feed.getEntries()[i]; ++i) { + newOption = document.createElement('option'); + newOption.value = entry.getEntryPostLink().href; + newOption.appendChild(document.createTextNode( + entry.getTitle().getText())); + // Add this as an option to the blog selector. + selector.appendChild(newOption); + } +}; + +/** + * Revokes the authentication token for this application. + * The editor div is then hidden and the login button is displayed. + */ +function logout() { + google.accounts.user.logout(); + // Hide the editor div and make the login button visible. + var blogThisDiv = document.getElementById(blogThis.EDITOR_DIV); + var loginButton = document.getElementById(blogThis.LOGIN_BUTTON); + blogThisDiv.style.display = 'none'; + loginButton.style.display = 'inline'; +}; + +/** + * Reads the contents of the blog post editor and sends it to the Blogger + * servers as a new blog post. + */ +function insertBlogEntry() { + // Find the target blog and the post URL. + var blogSelector = document.getElementById(blogThis.BLOG_SELECTOR); + var targetUrl = blogSelector.options[blogSelector.selectedIndex].value; + // Create event. + var blogPost = new google.gdata.blogger.PostEntry(); + // Add title - from the input field. + var title = document.getElementById(blogThis.TITLE_INPUT).value; + blogPost.setTitle(google.gdata.atom.Text.create(title)); + // Get the body from the input field. + var body = document.getElementById(blogThis.POST_BODY_INPUT).innerHTML; + // Set the content to be the body of the input form and tell the server + // to interpret it as html. + blogPost.setContent(google.gdata.atom.Text.create(body, 'html')); + // Read the tags from the input form and add them as categories to + // the blog post entry. + var tags = document.getElementById(blogThis.TAGS_INPUT).value; + var tagList = tags.split(','); + for (var i = 0, tag; tag = tagList[i]; ++i) { + blogPost.addCategory(new google.gdata.atom.Category( + {'scheme':'http://www.blogger.com/atom/ns#', + // Remove leading and trailing whitespace from the tag text. + // If the tag begins or ends with whitespace, the Blogger server + // will remove the whitespace but send back 2 category elements, + // one with the original term, and another with the stripped term. + 'term':tag.replace(/^\s+/g, '').replace(/\s+$/g, '')})); + } + blogThis.service.insertEntry(targetUrl, blogPost, handlePostSuccess, + handleError); +}; + +/** + * Displays the contents of the new blog post after the Blogger server + * responds to the POST request. + * @param {Object} newBlogPost An object containing the + * google.gdata.blogger.BlogPostEntry sent back from the server. + */ +function handlePostSuccess(newBlogPost) { + // Get the div which displays the posted blog entries. + var resultDiv = document.getElementById(blogThis.RESULT_DIV); + resultDiv.appendChild( + document.createTextNode('Your post about this page:')); + resultDiv.appendChild(document.createElement('br')); + + // Create a link to the blog post with the post's title as the anchor + // text. + var titleElement = document.createElement('a'); + titleElement['href'] = newBlogPost.entry.getHtmlLink().href; + titleElement.appendChild( + document.createTextNode(newBlogPost.entry.getTitle().getText())); + + var bodyElement = document.createElement('
'); + // Displays the source HTML of the post's body. To display the actual + // HTML (render it instead of displaying the source text) you could + // set the innerHTML of the body element instead of creating a text + // node. + bodyElement.innerHTML = newBlogPost.entry.getContent().getText(); + + // Display the tags for this entry in a paragraph below the body. + var tagsElement = document.createElement('p'); + var myTagsList = []; + var categories = newBlogPost.entry.getCategories(); + for (var i = 0, category; category = newBlogPost.entry.getCategories()[i]; ++i) { + myTagsList.push(category.term); + } + tagsElement.appendChild(document.createTextNode(myTagsList.join(', '))); + + resultDiv.appendChild(titleElement); + resultDiv.appendChild(bodyElement); + resultDiv.appendChild(tagsElement); + + var xhr = new XMLHttpRequest(); + xhr.open('POST','http://dev.a11y.in/scrape',true) + xhr.send('url='+newBlogPost.entry.getHtmlLink().href); +}; + diff --git a/alipi/sampleConf.py b/alipi/sampleConf.py new file mode 100644 index 0000000..469c4b1 --- /dev/null +++ b/alipi/sampleConf.py @@ -0,0 +1,8 @@ +#This is a samply config file. Create a file named conf.py,in this directory, and decalre the following variables there. +#DO NOT EDIT THIS FILE. This file is not read for config changes +APPURL = ('http://foo/bar',) # The path which points to "alipi" directory. +JQUERYURL = ('http://foo.jquery',) #URL for jquery. +PASSWD = ('password',) +BLOGURL = ('http://something.blogspot.com',) +EMAIL = ('johnDoe@gmail.com',) +DEPLOYURL = ('http://127.0.0.1:5000/',) diff --git a/alipi/sampleConfig.js b/alipi/sampleConfig.js new file mode 100644 index 0000000..f17e40f --- /dev/null +++ b/alipi/sampleConfig.js @@ -0,0 +1,6 @@ +//A sample configuration file for JS variables. Copy this file to "config.js" +var config = { + 'hostname': "127.0.0.1", + 'deploy': "http://127.0.0.1:5000", + 'root': "http://localhost" +} \ No newline at end of file diff --git a/alipi/stylesheet.css b/alipi/stylesheet.css new file mode 100755 index 0000000..8c47ea6 --- /dev/null +++ b/alipi/stylesheet.css @@ -0,0 +1,214 @@ +@media screen and (min-width:1000px) { + +#renarrated_overlay { position:fixed; left:0.5%; width:99%; text-align:center; font-weight:normal; z-index:2147483645; display:block; } + +#edit-current { font-size:17px; font-weight:400; font-style:italic; text-align:justify; display:none; } +#see-narration { font-size:17px; font-weight:400; font-style:italic; text-align:justify; display:none; } +#see-links { font-size:17px; font-weight:400; font-style:italic; text-align:justify; display:none; } +#blog-filter { right:-3px; min-width:225px; max-width:225px; font-size:17px; font-weight:400; font-style:italic; + -moz-border-radius-bottomright:0px; -webkit-border-bottom-right-radius:0px; border-bottom-right-radius:0px; + -moz-border-radius-topright:0px; -webkit-border-top-right-radius:0px; border-top-right-radius:0px; -moz-margin-start:7px; + text-align:center; display:none; } +@-moz-document domain(127.0.0.1), domain(dev.a11y.in), domain(y.a11y.in) { + #go { top:11px !important; } +} +#go { top:6px; height:25px; text-align:justify; display:none; + -moz-border-radius-bottomleft:0px; -webkit-border-bottom-left-radius:0px; border-bottom-left-radius:0px; + -moz-border-radius-topleft:0px; -webkit-border-top-left-radius:0px; -khtml-border-top-left-radius:0px; border-top-left-radius:0px; } + +#share { font-size:17px; font-weight:400; font-style:italic; text-align:justify; display:none; } +#orig-button { font-size:17px; font-weight:400; font-style:italic; text-align:justify; display:none; } +#info { font-size:17px; font-weight:400; font-style:italic; text-align:justify; display:none; } + +#outter-down-button { font-size:17px; font-weight:400; font-style:italic; text-align:justify; display:none; } +#outter-up-button { font-size:17px; font-weight:400; font-style:italic; text-align:justify; display:none; } + +#pub_overlay { position:fixed; left:10%; width:80%; text-align:center; z-index:2147483645; display:none; } +#pub_overlay .ui-button { margin-left:10px; } + +#icon-down { font-size:17px; font-weight:400; font-style:italic; text-align:justify; display:none; } +#icon-up { font-size:17px; font-weight:400; font-style:italic; text-align:justify; display:none; } +#exit-mode { font-size:17px; font-weight:400; font-style:italic; text-align:justify; } +#help-window { font-size:17px; font-weight:400; font-style:italic; text-align:justify; } +#undo-button { font-size:17px; font-weight:400; font-style:italic; text-align:justify; } +#publish-button { font-size:17px; font-weight:400; font-style:italic; text-align:justify; } + +#element_edit_overlay { position:fixed; text-align:center; z-index:2147483645; display:none; } + +#edit-text { font-size:17px; font-weight:400; font-style:italic; text-align:justify; display:none; } +#add-audio { font-size:17px; font-weight:400; font-style:italic; text-align:justify; display:none; } +#replace-image { font-size:17px; font-weight:400; font-style:italic; text-align:justify; display:none; } +#delete-image { font-size:17px; font-weight:400; font-style:italic; text-align:justify; display:none; } +#close-element { position:absolute; top:-5px; left:-2px; width:10px; font-size:17px; font-weight:400; font-style:italic; text-align:justify; } +#cant-edit { width: 450px; margin:15px; font-size:17px; font-weight:400; font-style:italic; text-align:justify; display:none; } + +#editoroverlay { min-width:90%; text-align:justify; display: none; } +#editoroverlay a { color:#1C94C4; } + +#adv-reference { position: absolute; top:15%; left:2%; min-width:48%; max-width:48%; border:solid 3px; padding:10px; font-size:16px; + font-weight:400; font-style:normal; color:#aaa; overflow:show; background:none; text-align:justify; display:none; } + +#reference { position: absolute; top: 15%; left:2%; min-width:46%; max-width:46%; min-height:10%; border:solid 3px; padding:10px; font-size:17px; + font-weight:400; font-style:normal; text-align:justify; color:#aaa; overflow:show; background:none; text-align:justify; } + +#editor { position:absolute; top:15%; left:52%; min-width:45%; max-width:45%; min-height:10%; border:3px solid #aaa; padding:10px; font-size:17px; + font-weight:400; font-style:normal; text-align:justify; color:#000; background-color:#ffe; text-align:justify; } + +#ref-lab { position:absolute; top:5%; font-size:17px; font-weight:400; font-style:italic; color:#aaa; text-align:justify; } +#edit-lab { position:absolute; top:5%; font-size:17px; font-weight:400; font-style:italic; color:#aaa; text-align:justify; } + +#close-adv { position:absolute; top:7%; right:51%; font-size:17px; font-weight:400; font-style:italic; text-align:justify; } +#adv-ref { position:absolute; top:7%; right:51%; font-size:17px; font-weight:400; font-style:italic; text-align:justify; } + +#mag-demag { position:absolute; bottom:5%; left:10%; font-size:17px; font-weight:400; font-style:italic; text-align:justify; } +#mag { position:absolute; left:3%; font-size:17px; font-weight:400; font-style:italic; text-align:justify; } +#demag { position:absolute; left:30%; font-size:17px; font-weight:400; font-style:italic; text-align:justify; } +#add-link { position:absolute; left:54%; font-size:17px; font-weight:400; font-style:italic; text-align:justify; } + +#save-changes { position:relative; font-size:17px; font-weight:400; font-style:italic; text-align:justify; } + +.highlightElement { box-shadow: 0 0 20px #000; } +.highlightOnSelect { box-shadow: 0 0 50px #000; } + +.barOnBottom { bottom:0px; } +.barOnTop { top:0px; } + +#tar-lab1 { position:absolute; top:5%; left:110px; font-size:17px; font-weight:400; font-style:italic; color:#aaa; text-align:justify; } +#tar-lab2 { position:absolute; top:20%; left:125px; font-size:17px; font-weight:400; font-style:italic; color:#aaa; text-align:justify; } +#tar-lab3 { position:absolute; top:35%; left:125px; font-size:17px; font-weight:400; font-style:italic; color:#aaa; text-align:justify; } +#tar-lab4 { position:absolute; top:50%; left:125px; font-size:17px; font-weight:400; font-style:italic; color:#aaa; text-align:justify; } +#tar-lab5 { position:absolute; top:65%; left:125px; font-size:17px; font-weight:400; font-style:italic; color:#aaa; text-align:justify; } +#tar-lab6 { position:relative; font-size:17px; font-weight:400; font-style:italic; color:#aaa; text-align:justify; } +#tar-lab7 { position:relative; font-size:17px; font-weight:400; font-style:italic; color:#aaa; text-align:justify; } +#tar-p { position:absolute; top:90%; left:210px; font-size:17px; font-weight:400; font-style:italic; text-align:justify; } +#blogset { position:absolute; top:80%; right:100px; left:125px; font-size:17px; font-weight:400; font-style:italic; color:#aaa; text-align:justify; } + + +#loc-select { position:absolute; top:25%; left:210px; width:256px; font-size:17px; font-weight:400; font-style:italic; color:#000; text-align:justify; } +#loc-img { position:absolute; top:25.5%; left:440px; height:20px; width:25px; font-size:17px; font-weight:400; font-style:italic; + color:#000; text-align:justify; display:none; } +#lang-select { position:absolute; top:40%; left:210px; width:256px; font-size:17px; font-weight:400; font-style:italic; color:#000; text-align:justify; } +#lang-img { position:absolute; top:41%; left:440px; height:18px; width:25px; font-size:17px; font-weight:400; font-style:italic; + color:#000; text-align:justify; display:none; } +#style-select { position:absolute; top:55%; left:210px; width:256px; font-size:17px; font-weight:400; font-style:italic; color:#000; text-align:justify; } +#auth-select { position:absolute; top:70%; left:210px; width:256px; font-size:17px; font-weight:400; font-style:italic; color:#000; text-align:justify; } + +#our-check { position:relative; } +#your-check { position:relative; margin-left:25px; } + +} +/****************************************************************************************************************************/ + +@media screen and (max-width:1000px) { + +#renarrated_overlay { position:fixed; clear:both; width:99%; left:0.5%; text-align:center; z-index:2147483645; font-size:80%; display:block; } +/* #renarrated_overlay .ui-button { padding:0.1em 0.8em 0.2em 0.8em; } */ + +#edit-current { font-size:14px; font-weight:200; font-style:italic; text-align:justify; display:none; } +#see-narration { font-size:14px; font-weight:200; font-style:italic; text-align:justify; display:none; } +#see-links { font-size:14px; font-weight:200; font-style:italic; text-align:justify; display:none; } +#blog-filter { right:-3px; min-width:150px; max-width:150px; font-weight:200; font-style:italic; text-align:justify; display:none; + -moz-border-radius-bottomright:0px; -webkit-border-bottom-right-radius:0px; border-bottom-right-radius:0px; + -moz-border-radius-topright:0px; -webkit-border-top-right-radius:0px; border-top-right-radius:0px; } +#go { top:5px; height:18px; -moz-border-radius-bottomleft:0px; -webkit-border-bottom-left-radius:0px; -khtml-border-bottom-left-radius:0px; + border-bottom-left-radius:0px; -moz-border-radius-topleft:0px; -webkit-border-top-left-radius:0px; -khtml-border-top-left-radius:0px; + border-top-left-radius:0px; font-size:14px; font-weight:200; font-style:italic; text-align:justify; display:none; } +@-moz-document domain(127.0.0.1), domain(dev.a11y.in), domain(y.a11y.in) { + #go { height:23px !important; top:4px !important; } +} +#share { font-size:14px; font-weight:200; font-style:italic; text-align:justify; display:none; } +#orig-button { font-size:14px; font-weight:200; font-style:italic; text-align:justify; display:none; } +#info { font-size:14px; font-weight:200; font-style:italic; text-align:justify; display:none; } + +#outter-down-button { font-size:14px; font-weight:200; font-style:italic; text-align:justify; display:none; } +#outter-up-button { font-size:14px; font-weight:200; font-style:italic; text-align:justify; display:none; } + + +#pub_overlay { position:fixed; left:3%; width:96%; text-align:center; z-index:2147483645; font-size:14px; font-weight:200; font-style:italic; + display:none; } +#pub_overlay .ui-button { margin-left:10px; } +#icon-down { font-size:14px; font-weight:200; font-style:italic; text-align:justify; display:none; } +#icon-up { font-size:14px; font-weight:200; font-style:italic; text-align:justify; display:none; } +#exit-mode { font-size:14px; font-weight:200; font-style:italic; text-align:justify; } +#help-window { font-size:14px; font-weight:200; font-style:italic; text-align:justify; } +#undo-button { font-size:14px; font-weight:200; font-style:italic; text-align:justify; } +#publish-button { font-size:14px; font-weight:200; font-style:italic; text-align:justify; } + +#element_edit_overlay { position:fixed; text-align:center; z-index:2147483645; font-size:14px; font-weight:200; font-style:italic; + text-align:justify; display:none; } +#element_edit_overlay .ui-button { text-align:justify; font-size:14px; font-weight:200; font-style:italic; } + +#edit-text { text-align:justify; font-size:14px; font-weight:200; font-style:italic; text-align:justify; display:none; } +#add-audio { text-align:justify; font-size:14px; font-weight:200; font-style:italic; text-align:justify; display:none; } +#replace-image { text-align:justify; font-size:14px; font-weight:200; font-style:italic; text-align:justify; display:none; } +#delete-image { text-align:justify; font-size:14px; font-weight:200; font-style:italic; text-align:justify; display:none; } +#close-element { position:absolute; top:-5px; left:-2px; width:10px; font-size:14px; font-weight:200; font-style:italic; text-align:justify; } +#cant-edit { width: 450px; margin:15px; display:none; font-size:14px; font-weight:200; font-style:italic; text-align:justify; } + +#editoroverlay { min-width:90%; display: none; } +#editoroverlay a { color:#1C94C4; } + +#adv-reference { position: absolute; top: 24%; left:2%; min-width:48%; max-width:48%; border:solid 2px; padding:10px; font-size:13px; + text-align:justify; color:#aaa; font-weight:normal; overflow:show; background:none; display:none; } +#reference { position: absolute; top: 24%; left:2%; min-width:46%; max-width:46%; min-height:10%; border:solid 2px; padding:10px; font-size:14px; + text-align:justify; color:#aaa; font-weight:normal; overflow:show; background:none; } + +#editor { position:absolute; top:15%; left:52%; min-width:45%; max-width:45%; min-height:10%; border:2px solid; padding:10px; color:#000; + background-color:#ffe; font-size:14px; font-weight:200; font-style:normal; text-align:justify; } + +#ref-lab { position:absolute; top:5%; font-size:14px; font-weight:200; font-style:italic; text-align:justify; color:#aaa; } +#edit-lab { position:absolute; top:5%; font-size:14px; font-weight:200; font-style:italic; text-align:justify; color:#aaa; } + +#close-adv { position:absolute; top:10%; right:50%; font-size:14px; font-weight:200; font-style:italic; text-align:justify; } +#adv-ref { position:absolute; top:10%; right:50%; font-size:14px; font-weight:200; font-style:italic; text-align:justify; } + +#mag-demag { position:absolute; bottom:8%; left:10%; font-size:14px; font-weight:200; font-style:italic; text-align:justify; } +#mag { position:absolute; left:3%; font-size:14px; font-weight:200; font-style:italic; text-align:justify; } +#demag { position:absolute; left:30%; font-size:14px; font-weight:200; font-style:italic; text-align:justify; } +#add-link { position:absolute; left:54%; font-size:14px; font-weight:200; font-style:italic; text-align:justify; } + +#save-changes { position:relative; font-size:14px; font-weight:200; font-style:italic; text-align:justify; } + +.highlightElement { box-shadow: 0 0 20px #000; } +.highlightOnSelect { box-shadow: 0 0 50px #000; } + +.barOnBottom { bottom:0px; } +.barOnTop { top:0px; } + +#tar-lab1 { position:absolute; top:5%; left:110px; color:#aaa; font-size:14px; font-weight:200; font-style:italic; text-align:justify; } +#tar-lab2 { position:absolute; top:20%; left:125px; color:#aaa; font-size:14px; font-weight:200; font-style:italic; text-align:justify; } +#tar-lab3 { position:absolute; top:35%; left:125px; color:#aaa; font-size:14px; font-weight:200; font-style:italic; text-align:justify; } +#tar-lab4 { position:absolute; top:50%; left:125px; color:#aaa; font-size:14px; font-weight:200; font-style:italic; text-align:justify; } +#tar-lab5 { position:absolute; top:65%; left:125px; color:#aaa; font-size:14px; font-weight:200; font-style:italic; text-align:justify; } +#tar-lab6 { position:relative; color:#aaa; font-size:14px; font-weight:200; font-style:italic; text-align:justify; } +#tar-lab7 { position:relative; color:#aaa; font-size:14px; font-weight:200; font-style:italic; text-align:justify; } +#tar-p { position:absolute; top:90%; left:210px; font-size:14px; font-weight:200; font-style:italic; text-align:justify; } +#blogset { position:absolute; top:80%; left:125px; right:80px; color:#aaa; font-size:14px; font-weight:200; font-style:italic; text-align:justify; } + +#loc-select { position:absolute; top:25%; left:210px; width:256px; color:#000; font-size:14px; font-weight:200; font-style:italic; text-align:justify; } +#loc-img { position:absolute; top:25.5%; left:440px; height:20px; width:25px; color:#000; font-size:14px; font-weight:200; font-style:italic; + text-align:justify; display:none; } +#lang-select { position:absolute; top:40%; left:210px; width:256px; color:#000; font-size:14px; font-weight:200; font-style:italic; text-align:justify; } +#lang-img { position:absolute; top:41%; left:440px; height:18px; width:25px; color:#000; font-size:14px; font-weight:200; font-style:italic; + text-align:justify; display:none; } +#style-select { position:absolute; top:55%; left:210px; width:256px; color:#000; font-size:14px; font-weight:200; font-style:italic; text-align:justify; } +#auth-select { position:absolute; top:70%; left:210px; width:256px; color:#000; font-size:14px; font-weight:200; font-style:italic; text-align:justify; } + +#our-check { position:relative; } +#your-check { position:relative; margin-left:25px;} + +} +/************************************************************** +************************************************************************************************************/ + +#infovis { position:absolute; top:3%; left:0%; width:60%; height:95%; overflow:hidden; } +#infovis-canvaswidget { height:95% } +#infovis-canvas { height:95% } + +#infonar { position:relative; top:2%; left:0; width:35%; height:90%; overflow:show; } +#narrations-div { position:fixed; top:5%; bottom:2%; right:0.1%; width:30%; height:93%; overflow:show; background-color: rgba(0,0,0,0.5); + z-index:999999999; } +/*TOOLTIPS*/ +.tip { color: #fff; width: 140px; background-color: rgba(0,0,0,1); border:1px solid #ccc; -moz-box-shadow:#555 2px 2px 8px; + -webkit-box-shadow:#555 2px 2px 8px; -o-box-shadow:#555 2px 2px 8px; box-shadow:#555 2px 2px 8px; opacity:1; font-size:12px; + font-family:Verdana, Geneva, Arial, Helvetica, sans-serif; padding:7px; } diff --git a/alipi/templates/blank.html b/alipi/templates/blank.html new file mode 100644 index 0000000..b2f39a7 --- /dev/null +++ b/alipi/templates/blank.html @@ -0,0 +1,62 @@ + + + + + + + +
Collecting data, Please have patience
+
+ + + + + diff --git a/alipi/templates/directory.html b/alipi/templates/directory.html new file mode 100644 index 0000000..a4b5990 --- /dev/null +++ b/alipi/templates/directory.html @@ -0,0 +1,22 @@ + + +Directory of Alipi + +
+

List of links narrated

+{% if name %} +{% for i in name %} +{% if i['about'] != 'undefined' %} +

{{ i['about'] }} in {{i['lang']}}

+

Narrations contributed at:

+{% for x in mylist(myset(i['na'])) %} +

{{x}}

+{% endfor %} +{% endif %} +{% endfor %} +{% else %} +

Hello world

+{% endif %} +
+ + diff --git a/alipi/templates/error.html b/alipi/templates/error.html new file mode 100644 index 0000000..168d6f4 --- /dev/null +++ b/alipi/templates/error.html @@ -0,0 +1,6 @@ + +Error + +

Please check the URL you entered, maybe you have misspelled it.

+ + diff --git a/alipi/templates/feeds.html b/alipi/templates/feeds.html new file mode 100644 index 0000000..105ff6b --- /dev/null +++ b/alipi/templates/feeds.html @@ -0,0 +1,67 @@ + + + + + + + + @ says has at in targetting +
+
+ + + diff --git a/alipi/ui.js b/alipi/ui.js new file mode 100644 index 0000000..3240b8c --- /dev/null +++ b/alipi/ui.js @@ -0,0 +1,1024 @@ +//-*-coding: utf-8 -*- +var a11ypi = { + auth : " ", + loc:" ", + elementTagName: " ", + elementId: " ", + flag : 0, + fflag : 0, + showbox : 0, + showlinks : 0, + blog_flag: false, + target : false, + pageHtml:'', + d: {}, + responseJSON:'', + testContext : function() + { + if(document.getElementById('social_overlay') != null) + document.body.removeChild(document.getElementById('social_overlay')); + $(document).ready(function(){$('body *').contents().filter(function() + { + try{ + if(this.nodeType == 3 && !($(this).hasClass('alipi'))) + { + return (this.nodeType == 3) && this.nodeValue.match(/\S/);}} + catch(err) + { + }}).parent().attr('m4pageedittype','text')}); + + vimg = document.getElementsByTagName('img'); + for(i=0; i'; + $(result).before(audio); + result.setAttribute('class','blink'); + } + else{ + result.innerHTML = a['data']; + result.setAttribute('class','blink'); + } + result=nodes.iterateNext(); + } + } + catch (e) + { + // dump( 'error: Document tree modified during iteration ' + e ); + } + } + else if(a['type']=='5el') + { + + try{ + var result = nodes.iterateNext(); + while (result) + { + $(result).html($(result).html()+a['data']); + $(result).get(0).scrollIntoView(); + result=nodes.iterateNext(); + } + } + catch (e) + { + //dump( 'error: Document tree modified during iteration ' + e ); + } + } + }, + filter: function() + { + var xhr = new XMLHttpRequest(); + xhr.onreadystatechange = function() + { + if(xhr.readyState == 4) + { + if(xhr.responseText =='empty') + { + // a11ypi.clearMenu(); + // alert("An internal server error occured, please try later."); + } + else + { + + d ={}; + var response=xhr.responseText.substring(3).split('###'); + for (var j= 0; j< response.length ; j++){ + chunk = response[j].substring(1).split('&'); + + for (var i= 0; i< chunk.length ; i++){ + pair =chunk[i].split("::"); + key = pair[0]; + value = pair[1]; + d[key] = value; + } + path = d['xpath']; + newContent = d['data']; + elementType = d['elementtype']; + a11ypi.evaluate(path,newContent,elementType); + } + } + } + } + a = a11ypi.getParams(); + var url = a['foruri']; + var lang= a['lang']; + var blog= a['blog']; + var data="url="+url+"&lang="+encodeURIComponent(lang)+"&blog="+encodeURIComponent(blog); + + xhr.open("POST",config.root+"/filter",true); + xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); + xhr.send(data);// + }, + createMenuFilter: function(menu_list) { + var xyz = document.getElementById("show-box"); + xyz.innerHTML = ''; + d = window.location.search.split('?')[1]; + a = a11ypi.getParams(); + var page = a['foruri']; + var blog = a['blog']; + for(var i=0;iMove '+ + ' '+ + ' '+ + ''+ + // ''+ + ''+ + ''+ + ''+ + '
'+ + '
'+ + ' '+ + '
'; + + var pub_overlay_template = '
'+ + ''+ //▲ + ''+ //▼ + ''+ + ''+ + ''+ + '
'; + + var element_edit_overlay_template = '
'+ + ''+ + ''+ + ''+ + ''+ + ''+ + ' '+ + '
'; + + $('body').append(overlay_template); + $('body').append(pub_overlay_template); + $('body').append(element_edit_overlay_template); + + $('#outter-up-button').show(); + $('#go').button({disabled : true}); + $('#undo-button').button({ disabled: true}); + $('#publish-button').button({ disabled: true}); + $('input:.alipi, select:.alipi').button(); + + $("#outter-down-button").button({icons:{primary:"ui-icon-circle-arrow-n"},text:false}); $('#outter-down-button').children().addClass('alipi'); + $("#outter-up-button").button({icons:{primary:"ui-icon-circle-arrow-s"},text:false}); $('#outter-up-button').children().addClass('alipi'); + $("#edit-current").button({icons:{primary:"ui-icon-pencil"}}); $('#edit-current').children().addClass('alipi'); + $("#see-narration").button({icons:{primary:"ui-icon-document-b"}}); $('#see-narration').children().addClass('alipi'); + $("#see-comment").button({icons:{primary:"ui-icon-document-b"}}); $('#see-comment').children().addClass('alipi'); + $("#see-links").button({icons:{primary:"ui-icon-link"}}); $('#see-links').children().addClass('alipi'); + /*$("#blog-filter").button({icons:{secondary:"ui-icon-triangle-1-s"}}); */ $('#blog-filter').children().addClass('alipi'); + $("#go").button({icons:{primary:"ui-icon-arrowthick-1-e"},text:false}); $('#go').children().addClass('alipi'); + $("#share").button({icons:{primary:"ui-icon-signal-diag"}}); $('#share').children().addClass('alipi'); + $("#orig-button").button({icons:{primary:"ui-icon-extlink"}}); $('#orig-button').children().addClass('alipi'); + $("#info").button({icons:{primary:"ui-icon-info"}}); $('#info').children().addClass('alipi'); + + $("#icon-up").button({icons:{primary:"ui-icon-circle-arrow-n"},text:false}); $('#icon-up').children().addClass('alipi'); + $("#icon-down").button({icons:{primary:"ui-icon-circle-arrow-s"},text:false}); $('#icon-down').children().addClass('alipi'); + $("#exit-mode").button({icons:{primary:"ui-icon-power"}}); $('#exit-mode').children().addClass('alipi'); + $("#help-window").button({icons:{primary:"ui-icon-help"}}); $('#help-window').children().addClass('alipi'); + $("#undo-button").button({icons:{primary:"ui-icon-arrowreturnthick-1-w"}}); $('#undo-button').children().addClass('alipi'); + $("#publish-button").button({icons:{primary:"ui-icon-circle-check"}}); $('#publish-button').children().addClass('alipi'); + + $("#edit-text").button({icons:{primary:"ui-icon-pencil"}}); $('#edit-text').children().addClass('alipi'); + $("#add-audio").button({icons:{primary:"ui-icon-circle-plus"}}); $('#add-audio').children().addClass('alipi'); + $("#replace-image").button({icons:{primary:"ui-icon-transferthick-e-w"}}); $('#replace-image').children().addClass('alipi'); + $("#delete-image").button({icons:{primary:"ui-icon-trash"}}); $('#delete-image').children().addClass('alipi'); + $("#close-element").button({icons:{primary:"ui-icon-circle-close"},text:false}); $("#close-element").children().addClass('alipi'); + + $('#renarrated_overlay').addClass('barOnTop'); + a11ypi.ajax(); + a11ypi.ajaxLinks1(); + $('#edit-current').show(); + + d = window.location.search.split('?')[1]; + var a =[]; + for (var i = 0;iTEXT :- It will popup a '+ + 'window and allow you to modify/replace text of select element on editor(right) box.'+ + '

To delete - Empty the editor(right) box and press "Save changes".'+ + '

Add Audio - It allows you to '+ + 'enter audio URL.

IMAGE:-

Replace - It allows you to enter '+ + 'image URL.

UNDO:- Use it when you want to revert back to '+ + 'previous change.'+ + 'PUBLISH:- To publish your crafted changes to database and blog (Alipi/Personal).'+ + '

States - The place you are targetting to.

Languages - In language you publishing.

Style - In what style you crafted?

'+ + 'Author - Who is a crafter?

'+ + 'Alipi blog - If you don\'t have blogspot ID then check this to post it to our blog.

'; + + $('body').append(help_template); + $(document).unbind('mouseover'); // Unbind the css on mouseover + $(document).unbind('mouseout'); // Unbind the css on mouseout + + $(function() { + $( "#helpwindow" ).dialog({ + width:800, + height:550, + modal: true, + close: function() { + $("#helpwindow").remove(); + } + }); + }); + }, + + exitMode: function() { + var exit = window.confirm("Do you really want to exit from edit mode?"); + if (exit == true) { + window.location.reload(); + } + }, + + hide_overlays: function() { + if($('#icon-up').attr('down') == 'true') { + $('#icon-up').attr('down', 'false'); + $('#icon-up').show(); $('#icon-down').hide(); + $('#pub_overlay').addClass('barOnBottom'); $('#pub_overlay').removeClass('barOnTop'); + } else { + $('#icon-up').attr('down', 'true'); + $('#icon-down').show(); $('#icon-up').hide(); + $('#pub_overlay').addClass('barOnTop'); $('#pub_overlay').removeClass('barOnBottom'); + + } + }, + + outterToggle: function() { + if($('#outter-down-button').attr('up') == 'true' ) { + $('#outter-down-button').attr('up', 'false'); + $('#outter-up-button').hide(); $('#outter-down-button').show(); + $('#renarrated_overlay').addClass('barOnBottom'); $('#renarrated_overlay').removeClass('barOnTop'); + } else { + $('#outter-down-button').attr('up', 'true'); + $('#outter-up-button').show(); $('#outter-down-button').hide(); + $('#renarrated_overlay').addClass('barOnTop'); $('#renarrated_overlay').removeClass('barOnBottom'); + } + }, + + + getLoc: function() { + + $( "#loc-select" ).autocomplete({ + source: function(req, add){ + + //pass request to server + $.getJSON(config.deploy+"/getLoc?", req, function(data) { + $('#loc-img').hide(); + + //create array for response objects + var suggestions = []; + + //process response + $.each(data['return'], function(i,val){ + suggestions.push(val['name']+', '+val['country_name']); + }); + //pass array to callback + add(suggestions); + }); + $('#loc-img').show(); + }, + }); + }, + + getLang: function() { + $( "#lang-select" ).autocomplete({ + source: function(req, add){ + + //pass request to server + $.getJSON(config.deploy+"/getLang?", req, function(data) { + $('#lang-img').hide(); + + //create array for response objects + var suggestions = []; + + //process response + $.each(data['return'], function(i, val){ + //suggestions.push(val.country); + suggestions.push(val['name']); + }); + //pass array to callback + add(suggestions); + }); + $('#lang-img').show(); + }, + }); + + + }, + + publish: function() { + if(util.hasChangesPending()) + { + $('#pub_overlay').slideUp(); + $('#element_edit_overlay').slideUp(); + $('#icon_on_overlay').slideUp(); + if (a11ypi.target == false ) { + var publish_template = '
'+ + // '
'+ + ''+ + ' '+ + ' '+ + ' '+ + ' '+ + ''+ + ' '+ + ' '+ + ''+ + ' '+ + ' '+ + '
You can choose to post this in your own blog or in the default Alipi blog
'+ + '

'+ + ' '+ + '

'; + + $('body').append(publish_template); + a11ypi.getLoc(); + a11ypi.getLang(); + a11ypi.target = true; + } + + $(document).unbind('mouseover'); // Unbind the css on mouseover + $(document).unbind('mouseout'); // Unbind the css on mouseout + + $('#pub_overlay').slideUp(); + $('#element_edit_overlay').slideUp(); + // $('#icon_on_overlay').slideUp(); + + $(function() { + $( "#targetoverlay" ).dialog({ + height:550, + width:600, + modal: true, + buttons: { + Publish: function() { + util.publish(); + } + }, + close: function() { + $('#pub_overlay').slideDown(); + // $('#element_edit_overlay').slideDown(); + // $('#icon_on_overlay').slideDown(); + $( "#targetoverlay" ).hide(); + } + }); + }); + } + }, + + hideAll: function() { + var boxes = '#show-links, #show-box, #show-comment'; + $(boxes).dialog('close'); + }, + + showBox: function() { + this.hideAll(); + $(document).unbind('mouseover'); // Unbind the css on mouseover + $(document).unbind('mouseout'); // Unbind the css on mouseout + + $(function() { + $( "#show-box" ).dialog( "destroy" ); + + $( "#show-box" ).dialog({ + width: 300, + height: 300, + modal: true + }); + }); + d = window.location.search.split('?')[1]; + var a = a11ypi.getParams(); + if (a['blog'] === undefined ) { + a11ypi.createMenu('1.0'); + } + else { + $('#show-box').attr('title', 'Choose a re-narration from the blog you specified.'); + a11ypi.ajax1(); + } + }, + showComment: function() { + this.hideAll(); + $(document).unbind('mouseover'); // Unbind the css on mouseover + $(document).unbind('mouseout'); // Unbind the css on mouseout + + $(function() { + $( "#show-comment" ).dialog( "destroy" ); + + $( "#show-comment" ).dialog({ + width: 300, + height: 300, + modal: true + }); + }); + a11ypi.createMenu('5el'); + }, + + ajaxLinks1: function() { + var xhr = new XMLHttpRequest(); + xhr.onreadystatechange = function() + { + if(xhr.readyState == 4) + { + if(xhr.responseText == "empty") + { } + else + { + $('#see-links').show(); + a11ypi.showlinks = JSON.parse(xhr.responseText); + } + } + } + xhr.open("POST",config.root+"/domain",true); + xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); + d = window.location.search.split('?')[1]; + a = a11ypi.getParams(); + xhr.send('url='+a['foruri']) + }, + showBox1: function() { + this.hideAll(); + $(document).unbind('mouseover'); // Unbind the css on mouseover + $(document).unbind('mouseout'); // Unbind the css on mouseout + + $(function() { + $( "#show-links" ).dialog( "destroy" ); + + $( "#show-links" ).dialog({ + width: 500, + height: 300, + modal: true + }); + }); + a11ypi.createDomainMenu(); + }, + createDomainMenu: function() { + var xyz = $("#show-links"); + xyz.html(''); + menu_list = a11ypi.showlinks; + for(var i=0; i '+ + 'Render source '+ + ' '+ + ''+ + '
'+ + ' '+ + ''+ + '
'; + $('body').append(template); + $('#pub_overlay').slideUp(); + $('#element_edit_overlay').hide(); + + var tag = pageEditor.event.target.nodeName; + $(pageEditor.event.target).removeAttr('m4pageedittype'); + $(pageEditor.event.target).children().removeAttr('m4pageedittype'); + + $('#adv-reference').text('<'+tag+'>'+$(pageEditor.event.target).html()+''); + $('#reference').html($(pageEditor.event.target).html()); + $('#editor').html($(pageEditor.event.target).html()); + $("#adv-ref").button({icons:{primary:"ui-icon-script"},text:true}); $('#adv-ref').children().addClass('alipi'); + $("#close-adv").button({icons:{primary:"ui-icon-bookmark"},text:true}); $('#close-adv').children().addClass('alipi'); + $('#close-adv').hide(); + $('#adv-ref').button(); + + $(document).unbind('mouseover'); // Unbind the css on mouseover + $(document).unbind('mouseout'); // Unbind the css on mouseout + + $( "#editoroverlay" ).dialog({ + position: 'center', + width:$(window).width()-10, + height:$(window).height()-50, + modal: true, + buttons: { + "+": function() { + if($('#editor').css('font-size') >= '30px') { + // passthrough + } + else { + var font = parseFloat($('#editor').css('font-size')) + 1; + $('#editor').css('font-size', font+'px'); + font = parseFloat($('#reference').css('font-size')) + 1; + $('#reference').css('font-size', font+'px'); + font = parseFloat($('#adv-reference').css('font-size')) + 1; + $('#adv-reference').css('font-size', font+'px'); + } + }, + "-": function() { + if($('#editor').css('font-size') <= '10px') { + //passthrough + } + else { + var font = parseFloat($('#editor').css('font-size')) - 1; + $('#editor').css('font-size', font+'px'); + font = parseFloat($('#reference').css('font-size')) - 1; + $('#reference').css('font-size', font+'px'); + font = parseFloat($('#adv-reference').css('font-size')) - 1; + $('#adv-reference').css('font-size', font+'px'); + } + }, + "Add Link": function() { + pageEditor.handler(); + }, + "Save changes": function() { + $('#pub_overlay').slideDown(); + $('#element_edit_overlay').slideDown(); + $('#icon_on_overlay').slideDown(); + manager.recordText(pageEditor.event.target); + pageEditor.cleanUp(pageEditor.event.target); + $( "#editoroverlay" ).remove(); + } + }, + close: function() { + pageEditor.cleanUp(pageEditor.event.target); + $("#editoroverlay" ).remove(); + } + }); + + $($($('