Commit 0cc07471681ae93ab128bfdaa78e1e1c86bb9098
- Diff rendering mode:
- inline
- side by side
server/alipi.py
(102 / 237)
  | |||
41 | 41 | page = unicode(page,'utf-8') #Hack to fix improperly displayed chars on wikipedia. | |
42 | 42 | except UnicodeDecodeError: | |
43 | 43 | pass #Some pages may not need be utf-8'ed | |
44 | root = lxml.html.parse(StringIO.StringIO(page)).getroot() | ||
44 | g.root = lxml.html.parse(StringIO.StringIO(page)).getroot() | ||
45 | 45 | if request.args.has_key('lang') == False and request.args.has_key('blog') == False: | |
46 | root.make_links_absolute(d['foruri'], resolve_base_href = True) | ||
47 | for i in root.iterlinks(): | ||
46 | g.root.make_links_absolute(d['foruri'], resolve_base_href = True) | ||
47 | for i in g.root.iterlinks(): | ||
48 | 48 | if i[1] == 'href' and i[0].tag != 'link': | |
49 | 49 | i[0].attrib['href'] = 'http://{0}?foruri={1}'.format(conf.DEPLOYURL[0],quote_plus(i[0].attrib['href'])) | |
50 | script_test = root.makeelement('script') | ||
51 | script_edit = root.makeelement('script') | ||
52 | root.body.append(script_test) | ||
53 | root.body.append(script_edit) | ||
54 | script_test.set("src", conf.APPURL[0] + "/server/ui.js") | ||
55 | script_test.set("type", "text/javascript") | ||
56 | script_edit.set("src", conf.APPURL[0] + "/server/wsgi/pageEditor.js") | ||
57 | script_edit.set("type","text/javascript") | ||
58 | |||
59 | script_jq_mini = root.makeelement('script') | ||
60 | root.body.append(script_jq_mini) | ||
61 | script_jq_mini.set("src", conf.JQUERYURL[0] + "/jquery-1.7.min.js") | ||
62 | script_jq_mini.set("type", "text/javascript") | ||
63 | |||
64 | style = root.makeelement('link') | ||
65 | root.body.append(style) | ||
66 | style.set("rel","stylesheet") | ||
67 | style.set("type", "text/css") | ||
68 | style.set("href", conf.APPURL[0] + "/server/stylesheet.css") | ||
50 | setScripts() | ||
51 | g.root.body.set("onload","a11ypi.loadOverlay();") | ||
52 | return lxml.html.tostring(g.root) | ||
69 | 53 | ||
70 | jit_script = root.makeelement('script') | ||
71 | root.body.append(jit_script) | ||
72 | jit_script.set("src", conf.APPURL[0] + "/server/jit.js") | ||
73 | jit_script.set("type", "text/javascript") | ||
74 | |||
75 | tree_script = root.makeelement('script') | ||
76 | root.body.append(tree_script) | ||
77 | tree_script.set("src", conf.APPURL[0] + "/server/tree.js") | ||
78 | tree_script.set("type", "text/javascript") | ||
79 | |||
80 | script_jq_cust = root.makeelement('script') | ||
81 | root.body.append(script_jq_cust) | ||
82 | script_jq_cust.set("src", conf.JQUERYUI[0] + "/jquery-ui.min.js") | ||
83 | script_jq_cust.set("type", "text/javascript") | ||
84 | |||
85 | style_cust = root.makeelement('link') | ||
86 | style_cust.set("rel","stylesheet") | ||
87 | style_cust.set("type", "text/css") | ||
88 | style_cust.set("href", conf.JQUERYCSS[0] + "/jquery-ui.css") | ||
89 | root.body.append(style_cust) | ||
90 | |||
91 | root.body.set("onload","a11ypi.loadOverlay();") | ||
92 | return lxml.html.tostring(root) | ||
93 | |||
94 | 54 | elif request.args.has_key('lang') == True and request.args.has_key('interactive') == True and request.args.has_key('blog') == False: | |
95 | root.make_links_absolute(d['foruri'], resolve_base_href = True) | ||
96 | script_test = root.makeelement('script') | ||
97 | script_edit = root.makeelement('script') | ||
98 | root.body.append(script_test) | ||
99 | root.body.append(script_edit) | ||
55 | setScripts() | ||
56 | setSocialScript() | ||
57 | g.root.body.set("onload","a11ypi.ren();a11ypi.tweet(); a11ypi.facebook(); a11ypi.loadOverlay();") | ||
58 | return lxml.html.tostring(g.root) | ||
100 | 59 | ||
101 | script_jq_mini = root.makeelement('script') | ||
102 | root.body.append(script_jq_mini) | ||
103 | script_jq_mini.set("src", conf.JQUERYURL[0] + "/jquery-1.7.min.js") | ||
104 | script_jq_mini.set("type", "text/javascript") | ||
105 | |||
106 | script_jqui = root.makeelement('script') | ||
107 | script_jqui.set("type","text/javascript") | ||
108 | script_jqui.set("src",conf.JQUERYUI[0] + "/jquery-ui.min.js") | ||
109 | root.body.append(script_jqui) | ||
110 | script_test.set("src", conf.APPURL[0] + "/server/ui.js") | ||
111 | script_test.set("type", "text/javascript") | ||
112 | script_edit.set("src", conf.APPURL[0] + "/server/wsgi/pageEditor.js") | ||
113 | script_edit.set("type","text/javascript") | ||
114 | |||
115 | jit_script = root.makeelement('script') | ||
116 | root.body.append(jit_script) | ||
117 | jit_script.set("src", conf.APPURL[0] + "/server/jit.js") | ||
118 | jit_script.set("type", "text/javascript") | ||
119 | |||
120 | tree_script = root.makeelement('script') | ||
121 | root.body.append(tree_script) | ||
122 | tree_script.set("src", conf.APPURL[0] + "/server/tree.js") | ||
123 | tree_script.set("type", "text/javascript") | ||
124 | |||
125 | ui_css = root.makeelement("link") | ||
126 | ui_css.set("rel", "stylesheet"); | ||
127 | ui_css.set("type", "text/css"); | ||
128 | ui_css.set("href", conf.JQUERYCSS[0] + "/jquery-ui.css"); | ||
129 | root.body.append(ui_css); | ||
130 | |||
131 | see_orig = root.makeelement('input') | ||
132 | root.body.append(see_orig) | ||
133 | see_orig.set("id", "orig-button") | ||
134 | see_orig.set("class", "alipi") | ||
135 | see_orig.set("type", "submit") | ||
136 | see_orig.set("onClick", "a11ypi.showOriginal();") | ||
137 | see_orig.set("value", "Original page") | ||
138 | see_orig.set("style","display:none;") | ||
139 | |||
140 | tweetroot = root.makeelement("div") | ||
141 | tweetroot.set("id", "tweet-root") | ||
142 | tweetroot.set("class", "alipi") | ||
143 | tweetroot.set("style", "display:none;padding:10px;") | ||
144 | root.body.append(tweetroot) | ||
145 | |||
146 | tweet = root.makeelement("a") | ||
147 | tweet.set("id", "tweet") | ||
148 | tweet.set("href", "https://twitter.com/share") | ||
149 | tweet.set("class", "alipi twitter-share-button") | ||
150 | tweet.set("data-via", "a11ypi") | ||
151 | tweet.set("data-lang", "en") | ||
152 | tweet.set("data-url", "http://dev.a11y.in/web?foruri={0}&lang={1}&interactive=1".format(quote_plus(d['foruri']),request.args['lang'])) | ||
153 | tweet.textContent = "Tweet" | ||
154 | tweetroot.append(tweet) | ||
155 | |||
156 | fblike = root.makeelement("div") | ||
157 | fblike.set("id", "fb-like") | ||
158 | fblike.set("class", "alipi fb-like") | ||
159 | fblike.set("style", "display:none;padding:10px;") | ||
160 | fblike.set("data-href", "http://dev.a11y.in/web?foruri={0}&lang={1}&interactive=1".format(quote_plus(d['foruri']),request.args['lang'])) | ||
161 | fblike.set("data-send", "true") | ||
162 | fblike.set("data-layout", "button_count") | ||
163 | fblike.set("data-width", "50") | ||
164 | fblike.set("data-show-faces", "true") | ||
165 | fblike.set("data-font", "arial") | ||
166 | root.body.append(fblike) | ||
167 | |||
168 | style = root.makeelement('link') | ||
169 | root.body.append(style) | ||
170 | style.set("rel","stylesheet") | ||
171 | style.set("type", "text/css") | ||
172 | style.set("href", "http://dev.a11y.in/server/stylesheet.css") | ||
173 | |||
174 | root.body.set("onload","a11ypi.ren();a11ypi.tweet(); a11ypi.facebook(); a11ypi.loadOverlay();") | ||
175 | return lxml.html.tostring(root) | ||
176 | |||
177 | 60 | elif request.args.has_key('lang') == True and request.args.has_key('blog') == False: | |
178 | 61 | script_jq_mini = root.makeelement('script') | |
179 | 62 | root.body.append(script_jq_mini) | |
… | … | ||
73 | 73 | ||
74 | 74 | elif request.args.has_key('interactive') == True and request.args.has_key('blog') == True and request.args.has_key('lang') == True: | |
75 | 75 | ||
76 | script_test = root.makeelement('script') | ||
77 | script_test.set("src", conf.APPURL[0] + "/server/ui.js") | ||
78 | script_test.set("type", "text/javascript") | ||
79 | root.body.append(script_test) | ||
80 | |||
81 | script_jq_mini = root.makeelement('script') | ||
82 | script_jq_mini.set("src", conf.JQUERYURL[0] + "/jquery-1.7.min.js") | ||
83 | script_jq_mini.set("type", "text/javascript") | ||
84 | root.body.append(script_jq_mini) | ||
76 | setScripts() | ||
77 | setSocialScript() | ||
78 | g.root.body.set("onload","a11ypi.filter(); a11ypi.tweet(); a11ypi.facebook(); a11ypi.loadOverlay();"); | ||
79 | g.root.make_links_absolute(d['foruri'], resolve_base_href = True) | ||
80 | return lxml.html.tostring(g.root) | ||
85 | 81 | ||
86 | script_edit = root.makeelement('script') | ||
87 | script_edit.set("src", conf.APPURL[0] + "/server/wsgi/pageEditor.js") | ||
88 | script_edit.set("type","text/javascript") | ||
89 | root.body.append(script_edit) | ||
82 | elif request.args.has_key('interactive') == False and request.args.has_key('blog') == True: | ||
83 | setScripts() | ||
84 | g.root.make_links_absolute(d['foruri'], resolve_base_href = True) | ||
85 | g.root.body.set('onload', 'a11ypi.loadOverlay();') | ||
86 | return lxml.html.tostring(g.root) | ||
90 | 87 | ||
91 | # jit_script = root.makeelement('script') | ||
92 | # root.body.append(jit_script) | ||
93 | # jit_script.set("src", conf.APPURL[0] + "/server/jit.js") | ||
94 | # jit_script.set("type", "text/javascript") | ||
88 | def setScripts(): | ||
89 | script_test = g.root.makeelement('script') | ||
90 | script_edit = g.root.makeelement('script') | ||
91 | g.root.body.append(script_test) | ||
92 | g.root.body.append(script_edit) | ||
93 | script_test.set("src", conf.APPURL[0] + "/server/ui.js") | ||
94 | script_test.set("type", "text/javascript") | ||
95 | script_edit.set("src", conf.APPURL[0] + "/server/wsgi/pageEditor.js") | ||
96 | script_edit.set("type","text/javascript") | ||
97 | |||
98 | script_jq_mini = g.root.makeelement('script') | ||
99 | g.root.body.append(script_jq_mini) | ||
100 | script_jq_mini.set("src", conf.JQUERYURL[0] + "/jquery-1.7.min.js") | ||
101 | script_jq_mini.set("type", "text/javascript") | ||
102 | |||
103 | style = g.root.makeelement('link') | ||
104 | g.root.body.append(style) | ||
105 | style.set("rel","stylesheet") | ||
106 | style.set("type", "text/css") | ||
107 | style.set("href", conf.APPURL[0] + "/server/stylesheet.css") | ||
95 | 108 | ||
96 | # tree_script = root.makeelement('script') | ||
97 | # root.body.append(tree_script) | ||
98 | # tree_script.set("src", conf.APPURL[0] + "/server/tree.js") | ||
99 | # tree_script.set("type", "text/javascript") | ||
100 | |||
101 | script_jqui = root.makeelement('script') | ||
102 | script_jqui.set("type","text/javascript") | ||
103 | script_jqui.set("src",conf.JQUERYUI[0] + "/jquery-ui.min.js") | ||
104 | root.body.append(script_jqui) | ||
105 | ui_css = root.makeelement("link") | ||
106 | ui_css.set("rel", "stylesheet"); | ||
107 | ui_css.set("type", "text/css"); | ||
108 | ui_css.set("href", conf.JQUERYCSS[0] + "/jquery-ui.css"); | ||
109 | root.body.append(ui_css); | ||
109 | jit_script = g.root.makeelement('script') | ||
110 | g.root.body.append(jit_script) | ||
111 | jit_script.set("src", conf.APPURL[0] + "/server/jit.js") | ||
112 | jit_script.set("type", "text/javascript") | ||
110 | 113 | ||
111 | see_orig = root.makeelement('input') | ||
112 | root.body.append(see_orig) | ||
113 | see_orig.set("id", "orig-button") | ||
114 | see_orig.set("class", "alipi") | ||
115 | see_orig.set("type", "submit") | ||
116 | see_orig.set("onClick", "a11ypi.showOriginal();") | ||
117 | see_orig.set("value", "Original page") | ||
118 | see_orig.set("style","display:none;") | ||
114 | tree_script = g.root.makeelement('script') | ||
115 | g.root.body.append(tree_script) | ||
116 | tree_script.set("src", conf.APPURL[0] + "/server/tree.js") | ||
117 | tree_script.set("type", "text/javascript") | ||
119 | 118 | ||
120 | tweetroot = root.makeelement("div") | ||
121 | tweetroot.set("id", "tweet-root") | ||
122 | tweetroot.set("class", "alipi") | ||
123 | tweetroot.set("style", "display:none;padding:10px;") | ||
124 | root.body.append(tweetroot) | ||
119 | script_jq_cust = g.root.makeelement('script') | ||
120 | g.root.body.append(script_jq_cust) | ||
121 | script_jq_cust.set("src", conf.JQUERYUI[0] + "/jquery-ui.min.js") | ||
122 | script_jq_cust.set("type", "text/javascript") | ||
125 | 123 | ||
126 | tweet = root.makeelement("a") | ||
127 | tweet.set("id", "tweet") | ||
128 | tweet.set("href", "https://twitter.com/share") | ||
129 | tweet.set("class", "alipi twitter-share-button") | ||
130 | tweet.set("data-via", "a11ypi") | ||
131 | tweet.set("data-lang", "en") | ||
132 | tweet.set("data-url", "http://dev.a11y.in/web?foruri={0}&lang={1}&interactive=1".format(quote_plus(d['foruri']),request.args['lang'])) | ||
133 | tweet.textContent = "Tweet" | ||
134 | tweetroot.append(tweet) | ||
124 | style_cust = g.root.makeelement('link') | ||
125 | style_cust.set("rel","stylesheet") | ||
126 | style_cust.set("type", "text/css") | ||
127 | style_cust.set("href", conf.JQUERYCSS[0] + "/jquery-ui.css") | ||
128 | g.root.body.append(style_cust) | ||
129 | |||
130 | def setSocialScript(): | ||
131 | see_orig = g.root.makeelement('input') | ||
132 | g.root.body.append(see_orig) | ||
133 | see_orig.set("id", "orig-button") | ||
134 | see_orig.set("class", "alipi") | ||
135 | see_orig.set("type", "submit") | ||
136 | see_orig.set("onClick", "a11ypi.showOriginal();") | ||
137 | see_orig.set("value", "Original page") | ||
138 | see_orig.set("style","display:none;") | ||
135 | 139 | ||
136 | fblike = root.makeelement("div") | ||
137 | fblike.set("id", "fb-like") | ||
138 | fblike.set("class", "alipi fb-like") | ||
139 | fblike.set("style", "display:none;padding:10px;") | ||
140 | fblike.set("data-href", "http://dev.a11y.in/web?foruri={0}&lang={1}&interactive=1".format(quote_plus(d['foruri']),request.args['lang'])) | ||
141 | fblike.set("data-send", "true") | ||
142 | fblike.set("data-layout", "button_count") | ||
143 | fblike.set("data-width", "50") | ||
144 | fblike.set("data-show-faces", "true") | ||
145 | fblike.set("data-font", "arial") | ||
146 | root.body.append(fblike) | ||
147 | |||
148 | style = root.makeelement('link') | ||
149 | root.body.append(style) | ||
150 | style.set("rel","stylesheet") | ||
151 | style.set("type", "text/css") | ||
152 | style.set("href", conf.APPURL[0] + "/server/stylesheet.css") | ||
153 | |||
154 | root.body.set("onload","a11ypi.filter(); a11ypi.tweet(); a11ypi.facebook(); a11ypi.loadOverlay();"); | ||
155 | root.make_links_absolute(d['foruri'], resolve_base_href = True) | ||
156 | return lxml.html.tostring(root) | ||
140 | tweetroot = g.root.makeelement("div") | ||
141 | tweetroot.set("id", "tweet-root") | ||
142 | tweetroot.set("class", "alipi") | ||
143 | tweetroot.set("style", "display:none;padding:10px;") | ||
144 | g.root.body.append(tweetroot) | ||
157 | 145 | ||
158 | elif request.args.has_key('interactive') == False and request.args.has_key('blog') == True: | ||
159 | script_test = root.makeelement('script') | ||
160 | root.body.append(script_test) | ||
161 | script_test.set("src", conf.APPURL[0] + "/server/ui.js") | ||
162 | script_test.set("type", "text/javascript") | ||
163 | |||
164 | script_jq_mini = root.makeelement('script') | ||
165 | root.body.append(script_jq_mini) | ||
166 | script_jq_mini.set("src", conf.JQUERYURL[0] + "/jquery-1.7.min.js") | ||
167 | script_jq_mini.set("type", "text/javascript") | ||
146 | tweet = g.root.makeelement("a") | ||
147 | tweet.set("id", "tweet") | ||
148 | tweet.set("href", "https://twitter.com/share") | ||
149 | tweet.set("class", "alipi twitter-share-button") | ||
150 | tweet.set("data-via", "a11ypi") | ||
151 | tweet.set("data-lang", "en") | ||
152 | tweet.set("data-url", "http://dev.a11y.in/web?foruri={0}&lang={1}&interactive=1".format(quote_plus(request.args['foruri']),request.args['lang'])) | ||
153 | tweet.textContent = "Tweet" | ||
154 | tweetroot.append(tweet) | ||
168 | 155 | ||
169 | script_edit = root.makeelement('script') | ||
170 | script_edit.set("src", conf.APPURL[0] + "/server/wsgi/pageEditor.js") | ||
171 | script_edit.set("type","text/javascript") | ||
172 | root.body.append(script_edit); | ||
173 | |||
174 | script_jq_cust = root.makeelement('script') | ||
175 | root.body.append(script_jq_cust) | ||
176 | script_jq_cust.set("src", conf.JQUERYUI[0] + "/jquery-ui.min.js") | ||
177 | script_jq_cust.set("type", "text/javascript") | ||
178 | |||
179 | style_cust = root.makeelement('link') | ||
180 | style_cust.set("rel","stylesheet") | ||
181 | style_cust.set("type", "text/css") | ||
182 | style_cust.set("href", conf.JQUERYCSS[0] + "/jquery-ui.css") | ||
183 | root.body.append(style_cust) | ||
184 | |||
185 | style = root.makeelement('link') | ||
186 | root.body.append(style) | ||
187 | style.set("rel","stylesheet") | ||
188 | style.set("type", "text/css") | ||
189 | style.set("href", conf.APPURL[0] + "/server/stylesheet.css") | ||
190 | |||
191 | root.make_links_absolute(d['foruri'], resolve_base_href = True) | ||
192 | root.body.set('onload', 'a11ypi.loadOverlay();') | ||
193 | return lxml.html.tostring(root) | ||
194 | |||
156 | fblike = g.root.makeelement("div") | ||
157 | fblike.set("id", "fb-like") | ||
158 | fblike.set("class", "alipi fb-like") | ||
159 | fblike.set("style", "display:none;padding:10px;") | ||
160 | fblike.set("data-href", "http://dev.a11y.in/web?foruri={0}&lang={1}&interactive=1".format(quote_plus(request.args['foruri']),request.args['lang'])) | ||
161 | fblike.set("data-send", "true") | ||
162 | fblike.set("data-layout", "button_count") | ||
163 | fblike.set("data-width", "50") | ||
164 | fblike.set("data-show-faces", "true") | ||
165 | fblike.set("data-font", "arial") | ||
166 | g.root.body.append(fblike) | ||
167 | |||
168 | style = g.root.makeelement('link') | ||
169 | g.root.body.append(style) | ||
170 | style.set("rel","stylesheet") | ||
171 | style.set("type", "text/css") | ||
172 | style.set("href", "http://dev.a11y.in/server/stylesheet.css") | ||
173 | |||
195 | 174 | @app.route('/directory') | |
196 | 175 | def show_directory(): | |
197 | 176 | collection = g.db['post'] | |
… | … | ||
210 | 210 | response = jsonify(d) | |
211 | 211 | response.headers['Access-Control-Allow-Origin'] = '*' | |
212 | 212 | return response | |
213 | @app.route('/blank', methods=['GET']) | ||
214 | def serve_blank(): | ||
215 | return render_template('blank.html') | ||
213 | 216 | ||
214 | 217 | import logging,os | |
215 | 218 | from logging import FileHandler |
server/ui.js
(55 / 11)
  | |||
