diff --git a/app/controllers/list_controller.rb b/app/controllers/list_controller.rb index bef7a75a0dc..2cc46690847 100644 --- a/app/controllers/list_controller.rb +++ b/app/controllers/list_controller.rb @@ -62,8 +62,8 @@ class ListController < ApplicationController list = TopicQuery.new(user, list_opts).public_send("list_#{filter}") - list.more_topics_url = construct_next_url_with(list_opts) - list.prev_topics_url = construct_prev_url_with(list_opts) + list.more_topics_url = construct_url_with(:next, list_opts) + list.prev_topics_url = construct_url_with(:prev, list_opts) if Discourse.anonymous_filters.include?(filter) @description = SiteSetting.site_description @rss = filter @@ -122,8 +122,8 @@ class ListController < ApplicationController guardian.ensure_can_see_private_messages!(target_user.id) unless action == :topics_by list = generate_list_for(action.to_s, target_user, list_opts) url_prefix = "topics" unless action == :topics_by - list.more_topics_url = url_for(construct_next_url_with(list_opts, url_prefix)) - list.prev_topics_url = url_for(construct_prev_url_with(list_opts, url_prefix)) + list.more_topics_url = url_for(construct_url_with(:next, list_opts, url_prefix)) + list.prev_topics_url = url_for(construct_url_with(:prev, list_opts, url_prefix)) respond_with_list(list) end end @@ -167,8 +167,8 @@ class ListController < ApplicationController user = list_target_user list = TopicQuery.new(user, top_options).list_top_for(period) list.for_period = period - list.more_topics_url = construct_next_url_with(top_options) - list.prev_topics_url = construct_prev_url_with(top_options) + list.more_topics_url = construct_url_with(:next, top_options) + list.prev_topics_url = construct_url_with(:prev, top_options) if use_crawler_layout? @title = I18n.t("js.filters.top.#{period}.title") @@ -280,14 +280,14 @@ class ListController < ApplicationController TopicQuery.new(current_user, opts).send("list_#{action}", target_user) end - def construct_next_url_with(opts, url_prefix = nil) + def construct_url_with(action, opts, url_prefix = nil) method = url_prefix.blank? ? "#{action_name}_path" : "#{url_prefix}_#{action_name}_path" - public_send(method, opts.merge(next_page_params(opts))) - end - - def construct_prev_url_with(opts, url_prefix = nil) - method = url_prefix.blank? ? "#{action_name}_path" : "#{url_prefix}_#{action_name}_path" - public_send(method, opts.merge(prev_page_params(opts))) + url = if action == :prev + public_send(method, opts.merge(prev_page_params(opts))) + else # :next + public_send(method, opts.merge(next_page_params(opts))) + end + url.sub('.json?','?') end def generate_top_lists(options) diff --git a/app/helpers/topics_helper.rb b/app/helpers/topics_helper.rb index 8ad809ef62b..cb330dcf2bc 100644 --- a/app/helpers/topics_helper.rb +++ b/app/helpers/topics_helper.rb @@ -4,4 +4,18 @@ module TopicsHelper link_to(topic.title,topic.relative_url) end + def categories_breadcrumb(topic) + breadcrumb = [{url: categories_path, + name: I18n.t('js.filters.categories.title')}] + + category = topic.category + if category + if (parent = category.parent_category) + breadcrumb.push url: parent.url, name: parent.name + end + breadcrumb.push url: category.url, name: category.name + end + breadcrumb + end + end diff --git a/app/views/categories/index.html.erb b/app/views/categories/index.html.erb index 2b189514a6e..3ffbc4c5926 100644 --- a/app/views/categories/index.html.erb +++ b/app/views/categories/index.html.erb @@ -1,14 +1,26 @@ -<% @list.categories.each do |c| %> -
-

"><%= c.name %>

-
- <%- if c.displayable_topics.present? %> - <% c.displayable_topics.each do |t| %> - <%= t.title %> '>(<%= t.posts_count %>)
- <% end %> - <%- end %> +
+ + <% @list.categories.each do |c| %> +
+ +

+ <%= c.name %> +

+ <%= c.description %> +
+ <%- if c.displayable_topics.present? %> + <% c.displayable_topics.each do |t| %> +
+ + + <%= t.title %> + '>(<%= t.posts_count %>) +
+ <% end %> + <%- end %> +
-
-<% end %> + <% end %> +
<% content_for :title do %><%= I18n.t('js.filters.categories.title') %><% end %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index baf1f7cbd0b..0588911879f 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -42,7 +42,17 @@ <%= yield %> +
+ diff --git a/app/views/layouts/crawler.html.erb b/app/views/layouts/crawler.html.erb index c4d7dc14da8..3a448be1910 100644 --- a/app/views/layouts/crawler.html.erb +++ b/app/views/layouts/crawler.html.erb @@ -25,6 +25,13 @@ <%= yield %> <%= render_google_analytics_code %> diff --git a/app/views/list/list.erb b/app/views/list/list.erb index 966c863f5fa..c6ff86bb0c5 100644 --- a/app/views/list/list.erb +++ b/app/views/list/list.erb @@ -1,21 +1,26 @@ -
-<% @list.topics.each do |t| %> - <%= t.title %> - <% if !@category && t.category %> - [<%= t.category.name %>] +
+ + <% @list.topics.each_with_index do |t,i| %> +
+ + + <%= t.title %> + + <% if !@category && t.category %> + [<%= t.category.name %>] + <% end %> + '>(<%= t.posts_count %>) +
<% end %> - '>(<%= t.posts_count %>)
-<% end %>
- <% if @list.topics.length > 0 && @list.more_topics_url %> -

