Commit d786060307f9f289f8e2cba8f233cb341ae0e063
Fix wrong URL paths in the server and client code
Should be using url_for for passing URL paths to static assets.
Fix them.
| | | | 1 | from flask import Flask | 1 | from flask import Flask |
---|
2 | from flask import request | 2 | from flask import request |
---|
3 | from flask import render_template | | from flask import render_template |
---|
| | 3 | from flask import render_template, url_for | 4 | from flask import make_response | 4 | from flask import make_response |
---|
5 | from flask import jsonify | 5 | from flask import jsonify |
---|
6 | import logging | 6 | import logging |
---|
… | | … | |
---|
143 | root = lxml.html.parse(StringIO.StringIO(page)).getroot() | 143 | root = lxml.html.parse(StringIO.StringIO(page)).getroot() |
---|
144 | root.make_links_absolute(request.args['url'], resolve_base_href = True) | 144 | root.make_links_absolute(request.args['url'], resolve_base_href = True) |
---|
145 | # Log -- comment them | 145 | # Log -- comment them |
---|
146 | print "Page parsed.. Preparing to send.." | | print "Page parsed.. Preparing to send.." |
---|
| | 146 | #print "Page parsed.. Preparing to send.." | 147 | | 147 | |
---|
148 | # inject the JS toolbar to annotate text | 148 | # inject the JS toolbar to annotate text |
---|
149 | jq = root.makeelement('script') | 149 | jq = root.makeelement('script') |
---|
150 | jq.set('src', '/static/jquery-1.9.1.min.js') | | jq.set('src', '/static/jquery-1.9.1.min.js') |
---|
| | 150 | jq.set('src', url_for('static', filename='jquery-1.9.1.min.js')) | 151 | | 151 | |
---|
152 | script = root.makeelement('script') | 152 | script = root.makeelement('script') |
---|
153 | script.set('src', '/static/text-annotation.js') | | script.set('src', '/static/text-annotation.js') |
---|
| | 153 | script.set('src', url_for('static', filename='text-annotation.js')) | 154 | | 154 | |
---|
155 | tree = root.makeelement('script') | 155 | tree = root.makeelement('script') |
---|
156 | tree.set('src', '/static/tree.js') | | tree.set('src', '/static/tree.js') |
---|
| | 156 | tree.set('src', url_for('static', filename='tree.js')) | 157 | | 157 | |
---|
158 | bs_js = root.makeelement('script') | 158 | bs_js = root.makeelement('script') |
---|
159 | bs_js.set('src', '/static/bootstrap.js') | | bs_js.set('src', '/static/bootstrap.js') |
---|
| | 159 | bs_js.set('src', url_for('static', filename='bootstrap.js')) | 160 | | 160 | |
---|
161 | jit = root.makeelement('script') | 161 | jit = root.makeelement('script') |
---|
162 | jit.set('src', '/static/jit.js') | | jit.set('src', '/static/jit.js') |
---|
| | 162 | jit.set('src', url_for('static', filename='jit.js')) | 163 | | 163 | |
---|
164 | us = root.makeelement('script') | 164 | us = root.makeelement('script') |
---|
165 | us.set('src', '/static/underscore-min-1.4.4.js') | | us.set('src', '/static/underscore-min-1.4.4.js') |
---|
| | 165 | us.set('src', url_for('static', filename='underscore-min-1.4.4.js')) | 166 | | 166 | |
---|
167 | link = root.makeelement('link') | 167 | link = root.makeelement('link') |
---|
168 | link.set('href', '/static/text-annotation.css') | | link.set('href', '/static/text-annotation.css') |
---|
| | 168 | link.set('href', url_for('static', filename='text-annotation.css')) | 169 | link.set('type', 'text/css') | 169 | link.set('type', 'text/css') |
---|
170 | link.set('rel', 'stylesheet') | 170 | link.set('rel', 'stylesheet') |
---|
171 | | 171 | |
---|
172 | bs = root.makeelement('link') | 172 | bs = root.makeelement('link') |
---|
173 | bs.set('href', '/static/bootstrap.css') | | bs.set('href', '/static/bootstrap.css') |
---|
| | 173 | bs.set('href', url_for('static', filename='bootstrap.css')) | 174 | bs.set('type', 'text/css') | 174 | bs.set('type', 'text/css') |
---|
175 | bs.set('rel', 'stylesheet') | 175 | bs.set('rel', 'stylesheet') |
---|
176 | | 176 | |
---|
177 | tree_css = root.makeelement('link') | 177 | tree_css = root.makeelement('link') |
---|
178 | tree_css.set('href', '/static/tree.css') | | tree_css.set('href', '/static/tree.css') |
---|
| | 178 | tree_css.set('href', url_for('static', filename='tree.css')) | 179 | tree_css.set('type', 'text/css') | 179 | tree_css.set('type', 'text/css') |
---|
180 | tree_css.set('rel', 'stylesheet') | 180 | tree_css.set('rel', 'stylesheet') |
---|
181 | | 181 | |
---|
| | | | 4 | <meta charset="utf-8"> | 4 | <meta charset="utf-8"> |
---|
5 | <meta http-equiv='imagetoolbar' content='no'/> | 5 | <meta http-equiv='imagetoolbar' content='no'/> |
---|
6 | <title> Web Annotation </title> | 6 | <title> Web Annotation </title> |
---|
7 | <link rel="stylesheet" type="text/css" href="/static/bootstrap.css"></link> | | <link rel="stylesheet" type="text/css" href="/static/bootstrap.css"></link> |
---|
8 | <script type="text/javascript" src="/static/jquery-1.9.1.min.js"></script> | | <script type="text/javascript" src="/static/jquery-1.9.1.min.js"></script> |
---|
9 | <script type="text/javascript" src="/static/bootstrap.js"></script> | | <script type="text/javascript" src="/static/bootstrap.js"></script> |
---|
| | 7 | <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='bootstrap.css') }}"></link> | | | 8 | <script type="text/javascript" src="{{ url_for('static', filename='jquery-1.9.1.min.js') }}"></script> |
---|
| | 9 | <script type="text/javascript" src"{{ url_for('static', filename='bootstrap.js') }}"></script> |
---|
10 | <style type="text/css"> | 10 | <style type="text/css"> |
---|
11 | .container { | 11 | .container { |
---|
12 | margin-top: 30px; | 12 | margin-top: 30px; |
---|