11 | 11 | target : false, | |
12 | 12 | pageHtml:'', | |
13 | 13 | d: {}, | |
14 | response:'', | ||
14 | 15 | testContext : function() | |
15 | 16 | { | |
16 | 17 | if(document.getElementById('social_overlay') != null) | |
… | … | ||
47 | 47 | var para = document.createElement("p"); | |
48 | 48 | var newel = document.createElement("a"); | |
49 | 49 | newel.textContent = menu_list[i]; | |
50 | $(newel).attr("href","http://dev.a11y.in/web?foruri="+page+"&lang="+menu_list[i]+"&interactive=1"); | ||
50 | $(newel).attr("href","http://127.0.0.1:5000?foruri="+page+"&lang="+menu_list[i]+"&interactive=1"); | ||
51 | 51 | para.appendChild(newel); | |
52 | 52 | xyz.appendChild(para); | |
53 | 53 | } | |
… | … | ||
140 | 140 | } | |
141 | 141 | else | |
142 | 142 | { | |
143 | |||
143 | var info_template = '<div id="infoDiv"></div>'; | ||
144 | $('#renarrated_overlay').append(info_template); | ||
144 | 145 | d ={}; | |
146 | a11ypi.response = xhr.responseText; | ||
145 | 147 | var response=xhr.responseText.substring(3).split('###'); | |
146 | 148 | for (var j= 0; j< response.length ; j++){ | |
147 | 149 | chunk = response[j].substring(1).split('&'); | |
… | … | ||
154 | 154 | value = pair[1]; | |
155 | 155 | d[key] = value; | |
156 | 156 | } | |
157 | $('#infoDiv').append(d['xpath']); | ||
158 | $('#infoDiv').append('<br>'); | ||
157 | 159 | path = d['xpath']; | |
158 | 160 | newContent = d['data']; | |
159 | 161 | elementType = d['elementtype']; | |
… | … | ||
208 | 208 | else if(elementType == 'audio/ogg') | |
209 | 209 | { | |
210 | 210 | newContent = decodeURIComponent(newContent); | |
211 | audio = '<audio controls="controls" autoplay="autoplay" src="'+newContent+'" style="display:table;"></audio>'; | ||
211 | audio = '<audio controls="controls" src="'+newContent+'" style="display:table;"></audio>'; | ||
212 | 212 | $(result).before(audio); | |
213 | 213 | result.setAttribute('class','blink'); | |
214 | 214 | } | |
… | … | ||
347 | 347 | '<input id="edit-current" class="alipi" type="submit" onclick="a11ypi.editPage();" value="Re-narrate this page">'+ | |
348 | 348 | '<input id="see-narration" class="alipi" type="submit" onclick="a11ypi.showBox();" value="See re-narrations">'+ | |
349 | 349 | '<input id="see-links" class="alipi" type="submit" onclick="a11ypi.showBox1();" value="List of pages narrated">'+ | |
350 | '<select id="blog-filter" class="alipi"></select>'+ | ||
351 | '<input id="go" class="alipi" type="submit" onclick="a11ypi.go();" value="|Y|">'+ | ||
350 | '<select id="blog-filter" class="alipi" onchange="a11ypi.checkSelect();"></select>'+ | ||
351 | '<input id="go" class="alipi" type="submit" onclick="a11ypi.go();" value="|Y|" title="Filter by specified blog">'+ | ||
352 | 352 | '<input id="share" class="alipi" type="submit" onclick="a11ypi.share();" value="Share"> '+ | |
353 | 353 | '</div><div id="show-box" title="Choose a narration"></div><div id="show-links" title="List of pages narrated in this domain" '+ | |
354 | 'class="alipi"></div><div id="share-box" class="alipi" title="Share this page in any following social network"></div>'; | ||
354 | 'class="alipi"></div><div id="share-box" class="alipi" title="Share this page in any following social network">'+ | ||
355 | '<input id="info" class="alipi" type="submit" onclick="a11ypi.showInfo();"></input></div>'; | ||
355 | 356 | ||
356 | 357 | var pub_overlay_template = '<div id="pub_overlay" class="alipi ui-widget-header ui-corner-all">'+ | |
357 | 358 | '<input id="exit-mode" class="alipi" type="submit" onclick="a11ypi.exitMode();" value="Exit">'+ | |
… | … | ||
401 | 401 | $('#share').show(); | |
402 | 402 | } | |
403 | 403 | }, | |
404 | |||
404 | checkSelect: function() | ||
405 | { | ||
406 | if($('#blog-filter').val() != "Choose a blog") { | ||
407 | $('#go').button({disabled : false}); | ||
408 | } else { | ||
409 | $('#go').button({disabled : true}); | ||
410 | } | ||
411 | }, | ||
405 | 412 | help_window: function() { | |
406 | 413 | var help_template = '<div id="helpwindow" class="alipi ui-widget-header ui-corner-all">'+ | |
407 | 414 | '<label id="txtlab" class="alipi" style="color:#000;font-weight:normal;">TEXT :- It will popup a '+ | |
… | … | ||
563 | 563 | '<label class="alipi" style="color:#000;position:relative;">Personal Blog</label></p></div>'; | |
564 | 564 | ||
565 | 565 | $('body').append(publish_template); | |
566 | //document.addEventListener("DOMActivate", init, false); | ||
567 | 566 | a11ypi.getLoc(); | |
568 | 567 | a11ypi.getLang(); | |
569 | 568 | a11ypi.target = true; | |
… | … | ||
599 | 599 | $('#element_edit_overlay').slideDown(); | |
600 | 600 | $('#icon_on_overlay').slideDown(); | |
601 | 601 | $( "#targetoverlay" ).hide(); | |
602 | // document.removeEventListener("DOMActivate", init, false); | ||
603 | 602 | } | |
604 | 603 | }); | |
605 | 604 | }); | |
… | … | ||
729 | 729 | { | |
730 | 730 | var sel = $("#blog-filter"); | |
731 | 731 | var menu_list = JSON.parse(xhr.responseText); | |
732 | opt = document.createElement("option"); | ||
733 | opt.textContent = "Choose a blog"; | ||
734 | sel.append(opt); | ||
732 | 735 | for (var i=0; i < menu_list.length; i++) | |
733 | 736 | { | |
734 | 737 | opt = document.createElement("option"); | |
… | … | ||
948 | 948 | $(event.target).removeClass('highlightElement'); | |
949 | 949 | }, | |
950 | 950 | ||
951 | showTopBar: function() { | ||
952 | |||
951 | showInfo: function() { | ||
952 | infoWindow = window.open('blank','Info page'); | ||
953 | window.setTimeout(function(){a11ypi.pushInfo(infoWindow.document.getElementById('info_content'),infoWindow);},2000); | ||
954 | // $('#infoDiv').dialog({ | ||
955 | // height:500, | ||
956 | // width:500, | ||
957 | // modal: true, | ||
958 | // close: function(){ | ||
959 | // $('#infoDiv').close(); | ||
960 | // } | ||
961 | // }); | ||
962 | }, | ||
963 | pushInfo: function(ele, win) //ele contains the info_content element from blank.html | ||
964 | { | ||
965 | var alipi_template = '<pre><alipi></alipi></pre>'; | ||
966 | |||
967 | var response = a11ypi.response.substring(3).split('###'); | ||
968 | myjson = []; | ||
969 | for (var j= 0; j< response.length ; j++){ | ||
970 | d = {}; | ||
971 | chunk = response[j].substring(1).split('&'); | ||
972 | for (var i= 0; i< chunk.length ; i++){ | ||
973 | pair =chunk[i].split("::"); | ||
974 | key = pair[0]; | ||
975 | value = pair[1]; | ||
976 | d[key] = value; | ||
977 | } | ||
978 | |||
979 | myjson.push(d); | ||
980 | } | ||
981 | win.responseJSON = myjson; | ||
982 | win.onLoad(); | ||
953 | 983 | }, | |
954 | 984 | }; |
server/wsgi/pageEditor.js
(1 / 1)
  | |||
354 | 354 | } else { | |
355 | 355 | if($('#your-check').attr('checked') != undefined) | |
356 | 356 | { | |
357 | localStorage.myContent = buildDataString(); | ||
357 | localStorage.myContent = util.buildDataString(); | ||
358 | 358 | window.location.href = "http://dev.a11y.in/test.html"; | |
359 | 359 | } | |
360 | 360 | else{ |
wsgi/scrape.wsgi
(5 / 44)
  | |||
1 | import lxml.html | ||
2 | import pymongo | ||
3 | 1 | from urllib import unquote_plus | |
4 | import random | ||
5 | from lxml import etree | ||
2 | sys.path.insert(0,(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)))+'/wsgi') | ||
3 | import alipiUtils | ||
6 | 4 | def application(environ, start_response): | |
7 | 5 | #set the headers | |
8 | 6 | status = '200 OK' | |
… | … | ||
13 | 13 | parameter_pair = parameter_pair.split('=',1) | |
14 | 14 | d[unquote_plus(parameter_pair[0])] = unquote_plus(parameter_pair[1]) | |
15 | 15 | url = d['url'] | |
16 | connection = pymongo.Connection('localhost', 27017) | ||
17 | db = connection['dev_alipi'] | ||
18 | collection = db['post'] | ||
19 | root = lxml.html.parse(url).getroot() | ||
20 | elements = root.xpath('//@alipius/..') | ||
21 | store_list = [] | ||
22 | ren_id = random.random() | ||
23 | for element in elements: | ||
24 | temp = {} | ||
25 | for i in element.attrib['alipius'].split(','): | ||
26 | temp[i.split(':')[0]] = i.split(':')[1] | ||
27 | if temp['elementtype'] == 'audio/ogg': | ||
28 | temp['about'] = element.attrib['about'] | ||
29 | temp['xpath'] = element.attrib['xpath'] | ||
30 | temp['data'] = element.attrib['src'] | ||
31 | temp['blog'] = url | ||
32 | temp['ren_id'] = ren_id | ||
33 | store_list.append(temp) | ||
34 | elif temp['elementtype'] == 'image': | ||
35 | temp['about'] = element.attrib['about'] | ||
36 | temp['xpath'] = element.attrib['xpath'] | ||
37 | temp['data'] = element.attrib['width']+'x'+element.attrib['height']+','+element.attrib['src'] | ||
38 | temp['blog'] = url | ||
39 | temp['ren_id'] = ren_id | ||
40 | store_list.append(temp) | ||
41 | else: | ||
42 | temp['about'] = element.attrib['about'] | ||
43 | temp['xpath'] = element.attrib['xpath'] | ||
44 | data ='' | ||
45 | for i in element.iterdescendants(): | ||
46 | data += etree.tostring(i) | ||
47 | temp['data'] = data | ||
48 | temp['blog'] = url | ||
49 | temp['ren_id'] = ren_id | ||
50 | store_list.append(temp) | ||
51 | for z in store_list: | ||
52 | collection.insert(z) | ||
53 | connection.disconnect() | ||
54 | print >> environ['wsgi.errors'], z | ||
55 | return ['ok'] | ||
16 | rstr = alipiUtils.doScrape(url) | ||
17 | return [rstr] | ||
18 |
wsgi/test.wsgi
(8 / 7)
  | |||
