A platform for community discussion. Free, open, simple.
FEATURE: Enable Markdown endpoints by default (#43915)
Penar Musaraj5e5f1df030b8
diff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex eb9d2ff1179..24f92ba3c0d 100644--- a/config/locales/server.en.yml+++ b/config/locales/server.en.yml@@ -3178,7 +3178,7 @@ en:enable_invite_modal_with_roles: "Enables a redesigned invite flow that lets admins invite someone directly as an admin. The invitee becomes a moderator on signup and an admin once the inviter confirms via email."update_pending_users_reminder_default: "We are updating the default for the {{setting:pending_users_reminder_delay_minutes}} setting to 30 minutes so that staff are promptly notified when a new member is waiting for approval. If you have previously changed this setting, this change will have no effect."enable_generated_llms_txt: "Generates a concise /llms.txt when no custom file is uploaded. The document describes public discovery routes, the preferred Discourse MCP interface, and responsible agent access. To tune automated access, configure {{setting:slow_down_crawler_user_agents}} and {{setting:slow_down_crawler_rate}}."- experimental_markdown_endpoints: "Serve supported topics and topic lists as Markdown through .md URLs and Accept negotiation. Normal visibility and profile privacy rules always apply."+ enable_markdown_endpoints: "Serve supported topics and topic lists as Markdown through .md URLs and requests with an Accept: text/markdown header. Normal visibility and profile privacy rules always apply."errors:invalid_css_color: "Invalid color. Enter a color name or hex value."diff --git a/config/site_settings.yml b/config/site_settings.ymlindex d084fe6e102..9e85fc47477 100644--- a/config/site_settings.yml+++ b/config/site_settings.yml@@ -4781,10 +4781,16 @@ dashboard:client: trueexperimental:- experimental_markdown_endpoints:+ enable_markdown_endpoints:default: falsehidden: true- area: "experimental"+ client: true+ upcoming_change:+ status: "beta"+ impact: "feature,all_members"+ learn_more_url: "https://meta.discourse.org/t/-/413006"+ allow_enabled_for:+ - everyoneenable_generated_llms_txt:default: falsehidden: truediff --git a/db/migrate/20260921120000_rename_experimental_markdown_endpoints.rb b/db/migrate/20260921120000_rename_experimental_markdown_endpoints.rbnew file mode 100644index 00000000000..60fed8adc39--- /dev/null+++ b/db/migrate/20260921120000_rename_experimental_markdown_endpoints.rb@@ -0,0 +1,19 @@+# frozen_string_literal: true++class RenameExperimentalMarkdownEndpoints < ActiveRecord::Migration[8.0]+ def up+ execute(<<~SQL)+ UPDATE site_settings+ SET name = 'enable_markdown_endpoints'+ WHERE name = 'experimental_markdown_endpoints'+ SQL+ end++ def down+ execute(<<~SQL)+ UPDATE site_settings+ SET name = 'experimental_markdown_endpoints'+ WHERE name = 'enable_markdown_endpoints'+ SQL+ end+enddiff --git a/db/structure.sql b/db/structure.sqlindex 9f754a39397..5c10b624468 100644--- a/db/structure.sql+++ b/db/structure.sql@@ -25405,6 +25405,7 @@ ALTER TABLE ONLY public.ad_plugin_house_ads_groupsSET search_path TO "$user", public;INSERT INTO "schema_migrations" (version) VALUES+('20260921120000'),('20260921081150'),('20260921074918'),('20260921015711'),diff --git a/lib/markdown_endpoint/controller_support.rb b/lib/markdown_endpoint/controller_support.rbindex fcf15174a05..f310baa7cc4 100644--- a/lib/markdown_endpoint/controller_support.rb+++ b/lib/markdown_endpoint/controller_support.rb@@ -48,7 +48,7 @@ module MarkdownEndpointenddef markdown_alternate_url- return unless SiteSetting.experimental_markdown_endpoints+ return unless SiteSetting.enable_markdown_endpointspath = markdown_alternate_pathreturn if path.blank?@@ -79,7 +79,7 @@ module MarkdownEndpointreturn if request.path.end_with?(".md")accept = request.headers["Accept"]- if SiteSetting.experimental_markdown_endpoints && markdown_supported_response? &&+ if SiteSetting.enable_markdown_endpoints && markdown_supported_response? &&AcceptHeader.preferred?(accept)returnenddiff --git a/lib/markdown_endpoint/request_constraint.rb b/lib/markdown_endpoint/request_constraint.rbindex 749d9556908..282b89c8d69 100644--- a/lib/markdown_endpoint/request_constraint.rb+++ b/lib/markdown_endpoint/request_constraint.rb@@ -9,7 +9,7 @@ module MarkdownEndpointenddef matches?(request)- return false unless SiteSetting.experimental_markdown_endpoints+ return false unless SiteSetting.enable_markdown_endpointsreturn true unless @acceptreturn false if request.path.end_with?(".json", ".rss")diff --git a/spec/requests/application_controller_spec.rb b/spec/requests/application_controller_spec.rbindex 32eb44fb579..52c285698dc 100644--- a/spec/requests/application_controller_spec.rb+++ b/spec/requests/application_controller_spec.rb@@ -1964,7 +1964,7 @@ RSpec.describe ApplicationController doit "is not included by default" doget "/latest"expect(response.status).to eq(200)- expect(response.headers["Link"]).to eq(nil)+ expect(response.headers["Link"].to_s).not_to include("rel=preconnect", 'rel="preload"')endcontext "when in preconnect mode" do@@ -1984,7 +1984,7 @@ RSpec.describe ApplicationController doexpect(response.headers["X-Discourse-Early-Hint"]).to include("<https://cdn.example.com>; rel=preconnect",)- expect(response.headers["Link"]).to eq(nil)+ expect(response.headers["Link"].to_s).not_to include("rel=preconnect", 'rel="preload"')endit "is skipped for non-app URLs" dodiff --git a/spec/requests/markdown_directories_spec.rb b/spec/requests/markdown_directories_spec.rbindex 8fb8b40151f..763eaaffafd 100644--- a/spec/requests/markdown_directories_spec.rb+++ b/spec/requests/markdown_directories_spec.rb@@ -9,10 +9,7 @@ RSpec.describe "Markdown directories" doFabricate(:tag, public_topic_count: 1, staff_topic_count: 1, description: "A useful tag.")end- before do- SiteSetting.experimental_markdown_endpoints = true- SiteSetting.tagging_enabled = true- end+ before { SiteSetting.tagging_enabled = true }after { category.clear_url_cache }@@ -210,7 +207,7 @@ RSpec.describe "Markdown directories" doendit "keeps directories behind the Markdown feature setting" do- SiteSetting.experimental_markdown_endpoints = false+ SiteSetting.enable_markdown_endpoints = false%w[categories tags].each do |directory|get "/#{directory}.md"expect(response).to have_http_status(:not_found)diff --git a/spec/requests/markdown_endpoints_spec.rb b/spec/requests/markdown_endpoints_spec.rbindex 38b89c62f3b..9b927f6fd21 100644--- a/spec/requests/markdown_endpoints_spec.rb+++ b/spec/requests/markdown_endpoints_spec.rb@@ -10,14 +10,32 @@ RSpec.describe "Markdown endpoints" doendfab!(:post) { Fabricate(:post, topic: topic, user: user, raw: "Visible body") }- before { SiteSetting.experimental_markdown_endpoints = true }after { category.clear_url_cache }+ it "respects the upcoming change promotion policy and explicit opt-in" do+ SiteSetting.promote_upcoming_changes_on_status = "stable"++ get "/latest.md"+ expect(response).to have_http_status(:not_found)++ get "/latest", headers: { "ACCEPT" => "text/html" }+ expect(response.headers["Link"]).to be_blank++ SiteSetting.enable_markdown_endpoints = true++ get "/latest.md"+ expect(response).to have_http_status(:ok)+ expect(response.media_type).to eq("text/markdown")++ get "/latest", headers: { "ACCEPT" => "text/html" }+ expect(response.headers["Link"]).to include("/latest.md")+ end+it "keeps HTML tag-intersection redirects out of Markdown routes" dotag = Fabricate(:tag)[false, true].each do |enabled|- SiteSetting.experimental_markdown_endpoints = enabled+ SiteSetting.enable_markdown_endpoints = enabledget "/tags/intersection/#{tag.name}/#{tag.name}", headers: { "ACCEPT" => "text/html" }expect(response).to redirect_to("/tag/#{tag.name}")follow_redirect!@@ -848,7 +866,7 @@ RSpec.describe "Markdown endpoints" doendit "keeps Markdown routes and discovery absent while disabled" do- SiteSetting.experimental_markdown_endpoints = false+ SiteSetting.enable_markdown_endpoints = falsesign_in(user)%w[/new /unread].each do |path|