From b60906045519e1ffb26b8a8c0d5eb6ac652c9b26 Mon Sep 17 00:00:00 2001 From: xdite Date: Mon, 11 Feb 2013 19:13:04 +0800 Subject: [PATCH 1/3] use link_to to replace a href --- app/views/topics/show.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/topics/show.html.erb b/app/views/topics/show.html.erb index 09b8906fe29..e7e847ab054 100644 --- a/app/views/topics/show.html.erb +++ b/app/views/topics/show.html.erb @@ -1,5 +1,5 @@

- <%= @topic_view.topic.title %> + <%= link_to(@topic_view.topic.title, @topic_view.topic.relative_url) %>

<% (@post ? [@post] : @topic_view.posts).each do |post| %>
@@ -12,7 +12,7 @@ <% if @next_page%>

- next page + <%= link_to("next page", @topic_view.topic.relative_url + "?page=" + @next_page ) %>

<% end %> From 0f54dbb36e4b5c8936484cef8a0b5654238199d9 Mon Sep 17 00:00:00 2001 From: xdite Date: Mon, 11 Feb 2013 19:15:31 +0800 Subject: [PATCH 2/3] use render_topic_title to replace plain link_to --- app/helpers/topics_helper.rb | 6 ++++++ app/views/topics/show.html.erb | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 app/helpers/topics_helper.rb diff --git a/app/helpers/topics_helper.rb b/app/helpers/topics_helper.rb new file mode 100644 index 00000000000..bd1f3d3b091 --- /dev/null +++ b/app/helpers/topics_helper.rb @@ -0,0 +1,6 @@ +module TopicsHelper + + def render_topic_title(topic) + link_to(topic.title,topic.relative_url) + end +end diff --git a/app/views/topics/show.html.erb b/app/views/topics/show.html.erb index e7e847ab054..57439cbe918 100644 --- a/app/views/topics/show.html.erb +++ b/app/views/topics/show.html.erb @@ -1,5 +1,6 @@

- <%= link_to(@topic_view.topic.title, @topic_view.topic.relative_url) %> + <%= render_topic_title(@topic_view.topic) %> + link_to(@topic_view.topic.title, @topic_view.topic.relative_url)

<% (@post ? [@post] : @topic_view.posts).each do |post| %>
From 00883842f49d39800bf124ed97f7789ed3cbf27e Mon Sep 17 00:00:00 2001 From: xdite Date: Mon, 11 Feb 2013 19:18:17 +0800 Subject: [PATCH 3/3] render_topic_next_page_link --- app/helpers/topics_helper.rb | 4 ++++ app/views/topics/show.html.erb | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/helpers/topics_helper.rb b/app/helpers/topics_helper.rb index bd1f3d3b091..96ec460ccd5 100644 --- a/app/helpers/topics_helper.rb +++ b/app/helpers/topics_helper.rb @@ -3,4 +3,8 @@ module TopicsHelper def render_topic_title(topic) link_to(topic.title,topic.relative_url) end + + def render_topic_next_page_link(topic, next_page) + link_to("next page", topic.relative_url + "?page=" + next_page ) + end end diff --git a/app/views/topics/show.html.erb b/app/views/topics/show.html.erb index 57439cbe918..869cd21c099 100644 --- a/app/views/topics/show.html.erb +++ b/app/views/topics/show.html.erb @@ -1,6 +1,6 @@

<%= render_topic_title(@topic_view.topic) %> - link_to(@topic_view.topic.title, @topic_view.topic.relative_url) +

<% (@post ? [@post] : @topic_view.posts).each do |post| %>
@@ -13,7 +13,7 @@ <% if @next_page%>

- <%= link_to("next page", @topic_view.topic.relative_url + "?page=" + @next_page ) %> + <%= render_topic_next_page_link(@topic_view.topic, @next_page) %>

<% end %>