From 1f8586168bc37d04ebca7653f4d672f600bb0d97 Mon Sep 17 00:00:00 2001 From: Robin Ward <robin.ward@gmail.com> Date: Tue, 12 Jan 2016 12:38:49 -0500 Subject: [PATCH] FIX: Incorrect subfolder urls when embedding --- app/models/post.rb | 4 ++++ app/views/embed/comments.html.erb | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index 9092fde836c..746a7a33bbc 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -359,6 +359,10 @@ class Post < ActiveRecord::Base publish_change_to_clients!(:acted) end + def full_url + "#{Discourse.base_url}#{url}" + end + def url if topic Post.url(topic.slug, topic.id, post_number) diff --git a/app/views/embed/comments.html.erb b/app/views/embed/comments.html.erb index 873229a9922..0eb010e407c 100644 --- a/app/views/embed/comments.html.erb +++ b/app/views/embed/comments.html.erb @@ -10,9 +10,9 @@ <%- if @topic_view.posts.present? %> <%- @topic_view.posts.each do |post| %> <article class='post<%- if post.trashed? %> deleted<% end %>' id='post-<%= post.id.to_s %>'> - <%= link_to embed_post_date(post.created_at), post.url, title: post.created_at.strftime("%B %e, %Y %l:%M%P"), class: 'post-date', target: "_blank" %> + <%= link_to embed_post_date(post.created_at), post.full_url, title: post.created_at.strftime("%B %e, %Y %l:%M%P"), class: 'post-date', target: "_blank" %> <%- if post.reply_to_post.present? && !post.cooked.index('aside') %> - <%= link_to I18n.t('embed.in_reply_to', username: post.reply_to_post.username), post.reply_to_post.url, 'data-link-to-post' => post.reply_to_post.id.to_s, :class => 'in-reply-to' %> + <%= link_to I18n.t('embed.in_reply_to', username: post.reply_to_post.username), post.reply_to_post.full_url, 'data-link-to-post' => post.reply_to_post.id.to_s, :class => 'in-reply-to' %> <%- end %> <div class='author'> @@ -29,9 +29,9 @@ <%- if post.reply_count > 0 %> <%- if post.reply_count == 1 %> - <%= link_to I18n.t('embed.replies', count: post.reply_count), post.url, 'data-link-to-post' => post.replies.first.id.to_s, :class => 'post-replies button' %> + <%= link_to I18n.t('embed.replies', count: post.reply_count), post.full_url, 'data-link-to-post' => post.replies.first.id.to_s, :class => 'post-replies button' %> <% else %> - <%= link_to I18n.t('embed.replies', count: post.reply_count), post.url, class: 'post-replies button', target: "_blank" %> + <%= link_to I18n.t('embed.replies', count: post.reply_count), post.full_url, class: 'post-replies button', target: "_blank" %> <%- end %> <%- end %> </div> @@ -41,7 +41,7 @@ <% if @topic_view.topic.posts_count > 0 %> <footer class="clearfix"> <%= link_to(image_tag(SiteSetting.logo_url, class: 'logo'), Discourse.base_url, target: '_blank') %> - <%= link_to(I18n.t('embed.continue'), @topic_view.posts.last.url, class: 'button', target: '_blank') %> + <%= link_to(I18n.t('embed.continue'), @topic_view.posts.last.full_url, class: 'button', target: '_blank') %> <%- if @posts_left > 0 %> <span class='replies'><%= I18n.t('embed.more_replies', count: @posts_left) %></span> <%- end %>