Skip to content

Commit

Permalink
fix path handling for subdir mounting (fixes phusion#13)
Browse files Browse the repository at this point in the history
`config.action_controller.relative_url_root` can be used to tell Rails
that you are deploying to a subdirectory. The default is
`ENV['RAILS_RELATIVE_URL_ROOT']`.

the asset pipeline doesn't like using the value from request script_name,
although this should contain the correct value and should theoretically
be possible :(
  • Loading branch information
stbuehler committed Dec 15, 2013
1 parent 17eca70 commit f01c3c5
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/assets/javascripts/application.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ reinstallBehavior = (context)->
textarea.delayedObserver ->
callback = (html)->
$('.preview .content', form).html(html)
$.get('/admin/comments/preview', content: textarea.val(), callback)
$.get('./admin/comments/preview', content: textarea.val(), callback)

$(document).ready ->
reinstallBehavior()
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/help/_code.txt.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}

var result =
'<%= request.protocol %><%= request.host_with_port %>/api/show_topic.js' +
'//<%= request.host_with_port %><%= root_path %>api/show_topic.js' +
'?_c=' + window._juviaRequestCounter +
'&' + makeQueryString(options);
window._juviaRequestCounter++;
Expand Down
4 changes: 2 additions & 2 deletions app/views/api/base.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ if (!Juvia) {
var $container = $(form).closest('.juvia-container');
this.setSubmitting($container, true);
this.saveCommentBox($container);
this.loadScript('/api/add_comment', {
this.loadScript('<%= root_path %>api/add_comment', {
site_key : $container.data('site-key'),
topic_key : $container.data('topic-key'),
topic_title : $container.data('topic-title'),
Expand All @@ -242,7 +242,7 @@ if (!Juvia) {
Juvia.previewComment = function(formElement) {
var $container = $(formElement).closest('.juvia-container');
this.saveCommentBox($container);
this.loadScript('/api/preview_comment', {
this.loadScript('<%= root_path %>api/preview_comment', {
site_key : $container.data('site-key'),
topic_key: $container.data('topic-key'),
content : this.compress($('textarea[name="content"]', $container).val())
Expand Down
11 changes: 6 additions & 5 deletions app/views/layouts/_custom.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en-us" class="no-js"> <!--<![endif]-->

<head>
<base href="<%= root_path %>">
<meta http-equiv="X-UA-Compatible" content="IE=Edge;chrome=1" />
<meta charset="utf-8" />

<title><% if @title %><%= @title %> - <% end %>Juvia</title>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="shortcut icon" href="<%= root_path %>favicon.ico" />

<!-- The Columnal Grid (1140px wide base, load first), Type and image presets, and mobile stylesheet -->
<%= stylesheet_link_tag 'columnal' %>
Expand Down Expand Up @@ -50,9 +51,9 @@
<div class="row">
<div id="site_logo" class="col_5 clearleft">
<a href="http://www.phusion.nl/" class="product_creator">Phusion</a>
<a href="/" class="product_logo"><%= image_tag 'logo-96.png', :width => 96, :height => 61, :alt => "Logo" %></a>
<a href="/" class="product_name">Juvia</a>
<a href="/" class="product_desc">commenting system</a>
<a href="<%= root_path %>" class="product_logo"><%= image_tag 'logo-96.png', :width => 96, :height => 61, :alt => "Logo" %></a>
<a href="<%= root_path %>" class="product_name">Juvia</a>
<a href="<%= root_path %>" class="product_desc">commenting system</a>
</div>
<nav class="col_7 omega">
<% if user_signed_in? %>
Expand All @@ -61,7 +62,7 @@
<% else %>
<div><%= link_to 'Login', new_user_session_path %></div>
<% end %>
<div><a href="/admin/help" class="<%= maybe_active(:help) %>">Help</a></div>
<div><a href="<%= admin_help_path %>" class="<%= maybe_active(:help) %>">Help</a></div>
<% if user_signed_in? %>
<div><%= link_to 'Logout', destroy_user_session_path, :method => :delete %></div>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
put 'admin/dashboard/create_admin', :to => 'admin/dashboard#create_admin'
get 'admin/dashboard/new_site', :to => 'admin/dashboard#new_site'
put 'admin/dashboard/create_site', :to => 'admin/dashboard#create_site'
get 'admin/help(/:action)', :to => 'admin/help'
get 'admin/help(/:action)', :to => 'admin/help', :as => :admin_help

match 'test/:action', :to => 'test' if Rails.env.test?

Expand Down

0 comments on commit f01c3c5

Please sign in to comment.