Skip to content

Commit

Permalink
Set the base URL correctly to refer to '/' and not /app.html
Browse files Browse the repository at this point in the history
The client app currently expects the base URL to refer to
the root URL for the Hypothesis web service and not the app.html
page for the sidebar. In particular, in the extension this
is used to determine where to make the '/app' call to get
a session token.
  • Loading branch information
robertknight committed Jan 19, 2016
1 parent b3fe835 commit 9477e00
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion h/buildext.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def build_chrome(args):
with codecs.open(content_dir + '/app.html', 'w', 'utf-8') as fp:
data = client_assets.render_app_html(
api_url=api_url,
base_url=webassets_env.url + '/app.html',
base_url=args.base,

# Google Analytics tracking is currently not enabled
# for the extension
Expand Down
10 changes: 9 additions & 1 deletion h/client_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ def _app_html_context(webassets_env,
else:
ga_cookie_domain = 'auto'


# Angular requires that the <base> tag's href include
# a non-empty path component
if urlparse(base_url).path == '':
base_url += '/'


return {
'angular_templates': map(_angular_template_context,
ANGULAR_DIRECTIVE_TEMPLATES),
Expand All @@ -86,7 +93,8 @@ def render_app_html(webassets_env, base_url, api_url, websocket_url,
Return the HTML for the Hypothesis app page,
used by the sidebar, stream and single-annotation page.
:param base_url: The URL at which the page will be served
:param base_url: The base URL of the Hypothesis service
(eg. https://hypothes.is/)
:param api_url: The root URL for the Hypothesis service API
:param websocket_url: The WebSocket URL which the client should connect to
:param register_url: The URL which new users should be sent to in order to
Expand Down
2 changes: 1 addition & 1 deletion h/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _handle_exc(request):
def _render_app(request, extra={}):
request.response.text = client_assets.render_app_html(
api_url=request.route_url('api'),
base_url=request.url,
base_url=request.route_url('index'),
extra=extra,
ga_tracking_id=request.registry.settings.get('ga_tracking_id'),
register_url=request.route_url('register'),
Expand Down

0 comments on commit 9477e00

Please sign in to comment.