- <% if params[:page].to_i > 0 %> -   - <% end %> - -

+
+ <% if params[:page].to_i > 0 %> + + <% end %> + +
<% end %> <% if @rss %> diff --git a/app/views/static/show.html.erb b/app/views/static/show.html.erb index e6aa2892e5d..2f73233a038 100644 --- a/app/views/static/show.html.erb +++ b/app/views/static/show.html.erb @@ -1,20 +1,24 @@ - -<% if staff? %> -

<%=t "edit_this_page" -%>

-<% end %> - -<%= @body.html_safe %> +
+ <%= @body.html_safe %> +
+
<% if @title %> <% content_for :title do %><%= @title %><% end %> diff --git a/app/views/topics/show.html.erb b/app/views/topics/show.html.erb index 846bdc38c8a..11b16051fe5 100644 --- a/app/views/topics/show.html.erb +++ b/app/views/topics/show.html.erb @@ -1,40 +1,52 @@

- <%= render_topic_title(@topic_view.topic) %> + <%= render_topic_title(@topic_view.topic) %>

-<% if c = @topic_view.topic.category %> - <%= link_to c.name, c.url %> -<% end %> -
+ +
+ <% categories_breadcrumb(@topic_view.topic).each_with_index do |c,i| %> + + <%= link_to c[:url], itemprop: 'item' do %> + <%= c[:name] %> + <% end %> + + + <% end %> +
+
<% @topic_view.posts.each do |post| %> - <% if post.user %> -
- <%= post.user.username %> - <%= "(#{post.user.name})" if (SiteSetting.display_name_on_posts && SiteSetting.enable_names?) %> — - <%= post.created_at.to_formatted_s(:iso8601) %> — - #<%= post.post_number %> -
-
- <% if post.hidden %> - <%= t('flagging.user_must_edit').html_safe %> - <% else %> - <%= post.cooked.html_safe %> - <% end %> -
-
- <% end %> +
+ <% if (u = post.user) %> +
+ + + <%= "(#{u.name})" if (SiteSetting.display_name_on_posts && SiteSetting.enable_names? && !u.name.blank?) %> + + + #<%= post.post_number %> +
+
+ <%= post.hidden ? t('flagging.user_must_edit').html_safe : post.cooked.html_safe %> +
+ + +
+ <% end %> +
<% end %> - -

- <% if @topic_view.prev_page %> - <%= link_to t(:prev_page), @topic_view.prev_page_path, rel: 'prev' %> - <% end %> - <% if @topic_view.next_page %> - <%= link_to t(:next_page), @topic_view.next_page_path, rel: 'next' %> - <% end %> -

- +<% if @topic_view.prev_page || @topic_view.next_page %> +
+ <% if @topic_view.prev_page %> + + <% end %> + <% if @topic_view.next_page %> + + <% end %> +
+<% end %> <% content_for :head do %> <%= auto_discovery_link_tag(@topic_view, {action: :feed, slug: @topic_view.topic.slug, topic_id: @topic_view.topic.id}, title: t('rss_posts_in_topic', topic: @topic_view.title), type: 'application/rss+xml') %> diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index c366ac77d8f..c7abd8d7137 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -160,6 +160,7 @@ en: next_page: "next page →" prev_page: "← previous page" page_num: "Page %{num}" + home_title: "Home" topics_in_category: "Topics in the '%{category}' category" rss_posts_in_topic: "RSS feed of '%{topic}'" rss_topics_in_category: "RSS feed of topics in the '%{category}' category" diff --git a/config/routes.rb b/config/routes.rb index e46d73fb5b2..9c6fe01f5f0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -224,9 +224,9 @@ Discourse::Application.routes.draw do get "login" => "static#show", id: "login" get "password-reset" => "static#show", id: "password_reset" get "faq" => "static#show", id: "faq" - get "guidelines" => "static#show", id: "guidelines" - get "tos" => "static#show", id: "tos" - get "privacy" => "static#show", id: "privacy" + get "guidelines" => "static#show", id: "guidelines", as: 'guidelines' + get "tos" => "static#show", id: "tos", as: 'tos' + get "privacy" => "static#show", id: "privacy", as: 'privacy' get "signup" => "list#latest" post "users/read-faq" => "users#read_faq" diff --git a/lib/crawler_detection.rb b/lib/crawler_detection.rb index d4bdac727d0..3b8b20ce4ec 100644 --- a/lib/crawler_detection.rb +++ b/lib/crawler_detection.rb @@ -1,7 +1,8 @@ module CrawlerDetection # added 'ia_archiver' based on https://meta.discourse.org/t/unable-to-archive-discourse-pages-with-the-internet-archive/21232 # added 'Wayback Save Page' based on https://meta.discourse.org/t/unable-to-archive-discourse-with-the-internet-archive-save-page-now-button/22875 + def self.crawler?(user_agent) - !/Googlebot|Mediapartners|AdsBot|curl|Twitterbot|facebookexternalhit|bingbot|Baiduspider|ia_archiver|Wayback Save Page/.match(user_agent).nil? + !/Googlebot|Mediapartners|AdsBot|curl|Twitterbot|facebookexternalhit|bingbot|Baiduspider|ia_archiver|Wayback Save Page|360Spider/.match(user_agent).nil? end end