mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FIX: crawler pages and RSS had broken links for sites deployed to a subfolder with relative_url_root
This commit is contained in:
parent
e9b70ac9cb
commit
1b250f1e01
10 changed files with 22 additions and 13 deletions
|
@ -373,7 +373,7 @@ SQL
|
||||||
def url
|
def url
|
||||||
url = @@url_cache[self.id]
|
url = @@url_cache[self.id]
|
||||||
unless url
|
unless url
|
||||||
url = "/c"
|
url = "#{Discourse.base_uri}/c"
|
||||||
url << "/#{parent_category.slug}" if parent_category_id
|
url << "/#{parent_category.slug}" if parent_category_id
|
||||||
url << "/#{slug}"
|
url << "/#{slug}"
|
||||||
url.freeze
|
url.freeze
|
||||||
|
|
|
@ -685,7 +685,7 @@ class Topic < ActiveRecord::Base
|
||||||
# NOTE: These are probably better off somewhere else.
|
# NOTE: These are probably better off somewhere else.
|
||||||
# Having a model know about URLs seems a bit strange.
|
# Having a model know about URLs seems a bit strange.
|
||||||
def last_post_url
|
def last_post_url
|
||||||
"/t/#{slug}/#{id}/#{posts_count}"
|
"#{Discourse.base_uri}/t/#{slug}/#{id}/#{posts_count}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.url(id, slug, post_number=nil)
|
def self.url(id, slug, post_number=nil)
|
||||||
|
@ -699,7 +699,7 @@ class Topic < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def relative_url(post_number=nil)
|
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 << "/#{post_number}" if post_number.to_i > 1
|
||||||
url
|
url
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<div class="contents">
|
<div class="contents">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="title span13">
|
<div class="title span13">
|
||||||
<a href="/">
|
<a href="<%= path "/" %>">
|
||||||
<%- if application_logo_url.present? %>
|
<%- if application_logo_url.present? %>
|
||||||
<img src="<%= application_logo_url %>" alt="<%= SiteSetting.title %>" id="site-logo">
|
<img src="<%= application_logo_url %>" alt="<%= SiteSetting.title %>" id="site-logo">
|
||||||
<%- else %>
|
<%- else %>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<% @list.categories.each do |c| %>
|
<% @list.categories.each do |c| %>
|
||||||
<div class='category' itemprop='itemListElement' itemscope itemtype='http://schema.org/ListItem'>
|
<div class='category' itemprop='itemListElement' itemscope itemtype='http://schema.org/ListItem'>
|
||||||
<meta itemprop='url' content='<%= c.url %>'>
|
<meta itemprop='url' content='<%= c.url %>'>
|
||||||
<h2><a href='/c/<%= c.slug.blank? ? c.id : c.slug %>' itemprop='item'>
|
<h2><a href='<%= c.url %>' itemprop='item'>
|
||||||
<span itemprop='name'><%= c.name %></span>
|
<span itemprop='name'><%= c.name %></span>
|
||||||
</a></h2>
|
</a></h2>
|
||||||
<span itemprop='description'><%= c.description %></span>
|
<span itemprop='description'><%= c.description %></span>
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
<!-- :preload-content -->
|
<!-- :preload-content -->
|
||||||
<footer>
|
<footer>
|
||||||
<nav itemscope itemtype='http://schema.org/SiteNavigationElement'>
|
<nav itemscope itemtype='http://schema.org/SiteNavigationElement'>
|
||||||
<a href='/'><%= t 'home_title' %></a>
|
<a href='<%= path "/" %>'><%= t 'home_title' %></a>
|
||||||
<%= link_to t('js.filters.categories.title'), main_app.categories_path %>
|
<%= link_to t('js.filters.categories.title'), main_app.categories_path %>
|
||||||
<%= link_to t('guidelines_topic.title'), main_app.guidelines_path %>
|
<%= link_to t('guidelines_topic.title'), main_app.guidelines_path %>
|
||||||
<%= link_to t('tos_topic.title'), main_app.tos_path %>
|
<%= link_to t('tos_topic.title'), main_app.tos_path %>
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
</div>
|
</div>
|
||||||
<footer class="container">
|
<footer class="container">
|
||||||
<nav itemscope itemtype='http://schema.org/SiteNavigationElement'>
|
<nav itemscope itemtype='http://schema.org/SiteNavigationElement'>
|
||||||
<a href='/'><%= t 'home_title' %></a>
|
<a href='<%= path "/" %>'><%= t 'home_title' %></a>
|
||||||
<%= link_to t('js.filters.categories.title'), main_app.categories_path %>
|
<%= link_to t('js.filters.categories.title'), main_app.categories_path %>
|
||||||
<%= link_to t('guidelines_topic.title'), main_app.guidelines_path %>
|
<%= link_to t('guidelines_topic.title'), main_app.guidelines_path %>
|
||||||
<%= link_to t('tos_topic.title'), main_app.tos_path %>
|
<%= link_to t('tos_topic.title'), main_app.tos_path %>
|
||||||
|
|
|
@ -1,3 +1,12 @@
|
||||||
|
<% if @category %>
|
||||||
|
<h1>
|
||||||
|
<%= link_to @category.url, itemprop: 'item' do %>
|
||||||
|
<span itemprop='name'><%= @category.name %></span>
|
||||||
|
<% end %>
|
||||||
|
</h1>
|
||||||
|
<br/>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<div class='topic-list' itemscope itemtype='http://schema.org/ItemList'>
|
<div class='topic-list' itemscope itemtype='http://schema.org/ItemList'>
|
||||||
<meta itemprop='itemListOrder' content='http://schema.org/ItemListOrderDescending'>
|
<meta itemprop='itemListOrder' content='http://schema.org/ItemListOrderDescending'>
|
||||||
<% @list.topics.each_with_index do |t,i| %>
|
<% @list.topics.each_with_index do |t,i| %>
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<lastBuildDate><%= @topic_list.topics.first.created_at.rfc2822 %></lastBuildDate>
|
<lastBuildDate><%= @topic_list.topics.first.created_at.rfc2822 %></lastBuildDate>
|
||||||
<atom:link href="<%= @atom_link %>" rel="self" type="application/rss+xml" />
|
<atom:link href="<%= @atom_link %>" rel="self" type="application/rss+xml" />
|
||||||
<% @topic_list.topics.each do |topic| %>
|
<% @topic_list.topics.each do |topic| %>
|
||||||
<% topic_url = Discourse.base_url + topic.relative_url -%>
|
<% topic_url = topic.relative_url -%>
|
||||||
<item>
|
<item>
|
||||||
<title><%= topic.title %></title>
|
<title><%= topic.title %></title>
|
||||||
<author><%= "no-reply@example.com (@#{topic.user.username}#{" #{topic.user.name}" if (topic.user.name.present? && SiteSetting.enable_names?)})" -%></author>
|
<author><%= "no-reply@example.com (@#{topic.user.username}#{" #{topic.user.name}" if (topic.user.name.present? && SiteSetting.enable_names?)})" -%></author>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<h2>
|
<h1>
|
||||||
<%= render_topic_title(@topic_view.topic) %>
|
<%= render_topic_title(@topic_view.topic) %>
|
||||||
</h2>
|
</h1>
|
||||||
|
|
||||||
<div itemscope itemtype='http://schema.org/BreadcrumbList'>
|
<div itemscope itemtype='http://schema.org/BreadcrumbList'>
|
||||||
<% categories_breadcrumb(@topic_view.topic).each_with_index do |c,i| %>
|
<% categories_breadcrumb(@topic_view.topic).each_with_index do |c,i| %>
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
<% if (u = post.user) %>
|
<% if (u = post.user) %>
|
||||||
<div class='creator'>
|
<div class='creator'>
|
||||||
<span>
|
<span>
|
||||||
<a href='/users/<%= u.username %>'><b itemprop='author'><%= u.username %></b></a>
|
<a href='<%= Discourse.base_uri %>/users/<%= u.username %>'><b itemprop='author'><%= u.username %></b></a>
|
||||||
<%= "(#{u.name})" if (SiteSetting.display_name_on_posts && SiteSetting.enable_names? && !u.name.blank?) %>
|
<%= "(#{u.name})" if (SiteSetting.display_name_on_posts && SiteSetting.enable_names? && !u.name.blank?) %>
|
||||||
<time datetime='<%= post.created_at.to_formatted_s(:iso8601) %>' itemprop='datePublished'>
|
<time datetime='<%= post.created_at.to_formatted_s(:iso8601) %>' itemprop='datePublished'>
|
||||||
<%= post.created_at %>
|
<%= post.created_at %>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||||
<channel>
|
<channel>
|
||||||
<% topic_url = Discourse.base_url + @topic_view.relative_url %>
|
<% topic_url = @topic_view.relative_url %>
|
||||||
<% lang = SiteSetting.find_by_name('default_locale').try(:value) %>
|
<% lang = SiteSetting.find_by_name('default_locale').try(:value) %>
|
||||||
<% site_email = SiteSetting.find_by_name('contact_email').try(:value) %>
|
<% site_email = SiteSetting.find_by_name('contact_email').try(:value) %>
|
||||||
<title><%= @topic_view.title %></title>
|
<title><%= @topic_view.title %></title>
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
<link><%= post_url %></link>
|
<link><%= post_url %></link>
|
||||||
<pubDate><%= post.created_at.rfc2822 %></pubDate>
|
<pubDate><%= post.created_at.rfc2822 %></pubDate>
|
||||||
<guid isPermaLink="false">post-<%= post.topic_id %>-<%= post.post_number %></guid>
|
<guid isPermaLink="false">post-<%= post.topic_id %>-<%= post.post_number %></guid>
|
||||||
<source url="<%= Discourse.base_url %><%= @topic_view.relative_url %>.rss"><%= @topic_view.title %></source>
|
<source url="<%= @topic_view.relative_url %>.rss"><%= @topic_view.title %></source>
|
||||||
</item>
|
</item>
|
||||||
<% end %>
|
<% end %>
|
||||||
</channel>
|
</channel>
|
||||||
|
|
Loading…
Reference in a new issue