diff --git a/app/assets/stylesheets/sidebar-data.scss b/app/assets/stylesheets/sidebar-data.scss index 08a13b15d..20d087e40 100644 --- a/app/assets/stylesheets/sidebar-data.scss +++ b/app/assets/stylesheets/sidebar-data.scss @@ -16,4 +16,16 @@ margin-top: 5px; border-radius: 3px; } + hr { + opacity: 0.3; + margin: 25px 0px 15px; + width: 200px; + } + .olderposts-header { + margin-bottom: 5px; + } + .olderposts-pagenumber { + padding: 8px; + margin-right: -8px; + } } diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb index e44261787..7e6441c30 100644 --- a/app/controllers/stories_controller.rb +++ b/app/controllers/stories_controller.rb @@ -11,6 +11,8 @@ class StoriesController < ApplicationController ] }.freeze + SIGNED_OUT_RECORD_COUNT = (Rails.env.production? ? 60 : 10).freeze + before_action :authenticate_user!, except: %i[index search show] before_action :set_cache_control_headers, only: %i[index search show] @@ -112,6 +114,7 @@ class StoriesController < ApplicationController def handle_tag_index @tag = params[:tag].downcase + @page = (params[:page] || 1).to_i @tag_model = Tag.find_by(name: @tag) || not_found @moderators = User.with_role(:tag_moderator, @tag_model).select(:username, :profile_image, :id) if @tag_model.alias_for.present? @@ -122,10 +125,11 @@ class StoriesController < ApplicationController @num_published_articles = if @tag_model.requires_approval? Article.published.cached_tagged_by_approval_with(@tag).size else - Article.published.cached_tagged_with(@tag).size + Article.published.cached_tagged_with(@tag).where("score > 2").size end - number_of_articles = user_signed_in? ? 5 : 45 - @stories = Articles::Feed.new(number_of_articles: number_of_articles, tag: @tag).published_articles_by_tag + @number_of_articles = user_signed_in? ? 5 : SIGNED_OUT_RECORD_COUNT + @stories = Articles::Feed.new(number_of_articles: @number_of_articles, tag: @tag, page: @page). + published_articles_by_tag @stories = @stories.where(approved: true) if @tag_model&.requires_approval @@ -293,7 +297,7 @@ class StoriesController < ApplicationController @stories = ArticleDecorator.decorate_collection(@user.articles.published. limited_column_select. where.not(id: @pinned_stories.pluck(:id)). - order("published_at DESC").page(@page).per(user_signed_in? ? 2 : 20)) + order("published_at DESC").page(@page).per(user_signed_in? ? 2 : SIGNED_OUT_RECORD_COUNT)) end def stories_by_timeframe @@ -301,9 +305,9 @@ class StoriesController < ApplicationController @stories.where("published_at > ?", Timeframer.new(params[:timeframe]).datetime). order("positive_reactions_count DESC") elsif params[:timeframe] == "latest" - @stories.where("score > ?", -40).order("published_at DESC") + @stories.where("score > ?", -20).order("published_at DESC") else - @stories.order("hotness_score DESC") + @stories.order("hotness_score DESC").where("score > 2") end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e0089a392..56d7a75d9 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -169,6 +169,10 @@ module ApplicationHelper URL.url(uri) end + def tag_url(tag, page) + URL.tag(tag, page) + end + def article_url(article) URL.article(article) end diff --git a/app/lib/url.rb b/app/lib/url.rb index f1e1bcae5..188cd2fd0 100644 --- a/app/lib/url.rb +++ b/app/lib/url.rb @@ -30,6 +30,13 @@ module URL url(article.path) end + # Creates an article URL + # + # @param tag [Tag] the tag to create the URL for + def self.tag(tag, page = 1) + url(["/t/#{tag.name}", ("/page/#{page}" if page > 1)].join) + end + # Creates a user URL # # @param user [User] the user to create the URL for diff --git a/app/services/articles/feed.rb b/app/services/articles/feed.rb index c76825f4e..a66d573fe 100644 --- a/app/services/articles/feed.rb +++ b/app/services/articles/feed.rb @@ -40,7 +40,7 @@ module Articles def latest_feed published_articles_by_tag.order("published_at DESC"). - where("featured_number > ? AND score > ?", 1_449_999_999, -40). + where("featured_number > ? AND score > ?", 1_449_999_999, -20). page(@page).per(@number_of_articles) end diff --git a/app/views/articles/tags/_meta.html.erb b/app/views/articles/tags/_meta.html.erb index e6783af12..051979b16 100644 --- a/app/views/articles/tags/_meta.html.erb +++ b/app/views/articles/tags/_meta.html.erb @@ -3,20 +3,20 @@ timeframe: params[:timeframe], content_for: true, ) %> - - - + +"> + - + - - +" /> + Community" /> - +"> <% if @tag_model %> diff --git a/app/views/articles/tags/_sidebar.html.erb b/app/views/articles/tags/_sidebar.html.erb index 656482a03..49a81deb4 100644 --- a/app/views/articles/tags/_sidebar.html.erb +++ b/app/views/articles/tags/_sidebar.html.erb @@ -76,6 +76,22 @@ MODERATE + <% else %> + <% number_of_pages = @num_published_articles / @number_of_articles %> + <% if number_of_pages > 1 %> +
+
Older #<%= @tag %> posts
+ + <% end %> <% end %> diff --git a/app/views/articles/tags/_sidebar_additional.html.erb b/app/views/articles/tags/_sidebar_additional.html.erb index be1f7aabd..30406aec8 100644 --- a/app/views/articles/tags/_sidebar_additional.html.erb +++ b/app/views/articles/tags/_sidebar_additional.html.erb @@ -1,43 +1,45 @@ -