From b80113514a132c573746c100d0da4e31382bc2f9 Mon Sep 17 00:00:00 2001 From: driveton Date: Thu, 26 Feb 2026 13:06:19 -0300 Subject: [PATCH 1/3] Add SEO meta description tags and expand LLM endpoint --- app/controllers/llms_controller.rb | 2 +- app/views/books/show.html.erb | 1 + app/views/leafables/show.html.erb | 1 + app/views/llms/show.text.erb | 9 +++++++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/controllers/llms_controller.rb b/app/controllers/llms_controller.rb index 024c24a..502172e 100644 --- a/app/controllers/llms_controller.rb +++ b/app/controllers/llms_controller.rb @@ -2,7 +2,7 @@ class LlmsController < ApplicationController allow_unauthenticated_access def show - @books = Book.published.ordered + @books = Book.accessable_or_published.ordered.includes(leaves: :leafable) render content_type: "text/plain" end end diff --git a/app/views/books/show.html.erb b/app/views/books/show.html.erb index 165993d..d419d19 100644 --- a/app/views/books/show.html.erb +++ b/app/views/books/show.html.erb @@ -2,6 +2,7 @@ <% @layout_class = "book" %> <% content_for :head do %> + <%= tag.meta name: "description", content: (@book.subtitle.presence || @book.title) %> <%= tag.meta property: "og:title", content: @book.title %> <%= tag.meta property: "og:description", content: @book.subtitle %> <%= tag.meta property: "og:image", content: @book.cover.blank? ? asset_url("covers/cover-#{@book.theme}-og.png") : "#{root_url}#{url_for(@book.cover)}" %> diff --git a/app/views/leafables/show.html.erb b/app/views/leafables/show.html.erb index 3d699c8..1939426 100644 --- a/app/views/leafables/show.html.erb +++ b/app/views/leafables/show.html.erb @@ -1,6 +1,7 @@ <% content_for(:title) { page_title(@leaf, @book) } %> <% content_for :head do %> + <%= tag.meta name: "description", content: leaf_og_description(@leaf, @book) %> <%= tag.meta property: "og:title", content: page_title(@leaf, @book) %> <%= tag.meta property: "og:description", content: leaf_og_description(@leaf, @book) %> <%= tag.meta property: "og:url", content: leafable_slug_url(@leaf) %> diff --git a/app/views/llms/show.text.erb b/app/views/llms/show.text.erb index 9d6793f..e06cb9e 100644 --- a/app/views/llms/show.text.erb +++ b/app/views/llms/show.text.erb @@ -6,3 +6,12 @@ <% @books.each do |book| %> - [<%= book.title %>](<%= book_slug_url(book) %>)<%= book.subtitle.present? ? " — #{book.subtitle}" : "" %><%= book.author.present? ? " by #{book.author}" : "" %> <% end %> +<% @books.each do |book| %> + +--- + +## [<%= book.title %>](<%= book_slug_url(book) %>) +<% book.leaves.active.positioned.each do |leaf| %> +- [<%= leaf.title %>](<%= leafable_slug_url(leaf) %>) +<% end %> +<% end %> From f6f189114f65fd4c3ba5eabc23b6b9885f3104e2 Mon Sep 17 00:00:00 2001 From: driveton Date: Thu, 26 Feb 2026 13:14:56 -0300 Subject: [PATCH 2/3] Fix double-slash in og:image and twitter:image URLs --- app/helpers/leaves_helper.rb | 4 ++-- app/views/books/show.html.erb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/helpers/leaves_helper.rb b/app/helpers/leaves_helper.rb index 90fe652..9897e0f 100644 --- a/app/helpers/leaves_helper.rb +++ b/app/helpers/leaves_helper.rb @@ -12,9 +12,9 @@ def leaf_og_description(leaf, book) def leaf_og_image(leaf, book) if leaf.picture? && leaf.picture.image.attached? - "#{root_url}#{url_for(leaf.picture.image)}" + url_for(leaf.picture.image) elsif book.cover.attached? - "#{root_url}#{url_for(book.cover)}" + url_for(book.cover) else asset_url("covers/cover-#{book.theme}-og.png") end diff --git a/app/views/books/show.html.erb b/app/views/books/show.html.erb index d419d19..872320e 100644 --- a/app/views/books/show.html.erb +++ b/app/views/books/show.html.erb @@ -5,12 +5,12 @@ <%= tag.meta name: "description", content: (@book.subtitle.presence || @book.title) %> <%= tag.meta property: "og:title", content: @book.title %> <%= tag.meta property: "og:description", content: @book.subtitle %> - <%= tag.meta property: "og:image", content: @book.cover.blank? ? asset_url("covers/cover-#{@book.theme}-og.png") : "#{root_url}#{url_for(@book.cover)}" %> + <%= tag.meta property: "og:image", content: @book.cover.blank? ? asset_url("covers/cover-#{@book.theme}-og.png") : url_for(@book.cover) %> <%= tag.meta property: "og:url", content: book_slug_url(@book) %> <%= tag.meta property: "twitter:title", content: @book.title %> <%= tag.meta property: "twitter:description", content: @book.subtitle %> - <%= tag.meta property: "twitter:image", content: @book.cover.blank? ? asset_url("covers/cover-#{@book.theme}-og.png") : "#{root_url}#{url_for(@book.cover)}" %> + <%= tag.meta property: "twitter:image", content: @book.cover.blank? ? asset_url("covers/cover-#{@book.theme}-og.png") : url_for(@book.cover) %> <%= tag.meta property: "twitter:card", content: "summary_large_image" %> <% end %> From 22fbdc71fe664928df7b5ab727703b769e7dfd0c Mon Sep 17 00:00:00 2001 From: driveton Date: Thu, 26 Feb 2026 13:18:48 -0300 Subject: [PATCH 3/3] Fall back to book title when subtitle is absent in og/twitter description tags --- app/views/books/show.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/books/show.html.erb b/app/views/books/show.html.erb index 872320e..2250282 100644 --- a/app/views/books/show.html.erb +++ b/app/views/books/show.html.erb @@ -4,12 +4,12 @@ <% content_for :head do %> <%= tag.meta name: "description", content: (@book.subtitle.presence || @book.title) %> <%= tag.meta property: "og:title", content: @book.title %> - <%= tag.meta property: "og:description", content: @book.subtitle %> + <%= tag.meta property: "og:description", content: (@book.subtitle.presence || @book.title) %> <%= tag.meta property: "og:image", content: @book.cover.blank? ? asset_url("covers/cover-#{@book.theme}-og.png") : url_for(@book.cover) %> <%= tag.meta property: "og:url", content: book_slug_url(@book) %> <%= tag.meta property: "twitter:title", content: @book.title %> - <%= tag.meta property: "twitter:description", content: @book.subtitle %> + <%= tag.meta property: "twitter:description", content: (@book.subtitle.presence || @book.title) %> <%= tag.meta property: "twitter:image", content: @book.cover.blank? ? asset_url("covers/cover-#{@book.theme}-og.png") : url_for(@book.cover) %> <%= tag.meta property: "twitter:card", content: "summary_large_image" %>