From 08a1e6b9a73ccd9994917b63efc952dc723e589c Mon Sep 17 00:00:00 2001 From: Francois Date: Fri, 6 Oct 2023 17:31:34 +0200 Subject: [PATCH] ISSUE-21: Index all pages (not just blog pages) (#27) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously we only included links that end with `.html` from the different sitemaps. Now we include all pages. The same conditions used to exclude some specifig pages from our index has been left in place. We also exclude URLs with a hash param. Reject condition: `x.match?(/#.+\z/) || x.include?('page') || x.include?('/tags/') || x.include?('author')` We removed the where condition in the links_controller. Now links without published_at will show. This also means that links without  published_at will appear at the top of the links page. See: https://stackoverflow.com/a/44912964 See: https://github.com/fastruby/librarian/issues/21 --- app/controllers/links_controller.rb | 2 +- app/models/link.rb | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/links_controller.rb b/app/controllers/links_controller.rb index ae76e62..960b3d5 100644 --- a/app/controllers/links_controller.rb +++ b/app/controllers/links_controller.rb @@ -8,7 +8,7 @@ def index else Link end - @links = scope.where("published_at IS NOT NULL").order(published_at: "DESC") + @links = scope.order("published_at DESC NULLS LAST") end # GET /links/1 diff --git a/app/models/link.rb b/app/models/link.rb index f3bb7eb..826f340 100644 --- a/app/models/link.rb +++ b/app/models/link.rb @@ -8,7 +8,9 @@ class Link < ApplicationRecord class << self def find_urls(sitemap) - sitemap.to_a.select {|x| x.end_with? ".html" }.reject {|x| x.include?("page") || x.include?("/tags/") || x.include?("author") } + sitemap.to_a.reject do |x| + x.match?(/#.+\z/) || x.include?('page') || x.include?('/tags/') || x.include?('author') + end end def find_description(page)