diff --git a/.forgejo/workflows/check.yml b/.forgejo/workflows/check.yml deleted file mode 100644 index 538b9f3..0000000 --- a/.forgejo/workflows/check.yml +++ /dev/null @@ -1,23 +0,0 @@ -# SPDX-License-Identifier: GPL-3.0-or-later -# -# Runs `make check` (gofmt, go vet, staticcheck and the tests) on every push to main and on every -# pull request, on the shared runner of git.kmalloc.org. -name: check - -on: - push: - branches: [main] - pull_request: - -jobs: - check: - runs-on: docker - steps: - - uses: https://code.forgejo.org/actions/checkout@v4 - - uses: https://code.forgejo.org/actions/setup-go@v5 - with: - go-version-file: go.mod - - name: Install staticcheck - run: go install honnef.co/go/tools/cmd/staticcheck@latest - - name: Run the checks - run: PATH="$PATH:$(go env GOPATH)/bin" make check diff --git a/CHANGELOG.md b/CHANGELOG.md index 66ddd0a..77eb11c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,3 @@ -## [1.0.1](https://git.kmalloc.org/squid/motorino/compare/v1.0.0...v1.0.1) (2026-11-15) - -### Bug Fixes - -* close the minor findings of the first review ([917683a](https://git.kmalloc.org/squid/motorino/commit/917683afa491c7f0b4331757d6066d215b5f19d9)) -* find code blocks with the Markdown parser and make the escape work everywhere ([4ab8f8d](https://git.kmalloc.org/squid/motorino/commit/4ab8f8d12223fca0db20ec5afee92217533d058b)) - ## 1.0.0 (2026-11-15) ### Features diff --git a/README.md b/README.md index 06b5921..af5a634 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ Pages: `Title`, `ID` (the same in every language, it links the translations), `D ### Placeholders -`{{name}}`, with lowercase letters, digits and underscores, is replaced by a string from `site.json` or the language file. An unknown placeholder stops the build and names the file. Fenced code blocks (found the way CommonMark finds them, in lists and quotes too) are left as written, so an article can show a placeholder there. Anywhere else a backslash before the placeholder (`\{{name}}`) keeps it as written, in a code span too; two backslashes are one literal backslash followed by the value. Code spans are otherwise substituted, which is how a page shows a value in monospace. The id of a heading is not checked against ids that a template writes itself, such as the `news` of the latest news block. `{{news_list}}`, `{{latest_news}}` and `{{categories_list}}` stand alone in a paragraph and expand to generated lists. +`{{name}}`, with lowercase letters, digits and underscores, is replaced by a string from `site.json` or the language file. An unknown placeholder stops the build and names the file. `{{news_list}}`, `{{latest_news}}` and `{{categories_list}}` stand alone in a paragraph and expand to generated lists. ## Development @@ -58,7 +58,7 @@ make build a local binary in bin/motorino make dist the release binary and its SHA-256 in dist/ ``` -Go code has a doc comment on every package and declaration, and is formatted with `gofmt`. Commits follow conventional commits. A Forgejo Actions workflow (`.forgejo/workflows/check.yml`) runs `make check` on every push to `main` and on every pull request, on the shared runner of git.kmalloc.org. +Go code has a doc comment on every package and declaration, and is formatted with `gofmt`. Commits follow conventional commits. ## Release diff --git a/cmd/motorino/main.go b/cmd/motorino/main.go index a1997f1..ce40c01 100644 --- a/cmd/motorino/main.go +++ b/cmd/motorino/main.go @@ -15,7 +15,6 @@ import ( "fmt" "io" "os" - "strings" "git.kmalloc.org/squid/motorino/internal/build" "git.kmalloc.org/squid/motorino/internal/version" @@ -60,10 +59,6 @@ func runBuild(args []string, stdout, stderr io.Writer) int { } return 2 } - if flags.NArg() > 0 { - fmt.Fprintf(stderr, "motorino: unexpected arguments: %s\n%s\n", strings.Join(flags.Args(), " "), usage) - return 2 - } result, err := build.Build(build.Options{SiteDir: *site, OutDir: *out, Version: version.String()}) if err != nil { fmt.Fprintf(stderr, "motorino: %v\n", err) diff --git a/cmd/motorino/main_test.go b/cmd/motorino/main_test.go index 4090294..8e2ffd6 100644 --- a/cmd/motorino/main_test.go +++ b/cmd/motorino/main_test.go @@ -30,11 +30,8 @@ func miniSite(t *testing.T) string { } for _, id := range []string{"home", "manifesto", "people", "services", "news", "history"} { name := id - switch id { - case "home": + if id == "home" { name = "index" - case "news": - name = "news/index" } files["content/en/"+name+".md"] = "Title: " + id + "\nID: " + id + "\nDescription: d\n-\nBody of " + id + ".\n" } @@ -104,17 +101,6 @@ func TestRunUnknownCommand(t *testing.T) { } } -// TestRunBuildRejectsExtraArguments checks that arguments that are not flags are not ignored. -func TestRunBuildRejectsExtraArguments(t *testing.T) { - var out, errOut bytes.Buffer - if code := run([]string{"build", "somesite", "someout"}, &out, &errOut); code != 2 { - t.Errorf("run(build somesite someout) = %d, want 2", code) - } - if !strings.Contains(errOut.String(), "unexpected") { - t.Errorf("stderr = %q, want it to say what was unexpected", errOut.String()) - } -} - // TestRunBuildBadFlag checks that an unknown flag is a usage error. func TestRunBuildBadFlag(t *testing.T) { var out, errOut bytes.Buffer diff --git a/internal/build/build.go b/internal/build/build.go index a6d2ea3..7975c88 100644 --- a/internal/build/build.go +++ b/internal/build/build.go @@ -76,10 +76,7 @@ type Result struct { } // Build reads the site in opts.SiteDir and writes it to opts.OutDir. It renders -// everything in memory first, so a failure in the content leaves the output -// folder untouched. Writing the files is not atomic, and files of an earlier -// build that are no longer produced are not removed: build into a fresh folder -// when that matters, as the deploy does. +// everything in memory first, so a failure leaves the output folder untouched. func Build(opts Options) (Result, error) { b, err := load(opts) if err != nil { @@ -140,9 +137,6 @@ func load(opts Options) (*builder, error) { return nil, fmt.Errorf("content/%s: there is no page with ID %q", b.defaultLang, id) } } - if news := b.byKey[pageKey{"news", b.defaultLang}]; !strings.HasSuffix(news.Path, "/") { - return nil, fmt.Errorf("%s: the news page must be an index (news/index.md), so that the feed has an address next to it", news.Source) - } if b.templates, err = readTemplates(opts.SiteDir); err != nil { return nil, err } diff --git a/internal/build/build_test.go b/internal/build/build_test.go index 1d6623d..b46db52 100644 --- a/internal/build/build_test.go +++ b/internal/build/build_test.go @@ -358,72 +358,6 @@ func TestBuildRejectsSwitchToUnknownLanguage(t *testing.T) { } } -// TestBuildFeedMakesImagesAbsolute checks that src links get the full address like href links. -func TestBuildFeedMakesImagesAbsolute(t *testing.T) { - files := baseFiles() - files["news/pic.md"] = "Title: Pic\nDate: 2026-11-15T12:00:00+0100\n-\n![the logo](/logo.svg)\n" - out, err := runBuild(t, files) - if err != nil { - t.Fatal(err) - } - mustContain(t, "feed", readOut(t, out, "news/feed.xml"), `src="https://kmalloc.org/logo.svg"`) -} - -// TestBuildNewsPageMustBeAFolderIndex checks that the feed has a sound address. -func TestBuildNewsPageMustBeAFolderIndex(t *testing.T) { - files := baseFiles() - delete(files, "content/en/news/index.md") - files["content/en/news.md"] = page("news", "News", "", "{{news_list}}\n") - _, err := runBuild(t, files) - if err == nil || !strings.Contains(err.Error(), "content/en/news.md") || !strings.Contains(err.Error(), "index") { - t.Errorf("Build() error = %v, want it to say that content/en/news.md must be an index", err) - } -} - -// TestBuildBlockNameInATitleIsNotAnError checks that a generated list that shows -// the text of a block placeholder (in a news title) is not mistaken for a -// placeholder that is not alone in its paragraph. -func TestBuildBlockNameInATitleIsNotAnError(t *testing.T) { - files := baseFiles() - files["news/tpl.md"] = "Title: Use {{latest_news}} in a page\nDate: 2026-11-15T12:00:00+0100\n-\nA note.\n" - out, err := runBuild(t, files) - if err != nil { - t.Fatalf("Build() error = %v", err) - } - mustContain(t, "home", readOut(t, out, "index.html"), "Use {{latest_news}} in a page") -} - -// TestBuildPlaceholdersAndCode checks the three ways a page can use a placeholder -// next to code: a value in a code span (the pages show the GPG fingerprint that -// way), a fenced block that shows a placeholder as written, and an escaped one. -func TestBuildPlaceholdersAndCode(t *testing.T) { - files := baseFiles() - files["content/en/people.md"] = page("people", "People", "", "Value `{{lang}}` and escaped \\{{lang}}.\n\n```\n{{lang}} {{nope}}\n```\n\nAnd {{lang}}.\n") - out, err := runBuild(t, files) - if err != nil { - t.Fatalf("Build() error = %v", err) - } - got := readOut(t, out, "people.html") - mustContain(t, "people", got, "en", "escaped {{lang}}.", "{{lang}} {{nope}}", "And en.") -} - -// TestBuildEscapedPlaceholders checks the escape with block placeholders: an -// escaped one inside a sentence or alone in a paragraph is shown, not expanded -// and not an error, and a code span can show a placeholder as written. -func TestBuildEscapedPlaceholders(t *testing.T) { - files := baseFiles() - files["content/en/people.md"] = page("people", "People", "", "See \\{{news_list}} here.\n\n\\{{latest_news}}\n\nAnd `\\{{lang}}`.\n") - out, err := runBuild(t, files) - if err != nil { - t.Fatalf("Build() error = %v", err) - } - got := readOut(t, out, "people.html") - mustContain(t, "people", got, "See {{news_list}} here.", "

{{latest_news}}

", "{{lang}}") - if strings.Contains(got, "