From 1b250f1e017c7f4e1fd6287a73a4e1e84537e061 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Thu, 30 Apr 2015 12:46:19 -0400 Subject: [PATCH] FIX: crawler pages and RSS had broken links for sites deployed to a subfolder with relative_url_root --- app/models/category.rb | 2 +- app/models/topic.rb | 4 ++-- app/views/application/_header.html.erb | 2 +- app/views/categories/index.html.erb | 2 +- app/views/layouts/application.html.erb | 2 +- app/views/layouts/crawler.html.erb | 2 +- app/views/list/list.erb | 9 +++++++++ app/views/list/list.rss.erb | 2 +- app/views/topics/show.html.erb | 6 +++--- app/views/topics/show.rss.erb | 4 ++-- 10 files changed, 22 insertions(+), 13 deletions(-) diff --git a/app/models/category.rb b/app/models/category.rb index 91b247355..de46c3e19 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -373,7 +373,7 @@ SQL def url url = @@url_cache[self.id] unless url - url = "/c" + url = "#{Discourse.base_uri}/c" url << "/#{parent_category.slug}" if parent_category_id url << "/#{slug}" url.freeze diff --git a/app/models/topic.rb b/app/models/topic.rb index a61cc8196..899246f8c 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -685,7 +685,7 @@ class Topic < ActiveRecord::Base # NOTE: These are probably better off somewhere else. # Having a model know about URLs seems a bit strange. def last_post_url - "/t/#{slug}/#{id}/#{posts_count}" + "#{Discourse.base_uri}/t/#{slug}/#{id}/#{posts_count}" end def self.url(id, slug, post_number=nil) @@ -699,7 +699,7 @@ class Topic < ActiveRecord::Base end def relative_url(post_number=nil) - url = "/t/#{slug}/#{id}" + url = "#{Discourse.base_uri}/t/#{slug}/#{id}" url << "/#{post_number}" if post_number.to_i > 1 url end diff --git a/app/views/application/_header.html.erb b/app/views/application/_header.html.erb index ddcb6da88..2fdcd3154 100644 --- a/app/views/application/_header.html.erb +++ b/app/views/application/_header.html.erb @@ -3,7 +3,7 @@
- + "> <%- if application_logo_url.present? %> <%- else %> diff --git a/app/views/categories/index.html.erb b/app/views/categories/index.html.erb index 3ffbc4c59..142bc7d0a 100644 --- a/app/views/categories/index.html.erb +++ b/app/views/categories/index.html.erb @@ -3,7 +3,7 @@ <% @list.categories.each do |c| %>
-

+

<%= c.name %>

<%= c.description %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 12d954e73..479ee1f5a 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -44,7 +44,7 @@