tracks/app/views/layouts/application.html.erb
Matt Rogers d0c4fee7e4 Don't include a protocol or domain for relative_to_root
Tracks uses this javascript method in the application layout called
`relative_to_root` to get relative paths for a lot of Javascript
functions. However, it includes the fully qualified protocol and domain
for the tracks site in question. If you have Tracks proxied through SSL
with nginx, then you get a non-secure URL which causes the Javascript to
not work to fetch things like contexts or projects for autocomplete.

Instead of using the `root_url` helper that Rails provides that won't
know about SSL, just use a normal forward slash instead, so that you
still get a path that's relative to the root instead of a URL.
2016-02-09 15:36:53 -06:00

50 lines
2.4 KiB
Text

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<%= stylesheet_link_tag "application", :media => "all" %>
<%= stylesheet_link_tag "print", :media => "print" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
<script type="text/javascript">
var SOURCE_VIEW = '<%=@source_view%>';
var AUTH_TOKEN = '<%= raw(protect_against_forgery? ? form_authenticity_token.inspect : "") %>'
var TAG_NAME = '<%= @tag_name ? @tag_name : "" %>'
var GROUP_VIEW_BY = '<%= @group_view_by ? @group_view_by : "" %>'
var defaultContexts = <%= default_contexts_for_autocomplete.html_safe rescue '{}' %>;
var defaultTags = <%= default_tags_for_autocomplete.html_safe rescue '{}' %>;
var dateFormat = '<%= date_format_for_date_picker %>';
var weekStart = '<%= current_user.prefs.week_starts %>';
function relative_to_root(path) { return '/' + path; };
<% if current_user.prefs.refresh != 0 -%>
setup_auto_refresh(<%= current_user.prefs["refresh"].to_i*60000 %>);
<% end -%>
<% unless controller.controller_name == 'feed' or session['noexpiry'] == "on" -%>
setup_periodic_check("<%=url_for(:controller => "login", :action => "check_expiry")%>", 5*60);
<% end -%>
setup_periodic_check("<%=check_deferred_todos_path(:format => 'js')%>", 10*60, 'POST');
<%= generate_i18n_strings %>
</script>
<%= favicon_link_tag 'favicon.ico' %>
<%= favicon_link_tag 'apple-touch-icon.png', :rel => 'apple-touch-icon', :type => 'image/png' %>
<%= auto_discovery_link_tag(:rss, {:controller => "todos", :action => "index", :format => 'rss', :token => "#{current_user.token}"}, {:title => t('layouts.next_actions_rss_feed')}) %>
<link rel="search" type="application/opensearchdescription+xml" title="Tracks" href="<%= search_plugin_path(:format => :xml) %>" />
<title><%= @page_title %></title>
</head>
<body>
<div class="bootstrap">
<%= render partial: "shared/navbar" %>
</div>
<div class="legacy-ui <%= controller.controller_name %>">
<%= render_flash %>
<div id="content" class="<%= controller.controller_name %>">
<%= yield %>
</div>
<%= render :partial => "shared/footer" %>
</div><!-- .legacy-ui -->
</body>
</html>