Commit 792b80b46c376045a70dcfcc71f6e401615a3c09
- Diff rendering mode:
- inline
- side by side
swtr/server.py
(33 / 76)
  | |||
138 | 138 | root.make_links_absolute(flask.request.args['where'], | |
139 | 139 | resolve_base_href=True) | |
140 | 140 | ||
141 | jQuery = root.makeelement('script') | ||
142 | root.body.append(jQuery) | ||
143 | jQuery.set("src", "//code.jquery.com/jquery-1.11.0.min.js") | ||
144 | jQuery.set("type", "text/javascript") | ||
141 | addScript("//code.jquery.com/jquery-1.11.0.min.js", root) | ||
142 | addScript(flask.url_for('static', filename="js/annotator-full.min.js"), | ||
143 | root) | ||
145 | 144 | ||
146 | annotatorScript = root.makeelement('script') | ||
147 | root.body.append(annotatorScript) | ||
148 | annotatorScript.set("src", flask.url_for('static', | ||
149 | filename= | ||
150 | "js/annotator-full.min.js")) | ||
151 | annotatorScript.set("type", "text/javascript") | ||
145 | addCSS(flask.url_for('static', filename='css/annotator.min.css'), root) | ||
146 | addCSS(flask.url_for('static', filename='css/swtmaker.css'), root) | ||
147 | addCSS(flask.url_for('static', filename='css/bootstrap.min.css'), root) | ||
148 | addScript(flask.url_for('static', | ||
149 | filename="js/lib/underscore-1.5.2.min.js"), | ||
150 | root) | ||
151 | addScript(flask.url_for('static', | ||
152 | filename="js/lib/backbone-1.0.0.min.js"), | ||
153 | root) | ||
154 | addCSS(flask.url_for('static', filename='css/annotorious.css'), root) | ||
155 | addScript(flask.url_for('static', | ||
156 | filename="js/annotorious.okfn.0.3.js"), | ||
157 | root) | ||
152 | 158 | ||
153 | annotatorCSS = root.makeelement('link') | ||
154 | root.body.append(annotatorCSS) | ||
155 | annotatorCSS.set("href", flask.url_for('static', | ||
156 | filename= | ||
157 | "css/annotator.min.css")) | ||
158 | annotatorCSS.set("rel", "stylesheet") | ||
159 | annotatorCSS.set("type", "text/css") | ||
160 | |||
161 | swtmakerCSS = root.makeelement('link') | ||
162 | root.body.append(swtmakerCSS) | ||
163 | swtmakerCSS.set("href", flask.url_for('static', | ||
164 | filename= | ||
165 | "css/swtmaker.css")) | ||
166 | swtmakerCSS.set("rel", "stylesheet") | ||
167 | swtmakerCSS.set("type", "text/css") | ||
168 | |||
169 | bootstrapCSS = root.makeelement('link') | ||
170 | root.body.append(bootstrapCSS) | ||
171 | bootstrapCSS.set("href", flask.url_for('static', | ||
172 | filename= | ||
173 | "css/bootstrap.min.css")) | ||
174 | bootstrapCSS.set("rel", "stylesheet") | ||
175 | bootstrapCSS.set("type", "text/css") | ||
176 | |||
177 | underscoreJS = root.makeelement('script') | ||
178 | root.body.append(underscoreJS) | ||
179 | underscoreJS.set("src", flask.url_for('static', | ||
180 | filename="js/lib/" + | ||
181 | "underscore-1.5.2.min.js")) | ||
182 | underscoreJS.set("type", "text/javascript") | ||
183 | |||
184 | backboneJS = root.makeelement('script') | ||
185 | root.body.append(backboneJS) | ||
186 | backboneJS.set("src", flask.url_for('static', | ||
187 | filename= | ||
188 | "js/lib/backbone-1.0.0.min.js")) | ||
189 | backboneJS.set("type", "text/javascript") | ||
190 | |||
191 | # annotorious plugin | ||
192 | annotoriousCSS = root.makeelement('link') | ||
193 | root.body.append(annotoriousCSS) | ||
194 | annotoriousCSS.set("href", flask.url_for('static', | ||
195 | filename='css/annotorious.css')) | ||
196 | annotoriousCSS.set('rel', 'stylesheet') | ||
197 | |||
198 | annotoriousJS = root.makeelement('script') | ||
199 | root.body.append(annotoriousJS) | ||
200 | annotoriousJS.set('src', flask.url_for('static', | ||
201 | filename='js/annotorious.okfn.0.3.js')) | ||
202 | |||
203 | 159 | if 'auth_tok' in session: | |
204 | 160 | auth_tok = session['auth_tok'] | |
205 | 161 | else: | |
… | … | ||
184 | 184 | config.redirect_uri) | |
185 | 185 | configScript.set("type", "text/javascript") | |
186 | 186 | ||
187 | # swtmakerScript = root.makeelement('script') | ||
188 | # root.body.append(swtmakerScript) | ||
189 | # swtmakerScript.set("src", flask.url_for('static', | ||
190 | # filename="js/swtmaker.js")) | ||
191 | # swtmakerScript.set("type", "text/javascript") | ||
187 | addScript(flask.url_for('static', filename="js/oauth.js"), root) | ||
192 | 188 | ||
193 | oAuthScript = root.makeelement('script') | ||
194 | root.body.append(oAuthScript) | ||
195 | oAuthScript.set("src", flask.url_for('static', | ||
196 | filename="js/oauth.js")) | ||
197 | oAuthScript.set("type", "text/javascript") | ||
189 | addScript(flask.url_for('static', filename="js/app.js"), root) | ||
198 | 190 | ||
199 | appScript = root.makeelement('script') | ||
200 | root.body.append(appScript) | ||
201 | appScript.set("src", flask.url_for('static', | ||
202 | filename="js/app.js")) | ||
203 | appScript.set("type", "text/javascript") | ||
204 | |||
205 | 191 | response = flask.make_response() | |
206 | 192 | response.data = lxml.html.tostring(root) | |
207 | 193 | return response | |
… | … | ||
203 | 203 | refresh_token=auth_tok['refresh_token'], | |
204 | 204 | config=config, | |
205 | 205 | url=flask.request.args.get('where')) | |
206 | |||
207 | |||
208 | def addScript(src, el): | ||
209 | script = el.makeelement('script') | ||
210 | el.body.append(script) | ||
211 | script.set("src", src) | ||
212 | script.set("type", "text/javascript") | ||
213 | |||
214 | |||
215 | def addCSS(src, el): | ||
216 | style = el.makeelement('link') | ||
217 | el.body.append(style) | ||
218 | style.set("href", src) | ||
219 | style.set("rel", "stylesheet") | ||
220 | style.set("type", "text/css") | ||
206 | 221 | ||
207 | 222 | ||
208 | 223 | # if the app is run directly from command-line |