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.
server.py
(11 / 11)
  
11from flask import Flask
22from flask import request
3from flask import render_template
3from flask import render_template, url_for
44from flask import make_response
55from flask import jsonify
66import logging
143143 root = lxml.html.parse(StringIO.StringIO(page)).getroot()
144144 root.make_links_absolute(request.args['url'], resolve_base_href = True)
145145 # Log -- comment them
146 print "Page parsed.. Preparing to send.."
146 #print "Page parsed.. Preparing to send.."
147147
148148 # inject the JS toolbar to annotate text
149149 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
152152 script = root.makeelement('script')
153 script.set('src', '/static/text-annotation.js')
153 script.set('src', url_for('static', filename='text-annotation.js'))
154154
155155 tree = root.makeelement('script')
156 tree.set('src', '/static/tree.js')
156 tree.set('src', url_for('static', filename='tree.js'))
157157
158158 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
161161 jit = root.makeelement('script')
162 jit.set('src', '/static/jit.js')
162 jit.set('src', url_for('static', filename='jit.js'))
163163
164164 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
167167 link = root.makeelement('link')
168 link.set('href', '/static/text-annotation.css')
168 link.set('href', url_for('static', filename='text-annotation.css'))
169169 link.set('type', 'text/css')
170170 link.set('rel', 'stylesheet')
171171
172172 bs = root.makeelement('link')
173 bs.set('href', '/static/bootstrap.css')
173 bs.set('href', url_for('static', filename='bootstrap.css'))
174174 bs.set('type', 'text/css')
175175 bs.set('rel', 'stylesheet')
176176
177177 tree_css = root.makeelement('link')
178 tree_css.set('href', '/static/tree.css')
178 tree_css.set('href', url_for('static', filename='tree.css'))
179179 tree_css.set('type', 'text/css')
180180 tree_css.set('rel', 'stylesheet')
181181
  
44 <meta charset="utf-8">
55 <meta http-equiv='imagetoolbar' content='no'/>
66 <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>
1010 <style type="text/css">
1111 .container {
1212 margin-top: 30px;