8 | 8 | import random | |
9 | 9 | import os.path, sys | |
10 | 10 | sys.path.insert(0,(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)))+'/server') #A hack to import modules from server dir. | |
11 | sys.path.insert(0,(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)))+'/wsgi') | ||
11 | 12 | import conf | |
13 | import alipiUtils | ||
12 | 14 | def application(environ, start_response): | |
13 | 15 | #set the headers | |
14 | 16 | status = '200 OK' | |
… | … | ||
99 | 99 | blog_id = entry.GetSelfLink().href.split("/")[-1] | |
100 | 100 | blogEntry = CreatePublicPost(blogger_service, blog_id, title=title, content=string + "<blockquote><p>Re-narration by "+author+' in '+lang+' targeting '+target+' for this web <a href="'+about+'">page</a></p></blockquote>') | |
101 | 101 | ||
102 | j=0 | ||
103 | while j< len(dicts): | ||
104 | dicts[j]["blog"] = str(blogEntry.GetHtmlLink().href) | ||
105 | collection.insert(dicts[j]) | ||
106 | j+=1 | ||
107 | |||
108 | #commands.getoutput(cmd) | ||
102 | # j=0 | ||
103 | # while j< len(dicts): | ||
104 | # dicts[j]["blog"] = str(blogEntry.GetHtmlLink().href) | ||
105 | # collection.insert(dicts[j]) | ||
106 | # j+=1 | ||
107 | rstr = alipiUtils.doScrape(str(blogEntry.GetHtmlLink().href)) | ||
109 | 108 | connection.disconnect() | |
110 | 109 | return 'ok' | |
111 | 110 | #return ["Blog successfuly posted!!"] |