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.
  • Diff rendering mode:
  • inline
  • side by side

server.py

1from flask import Flask1from flask import Flask
2from flask import request2from flask import request
3from flask import render_template
3from flask import render_template, url_for
4from flask import make_response4from flask import make_response
5from flask import jsonify5from flask import jsonify
6import logging6import 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 them145 # Log -- comment them
146 print "Page parsed.. Preparing to send.."
146 #print "Page parsed.. Preparing to send.."
147147
148 # inject the JS toolbar to annotate text148 # 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')
150 jq.set('src', url_for('static', filename='jquery-1.9.1.min.js'))
151151
152 script = root.makeelement('script')152 script = root.makeelement('script')
153 script.set('src', '/static/text-annotation.js')
153 script.set('src', url_for('static', filename='text-annotation.js'))
154154
155 tree = root.makeelement('script')155 tree = root.makeelement('script')
156 tree.set('src', '/static/tree.js')
156 tree.set('src', url_for('static', filename='tree.js'))
157157
158 bs_js = root.makeelement('script')158 bs_js = root.makeelement('script')
159 bs_js.set('src', '/static/bootstrap.js')
159 bs_js.set('src', url_for('static', filename='bootstrap.js'))
160160
161 jit = root.makeelement('script')161 jit = root.makeelement('script')
162 jit.set('src', '/static/jit.js')
162 jit.set('src', url_for('static', filename='jit.js'))
163163
164 us = root.makeelement('script')164 us = root.makeelement('script')
165 us.set('src', '/static/underscore-min-1.4.4.js')
165 us.set('src', url_for('static', filename='underscore-min-1.4.4.js'))
166166
167 link = root.makeelement('link')167 link = root.makeelement('link')
168 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')
171171
172 bs = root.makeelement('link')172 bs = root.makeelement('link')
173 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')
176176
177 tree_css = root.makeelement('link')177 tree_css = root.makeelement('link')
178 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')
181181

templates/web.html

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>
8 <script type="text/javascript" src="/static/jquery-1.9.1.min.js"></script>
9 <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;