Reference · framework 0.7.3
Snippets: small, tested code to copy.
Recipes you would otherwise look up: a feed, slugs, Markdown, a pager, a theme button, backdated seeds, a public page by slug, a CRUD resource. Read one, copy it by hand, or let snippet add copy and wire it; snippet remove takes it back.
-
atom-feed
GET /feed.xml: an Atom feed (escaped, RFC 3339 dates, newest 20), linked from every page
- Needs
- nothing
- Adds
5 files
src/controllers/feed.rssrc/routes/feed.rssrc/views/feed.rstemplates/feed/atom.xmltests/app/feed_test.rs
cargo offrails snippet show atom-feed cargo offrails snippet add atom-feed cargo offrails snippet remove atom-feed -
markdown
markdown::to_html: CommonMark (tables, strikethrough) rendered by pulldown-cmark, sanitized by ammonia
- Needs
- crates pulldown-cmark and ammonia
- Adds
1 file
src/views/markdown.rs
cargo offrails snippet show markdown cargo offrails snippet add markdown cargo offrails snippet remove markdown -
pagination
PageLinks::new(base, page, more) and shared/_pager.html: the kit's pagination, per kept, ?page clamped
- Needs
- nothing
- Adds
2 files
src/views/pager.rstemplates/shared/_pager.html
cargo offrails snippet show pagination cargo offrails snippet add pagination cargo offrails snippet remove pagination -
public-show-by-slug
GET /read/notes/{slug}: a public page per record, by slug (a path param), slugs unique and stable
- Needs
- the resource and slug snippets
- Adds
7 files
migration/src/m20261018_000200_add_slug_to_notes.rssrc/controllers/note_pages.rssrc/models/note_slugs.rssrc/routes/note_pages.rssrc/views/note_pages.rstemplates/note_pages/show.htmltests/app/note_pages_test.rs
cargo offrails snippet show public-show-by-slug cargo offrails snippet add public-show-by-slug cargo offrails snippet remove public-show-by-slug -
resource
htmx CRUD for one model (notes: title, body): the files
g resourcewrites, split per action, public- Needs
- nothing
- Adds
22 files
migration/src/m20261018_000100_create_notes.rssrc/controllers/notes/destroy.rssrc/controllers/notes/edit.rssrc/controllers/notes/index.rssrc/controllers/notes/mod.rssrc/controllers/notes/new.rssrc/controllers/notes/show.rssrc/models/note/mod.rssrc/models/note/params.rssrc/models/note/queries.rssrc/routes/notes.rssrc/views/notes.rstemplates/notes/_form.htmltemplates/notes/edit.htmltemplates/notes/index.htmltemplates/notes/new.htmltemplates/notes/show.htmltests/app/factories/note.rstests/app/notes/mod.rstests/app/notes/model_test.rstests/app/notes/read_test.rstests/app/notes/write_test.rs
cargo offrails snippet show resource cargo offrails snippet add resource cargo offrails snippet remove resource -
seed-backdated
Seeds with history: create through the model, then backdate::(db, id, days_ago(30)) moves the timestamps
- Needs
- nothing
- Adds
2 files
src/tasks/seed_support.rstests/app/seed_backdated_test.rs
cargo offrails snippet show seed-backdated cargo offrails snippet add seed-backdated cargo offrails snippet remove seed-backdated -
slug
slugify(title) (accents folded, 80 chars) and unique(base, query): -2, -3… unique per owner or global
- Needs
- nothing
- Adds
1 file
src/models/slug.rs
cargo offrails snippet show slug cargo offrails snippet add slug cargo offrails snippet remove slug -
theme-toggle
A System/Light/Dark button in the nav: shared/_theme_toggle.html, a delegated handler in app.js, no-JS POST
- Needs
- nothing
- Adds
2 files
templates/shared/_theme_toggle.htmltests/app/theme_toggle_test.rs
cargo offrails snippet show theme-toggle cargo offrails snippet add theme-toggle cargo offrails snippet remove theme-toggle
This page is also plain Markdown. Agents: the MCP server's list_snippets and read_snippet.