Allow subscribers to set a custom robots.txt#945
Draft
lylo wants to merge 4 commits into
Draft
Conversation
Subscribed blogs can override the generated robots.txt via Settings → Blog. The override is served from /robots.txt when present and the owner is subscribed; non-subscribers fall back to the generated default. The settings UI uses a "Use custom robots.txt" checkbox and a textarea inside the existing Blog Settings form — saving and clearing both go through the page-level Update button. Validation covers UTF-8, size, control chars, and the supported directives (User-agent, Allow, Disallow, Sitemap, Crawl-delay).
- Drop bespoke Stimulus controller; use Tailwind group-has-[input:checked] to drive editor visibility from the checkbox state - Fold the use_custom_robots_txt clearing into the existing subscribed? block in blog_params; check params[:use_custom_robots_txt].present? rather than == "1" - Revert unrelated language_select / form render path qualifications
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/robots.txtserves the custom value when present and the owner is subscribed; non-subscribers and lapsed users get the generated defaultImplementation
Blog::RobotsTxtconcern owns generation, normalisation, and validation. Validates UTF-8, 10 KB max, control chars, and the supported directives (User-agent / Allow / Disallow / Sitemap / Crawl-delay)Blogs::RobotsController#showrenders directly from the model (deletesapp/views/blogs/robots/show.text.erb)App::Settings::RobotsControllerexposes PATCH (subscribers only) and DELETE (any owner) on/app/settings/robotsform_withshells via HTML5form="…"association so the controls live inside the existing blog settings formTest plan
bin/rails test test/models/concerns/blog/robots_txt_test.rb test/controllers/blogs/robots_controller_test.rb test/controllers/app/settings/robots_controller_test.rb test/controllers/app/settings/blogs_controller_test.rb/robots.txt/robots.txtfalls back to the defaultUser-agent: *\nDisallow: /Host:,Bad Bot, oversized) is rejected with a field error