Class: DocsKit::LlmsController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- DocsKit::LlmsController
- Includes:
- Scoping
- Defined in:
- app/controllers/docs_kit/llms_controller.rb
Overview
Serves the two AI-readable artifacts (llmstxt.org) from the registry, with zero authoring — the host app wires the routes (the engine is glue-only, no routes of its own), so a site keeps full control over path, auth, and omission:
# config/routes.rb
get "/llms.txt" => "docs_kit/llms#index"
get "/llms-full.txt" => "docs_kit/llms#full"
#index → the llms.txt index (brand, tagline, nav-grouped links to each page's
.md twin). #full → llms-full.txt (every page's Markdown concatenated). Both
are text/plain and HTTP-cached: the response revalidates on the registry's
own content plus DocsKit::VERSION, so a page/gem change busts the cache while
an unchanged registry serves a 304.
All the text shaping lives in DocsKit::LlmsText (pure, Rails-free). This controller only threads the Rails view context: #full renders each page to Markdown via DocsKit::MarkdownExport (which needs url helpers/CSRF), then hands the [title, markdown] pairs to LlmsText.full.
Constant Summary collapse
- LLMS_MAX_AGE =
Freshness lifetime for a shared cache (dash-proxy, a CDN).
publicon its own is not storable under RFC 9111 — without a max-age the proxy cache skips the response. 300s matches theproxy.cache.max_ttldocs-kit scaffolds; the etag below still revalidates within that window. 300
Instance Method Summary collapse
Methods included from Scoping
Instance Method Details
#full ⇒ Object
42 43 44 45 46 47 48 |
# File 'app/controllers/docs_kit/llms_controller.rb', line 42 def full pairs = DocsKit::LlmsText.pages(docs_config).map do |page| [page.title, render_page_markdown(page)] end body = DocsKit::LlmsText.full(docs_config, pairs) render_text(body) if stale_llms?(body) end |