diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 0b3e8fb..e47ed2c 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -3,22 +3,23 @@ name: Deploy to GitHub Pages on: push: branches: [main, master] + pull_request: schedule: - cron: "0 6 * * *" # Rebuild daily at 6am UTC workflow_dispatch: permissions: contents: read - pages: write - id-token: write concurrency: - group: "pages" + group: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.ref) || 'pages' }} cancel-in-progress: false jobs: build: runs-on: ubuntu-24.04 + outputs: + sitemap_urls: ${{ steps.sitemap.outputs.urls }} steps: - uses: actions/checkout@v6 @@ -35,15 +36,21 @@ jobs: - name: Install npm dependencies run: npm ci - - name: Setup Pages - uses: actions/configure-pages@v6 - - name: Build site run: bundle exec rake deploy env: BRIDGETOWN_ENV: production + - name: Run specs + run: bundle exec rake test + + # Read from the fresh build, not the live site (Pages' CDN can serve a stale sitemap after deploy) + - name: Collect sitemap URLs for IndexNow + id: sitemap + run: echo "urls=$(bundle exec ruby -rrexml/document -rjson -e 'puts REXML::Document.new(File.read("output/sitemap.xml")).get_elements("urlset/url/loc").map(&:text).to_json')" >> "$GITHUB_OUTPUT" + - name: Upload artifact + if: github.event_name != 'pull_request' uses: actions/upload-pages-artifact@v5 with: path: output @@ -54,7 +61,28 @@ jobs: url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-24.04 needs: build + if: github.event_name != 'pull_request' + permissions: + pages: write + id-token: write steps: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v5 + + # Runs only after Pages reports a successful deploy. URLs come from the build job's sitemap. + # ponytail: pings every sitemap URL on each deploy (incl. daily cron); diff against the previous sitemap if IndexNow starts throttling + - name: Ping IndexNow + continue-on-error: true + env: + INDEXNOW_KEY: d3edebe3-2774-4cd0-b3aa-780a8587c0a6 + SITE: https://www.rakefire.io + URLS: ${{ needs.build.outputs.sitemap_urls }} + run: | + set -o pipefail + if [ -z "$URLS" ] || [ "$URLS" = "[]" ]; then echo "::warning::No sitemap URLs from build; skipping IndexNow"; exit 0; fi + echo "Submitting: $URLS" + jq -nc --arg key "$INDEXNOW_KEY" --arg site "$SITE" --argjson urls "$URLS" \ + '{host: ($site | sub("https://"; "")), key: $key, keyLocation: "\($site)/\($key).txt", urlList: $urls}' \ + | curl -fsS -w 'IndexNow HTTP %{http_code}\n' -X POST https://api.indexnow.org/indexnow \ + -H 'Content-Type: application/json; charset=utf-8' --data-binary @- diff --git a/Gemfile b/Gemfile index 5dc8163..773100e 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source "https://rubygems.org" -gem "bridgetown", "~> 2.1" +gem "bridgetown", "~> 2.2" gem "bridgetown-feed", "~> 4.0" gem "bridgetown-sitemap", "~> 3.0" gem "bridgetown-seo-tag", "~> 7.0" @@ -18,3 +18,9 @@ gem "htmlcompressor", "~> 0.4" group :test, :development do gem "puma", "~> 7.2" end + +group :test do + gem "minitest" + gem "rack-test" + gem "nokolexbor" +end diff --git a/Gemfile.lock b/Gemfile.lock index 500cd59..d341411 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,28 +1,28 @@ GEM remote: https://rubygems.org/ specs: - addressable (2.9.1) + addressable (2.10.0) public_suffix (>= 2.0.2, < 8.0) amazing_print (1.8.1) base64 (0.3.0) - bigdecimal (4.0.1) - bridgetown (2.1.2) - bridgetown-builder (= 2.1.2) - bridgetown-core (= 2.1.2) - bridgetown-foundation (= 2.1.2) - bridgetown-paginate (= 2.1.2) - bridgetown-builder (2.1.2) - bridgetown-core (= 2.1.2) - bridgetown-core (2.1.2) + bigdecimal (4.1.3) + bridgetown (2.2.2) + bridgetown-builder (= 2.2.2) + bridgetown-core (= 2.2.2) + bridgetown-foundation (= 2.2.2) + bridgetown-paginate (= 2.2.2) + bridgetown-builder (2.2.2) + bridgetown-core (= 2.2.2) + bridgetown-core (2.2.2) addressable (~> 2.4) amazing_print (~> 1.2) base64 (>= 0.3) bigdecimal (>= 3.2) - bridgetown-foundation (= 2.1.2) + bridgetown-foundation (= 2.2.2) csv (~> 3.2) erubi (~> 1.9) faraday (~> 2.0) - faraday-follow_redirects (~> 0.3) + faraday-follow_redirects (~> 0.5) freyia (>= 0.5) i18n (~> 1.0) irb (>= 1.14) @@ -35,7 +35,7 @@ GEM rake (>= 13.0) roda (~> 3.46) rouge (>= 3.0, < 5.0) - samovar (>= 2.4) + samovar (= 2.4.1) securerandom (~> 0.4) serbea (>= 2.4.1) signalize (~> 1.3) @@ -44,34 +44,34 @@ GEM zeitwerk (>= 2.7.3) bridgetown-feed (4.0.0) bridgetown (>= 1.2.0) - bridgetown-foundation (2.1.2) + bridgetown-foundation (2.2.2) dry-inflector (>= 1.0) hash_with_dot_access (~> 2.0) inclusive (~> 1.0) zeitwerk (~> 2.5) - bridgetown-paginate (2.1.2) - bridgetown-core (= 2.1.2) + bridgetown-paginate (2.2.2) + bridgetown-core (= 2.2.2) bridgetown-seo-tag (7.0.1) bridgetown (>= 1.3) bridgetown-sitemap (3.0.3) bridgetown (>= 1.3.0, < 3.0) - concurrent-ruby (1.3.7) - console (1.34.3) + concurrent-ruby (1.3.8) + console (1.38.0) fiber-annotation fiber-local (~> 1.1) json - csv (3.3.5) - date (3.5.1) + csv (3.3.7) + drb (2.2.3) dry-inflector (1.3.1) - erb (6.0.4) + erb (6.0.7) erubi (1.13.1) - faraday (2.14.3) - faraday-net_http (>= 2.0, < 3.5) + faraday (2.15.1) + faraday-net_http (>= 2.0, < 3.6) json logger faraday-follow_redirects (0.5.0) faraday (>= 1, < 3) - faraday-net_http (3.4.4) + faraday-net_http (3.5.0) net-http (~> 0.5) ffi (1.17.4) ffi (1.17.4-aarch64-linux-gnu) @@ -90,59 +90,65 @@ GEM fiber-storage fiber-storage (1.0.1) freyia (0.6.2) - google-protobuf (4.34.1) + google-protobuf (4.36.2) bigdecimal rake (~> 13.3) - google-protobuf (4.34.1-aarch64-linux-gnu) + google-protobuf (4.36.2-aarch64-linux-gnu) bigdecimal rake (~> 13.3) - google-protobuf (4.34.1-aarch64-linux-musl) + google-protobuf (4.36.2-aarch64-linux-musl) bigdecimal rake (~> 13.3) - google-protobuf (4.34.1-arm64-darwin) + google-protobuf (4.36.2-arm64-darwin) bigdecimal rake (~> 13.3) - google-protobuf (4.34.1-x86-linux-gnu) + google-protobuf (4.36.2-x86-linux-gnu) bigdecimal rake (~> 13.3) - google-protobuf (4.34.1-x86-linux-musl) + google-protobuf (4.36.2-x86-linux-musl) bigdecimal rake (~> 13.3) - google-protobuf (4.34.1-x86_64-darwin) + google-protobuf (4.36.2-x86_64-darwin) bigdecimal rake (~> 13.3) - google-protobuf (4.34.1-x86_64-linux-gnu) + google-protobuf (4.36.2-x86_64-linux-gnu) bigdecimal rake (~> 13.3) - google-protobuf (4.34.1-x86_64-linux-musl) + google-protobuf (4.36.2-x86_64-linux-musl) bigdecimal rake (~> 13.3) hash_with_dot_access (2.2.0) htmlcompressor (0.4.0) - i18n (1.14.8) + i18n (1.15.2) concurrent-ruby (~> 1.0) inclusive (1.1.0) - io-console (0.8.2) - irb (1.18.0) + io-console (0.9.5) + irb (1.19.0) pp (>= 0.6.0) prism (>= 1.3.0) rdoc (>= 4.0.0) reline (>= 0.4.2) json (3.1.0) - kramdown (2.5.2) + kramdown (2.6.1) rexml (>= 3.4.4) kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) liquid (5.4.0) - listen (3.10.0) + listen (3.10.1) logger rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) logger (1.7.0) mapping (1.1.3) mini_portile2 (2.8.9) - net-http (0.9.1) + minitest (6.1.0) + drb (~> 2.0) + prism (>= 1.5, < 3) + net-http (0.10.0) + net-protocol (>= 0.3.0) uri (>= 0.11.1) + net-protocol (0.4.0) + timeout nio4r (2.7.5) nokogiri (1.19.7) mini_portile2 (~> 2.8.2) @@ -163,71 +169,89 @@ GEM racc (~> 1.4) nokogiri (1.19.7-x86_64-linux-musl) racc (~> 1.4) - pp (0.6.3) + nokolexbor (0.8.0) + nokolexbor (0.8.0-aarch64-linux) + nokolexbor (0.8.0-arm64-darwin) + nokolexbor (0.8.0-x86_64-darwin) + nokolexbor (0.8.0-x86_64-linux) + pp (0.6.4) prettyprint - prettyprint (0.2.0) - prism (1.9.0) - psych (5.3.1) - date - stringio + prettyprint (0.2.1) + prism (2.1.0) + prism (2.1.0-aarch64-linux-gnu) + prism (2.1.0-aarch64-linux-musl) + prism (2.1.0-aarch64-mingw-ucrt) + prism (2.1.0-arm-linux-gnu) + prism (2.1.0-arm-linux-musl) + prism (2.1.0-arm64-darwin) + prism (2.1.0-x86_64-darwin) + prism (2.1.0-x86_64-linux-gnu) + prism (2.1.0-x86_64-linux-musl) public_suffix (7.0.5) - puma (7.2.1) + puma (7.2.3) nio4r (~> 2.0) racc (1.8.1) - rack (3.2.8) + rack (3.2.9) + rack-test (2.3.0) + rack (>= 1.3) rackup (2.3.1) rack (>= 3) - rake (13.3.1) + rake (13.4.2) rb-fsevent (0.11.2) rb-inotify (0.11.1) ffi (~> 1.0) - rdoc (7.2.0) + rbs (4.2.0) + logger + prism (>= 1.6.0) + tsort + rdoc (8.1.0) erb - psych (>= 4.0.0) + prism (>= 1.6.0) + rbs (>= 4.0.0) tsort - reline (0.6.3) + reline (0.7.0) io-console (~> 0.5) - reverse_markdown (3.0.2) + reverse_markdown (3.1.0) nokogiri rexml (3.4.4) - roda (3.103.0) + roda (3.110.0) rack rouge (4.7.0) samovar (2.4.1) console (~> 1.0) mapping (~> 1.0) - sass-embedded (1.98.0) + sass-embedded (1.108.2) google-protobuf (~> 4.31) - rake (>= 13) - sass-embedded (1.98.0-aarch64-linux-android) + rake (~> 13.3) + sass-embedded (1.108.2-aarch64-linux-android) google-protobuf (~> 4.31) - sass-embedded (1.98.0-aarch64-linux-gnu) + sass-embedded (1.108.2-aarch64-linux-gnu) google-protobuf (~> 4.31) - sass-embedded (1.98.0-aarch64-linux-musl) + sass-embedded (1.108.2-aarch64-linux-musl) google-protobuf (~> 4.31) - sass-embedded (1.98.0-aarch64-mingw-ucrt) + sass-embedded (1.108.2-aarch64-mingw-ucrt) google-protobuf (~> 4.31) - sass-embedded (1.98.0-arm-linux-androideabi) + sass-embedded (1.108.2-arm-linux-androideabi) google-protobuf (~> 4.31) - sass-embedded (1.98.0-arm-linux-gnueabihf) + sass-embedded (1.108.2-arm-linux-gnueabihf) google-protobuf (~> 4.31) - sass-embedded (1.98.0-arm-linux-musleabihf) + sass-embedded (1.108.2-arm-linux-musleabihf) google-protobuf (~> 4.31) - sass-embedded (1.98.0-arm64-darwin) + sass-embedded (1.108.2-arm64-darwin) google-protobuf (~> 4.31) - sass-embedded (1.98.0-riscv64-linux-android) + sass-embedded (1.108.2-riscv64-linux-android) google-protobuf (~> 4.31) - sass-embedded (1.98.0-riscv64-linux-gnu) + sass-embedded (1.108.2-riscv64-linux-gnu) google-protobuf (~> 4.31) - sass-embedded (1.98.0-riscv64-linux-musl) + sass-embedded (1.108.2-riscv64-linux-musl) google-protobuf (~> 4.31) - sass-embedded (1.98.0-x86_64-darwin) + sass-embedded (1.108.2-x86_64-darwin) google-protobuf (~> 4.31) - sass-embedded (1.98.0-x86_64-linux-android) + sass-embedded (1.108.2-x86_64-linux-android) google-protobuf (~> 4.31) - sass-embedded (1.98.0-x86_64-linux-gnu) + sass-embedded (1.108.2-x86_64-linux-gnu) google-protobuf (~> 4.31) - sass-embedded (1.98.0-x86_64-linux-musl) + sass-embedded (1.108.2-x86_64-linux-musl) google-protobuf (~> 4.31) securerandom (0.4.1) serbea (2.4.1) @@ -238,11 +262,11 @@ GEM streamlined (0.6.2) serbea (>= 2.1) zeitwerk (~> 2.5) - stringio (3.2.0) - tilt (2.7.0) + tilt (2.9.0) + timeout (0.6.1) tsort (0.2.0) - uri (1.1.1) - zeitwerk (2.7.5) + uri (1.1.2) + zeitwerk (2.8.3) PLATFORMS aarch64-linux @@ -274,13 +298,16 @@ PLATFORMS x86_64-linux-musl DEPENDENCIES - bridgetown (~> 2.1) + bridgetown (~> 2.2) bridgetown-feed (~> 4.0) bridgetown-seo-tag (~> 7.0) bridgetown-sitemap (~> 3.0) htmlcompressor (~> 0.4) + minitest nokogiri (~> 1.19) + nokolexbor puma (~> 7.2) + rack-test reverse_markdown (~> 3.0) sass-embedded (~> 1.0) diff --git a/README.md b/README.md index e609c13..1b91e9a 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,14 @@ BRIDGETOWN_ENV=production bundle exec bridgetown build Output goes to `output/`. +## Tests + +Specs in `test/` use Bridgetown's Minitest harness (`bridgetown/test` + rack-test) against the built `output/`: page metadata, broken internal links, redirects, sitemap/robots/feed, and the agent-skills/llms.txt files. + +```sh +bundle exec bridgetown build && bundle exec rake test +``` + ## CSS `src/css/style.css` is checked in as the byte-exact output of the legacy Jekyll/libsass build, so the deployed stylesheet matches the pre-Bridgetown site. If you change anything under `_sass/`, regenerate it: @@ -38,4 +46,4 @@ Note: `sass-embedded` (Dart Sass) emits a slightly different stylesheet than lib ## Deploy -`.github/workflows/pages.yml` builds on every push to `main` and publishes to GitHub Pages (custom domain: `www.rakefire.io`). No manual deploy step. +`.github/workflows/pages.yml` builds on every push to `main` and publishes to GitHub Pages (custom domain: `www.rakefire.io`). The specs run against that production build first; a failure blocks the deploy. IndexNow is pinged only after a successful deploy. Pull requests run the same build + specs without deploying or pinging. No manual deploy step. diff --git a/Rakefile b/Rakefile index 7004f8f..4982f9b 100644 --- a/Rakefile +++ b/Rakefile @@ -53,3 +53,12 @@ namespace :css do puts "Wrote #{out} (#{result.css.bytesize} bytes)" end end + +# Specs run against the already-built output/ (CI tests the exact production +# build it deploys). Locally: `bin/bridgetown build && bundle exec rake test`. +begin + require "minitest/test_task" + Minitest::TestTask.create(:test) { |t| t.warning = false } +rescue LoadError + # test gems not installed (e.g. BUNDLE_WITHOUT=test); `rake deploy` still works +end diff --git a/docs/gha-deploy-flow.md b/docs/gha-deploy-flow.md index 822d808..f84edbd 100644 --- a/docs/gha-deploy-flow.md +++ b/docs/gha-deploy-flow.md @@ -18,16 +18,18 @@ Single workflow: `.github/workflows/pages.yml` ## Triggers - `push` to `main` / `master` +- `pull_request` — build + specs only; no upload, deploy, or IndexNow - `schedule: "0 6 * * *"` — daily 06:00 UTC rebuild - `workflow_dispatch` — manual **Permissions** -- `contents: read`, `pages: write`, `id-token: write` +- Workflow: `contents: read` only +- `deploy` job adds `pages: write`, `id-token: write` (PR builds never get them) **Concurrency** -- `group: pages`, `cancel-in-progress: false` — runs queue, never get killed mid-flight +- `group: pages` (PRs: `pr-`), `cancel-in-progress: false` — deploys queue, never get killed mid-flight; PRs can't bump a queued deploy --- @@ -35,14 +37,14 @@ Single workflow: `.github/workflows/pages.yml` ``` build (ubuntu-latest) - └─ checkout → setup ruby/node → npm ci → rake deploy → upload artifact + └─ checkout → setup ruby/node → npm ci → rake deploy → rake test → collect sitemap URLs → upload artifact deploy (ubuntu-latest, needs: build) - └─ actions/deploy-pages@v5 + └─ actions/deploy-pages@v5 → ping IndexNow ``` Note: this repo runs **newer action versions** than its siblings — -`checkout@v6`, `configure-pages@v6`, `upload-pages-artifact@v5`, +`checkout@v6`, `upload-pages-artifact@v5`, `deploy-pages@v5`. --- @@ -54,7 +56,6 @@ Note: this repo runs **newer action versions** than its siblings — - Caches `vendor/bundle` keyed off `Gemfile.lock` 3. `actions/setup-node@v4` — Node 20, `cache: npm` 4. `npm ci` — installs esbuild + postcss toolchain -5. `actions/configure-pages@v6` **No Tailwind, no Puppeteer.** Only the Bridgetown 2.x esbuild defaults. @@ -125,7 +126,6 @@ Generates `output/` from `src/`. | `markdown_for_agents` | Emits markdown twins of HTML pages | | `redirects` | Generates redirect HTML files from data | | `html_minifier` | `htmlcompressor` rewrites every `output/**/*.html` | -| `indexnow` | Pings IndexNow API (production only) | --- @@ -179,25 +179,20 @@ Three different sources: | `/sitemap.xml` | `bridgetown-sitemap` gem | | `/feed.xml` | `bridgetown-feed` gem | | `/robots.txt` | `src/robots.txt` (committed) | +| `/404.html` | `src/404.html` — GitHub Pages serves it (status 404) for any missing URL | SEO meta tags injected via `bridgetown-seo-tag` gem. -The IndexNow builder reads `output/sitemap.xml` post-write. +The build job extracts the ``s from `output/sitemap.xml` (REXML) into a job output for the IndexNow step. --- ## IndexNow submission -`plugins/builders/indexnow.rb` — fires on `:post_write` when: +Last step of the `deploy` job, so it only runs after Pages reports success (never on PRs, never when specs fail). -- `BRIDGETOWN_ENV == "production"`, **or** -- `INDEXNOW=true` - -**Flow** - -1. Read `output/sitemap.xml` -2. Parse with `REXML`, collect `urlset/url/loc` -3. POST to `https://api.indexnow.org/indexnow`: +1. Take the URL list from the build job's `sitemap_urls` output (the fresh build, not the live site: Pages' CDN can serve a stale sitemap right after deploy). Empty list → skip with a warning +2. POST to `https://api.indexnow.org/indexnow` (built with `jq`): ```json { "host": "www.rakefire.io", @@ -206,8 +201,9 @@ The IndexNow builder reads `output/sitemap.xml` post-write. "urlList": [...] } ``` -4. 10s open/read timeouts -5. Exceptions caught and logged — never fail the build +3. `continue-on-error: true` — a failed ping never marks the deploy red + +Key lives in the step's `INDEXNOW_KEY` env; a spec checks it matches the served key file. Key file: `src/d3edebe3-2774-4cd0-b3aa-780a8587c0a6.txt` @@ -266,10 +262,10 @@ The committed CSS is what makes this site cheap to rebuild. ## Notable per-run side effects -- **IndexNow** — single POST per production / cron run +- **IndexNow** — single POST after each successful deploy (push / cron / manual) - **HTML minifier** — every `output/**/*.html` rewritten in place - **Full rebuild** every time — no incremental Bridgetown -- **Build failures in IndexNow are swallowed** — logged, never raised +- **IndexNow failures are swallowed** — step is `continue-on-error` - **Concurrency queue** — pushes during a run wait, don't cancel - **CSS is whatever was last committed** — drift between `_sass/` and `src/css/style.css` is silent unless someone runs `rake css:build` @@ -302,7 +298,6 @@ plugins/builders/ ├── agent_skills.rb ├── api_catalog.rb ├── html_minifier.rb # post-build compression - ├── indexnow.rb # IndexNow submission ├── markdown_for_agents.rb └── redirects.rb src/robots.txt diff --git a/plugins/builders/indexnow.rb b/plugins/builders/indexnow.rb deleted file mode 100644 index 28fec77..0000000 --- a/plugins/builders/indexnow.rb +++ /dev/null @@ -1,78 +0,0 @@ -require "net/http" -require "json" -require "uri" -require "rexml/document" - -class Builders::Indexnow < SiteBuilder - INDEXNOW_KEY = "d3edebe3-2774-4cd0-b3aa-780a8587c0a6" - INDEXNOW_API = "https://api.indexnow.org/indexnow" - SITE_HOST = "https://www.rakefire.io" - - def build - hook :site, :post_write do - next unless should_run? - - urls = collect_urls_from_sitemap - - if urls.empty? - Bridgetown.logger.info "IndexNow:", "No URLs to submit" - next - end - - submit_urls(urls) - end - end - - private - - def should_run? - return true if ENV["INDEXNOW"] == "true" - return true if Bridgetown.environment == "production" - - false - end - - def collect_urls_from_sitemap - sitemap_path = site.in_dest_dir("sitemap.xml") - unless File.exist?(sitemap_path) - Bridgetown.logger.warn "IndexNow:", "sitemap.xml not found at #{sitemap_path}" - return [] - end - - doc = REXML::Document.new(File.read(sitemap_path)) - doc.elements.collect("urlset/url/loc") { |el| el.text } - end - - def submit_urls(urls) - Bridgetown.logger.info "IndexNow:", "Submitting #{urls.size} URL(s) to IndexNow" - urls.each { |url| Bridgetown.logger.info "IndexNow:", " → #{url}" } - - body = { - host: URI(SITE_HOST).host, - key: INDEXNOW_KEY, - keyLocation: "#{SITE_HOST}/#{INDEXNOW_KEY}.txt", - urlList: urls - } - - uri = URI(INDEXNOW_API) - http = Net::HTTP.new(uri.host, uri.port) - http.use_ssl = true - http.open_timeout = 10 - http.read_timeout = 10 - - request = Net::HTTP::Post.new(uri.path) - request["Content-Type"] = "application/json; charset=utf-8" - request.body = JSON.generate(body) - - response = http.request(request) - - case response.code.to_i - when 200, 202 - Bridgetown.logger.info "IndexNow:", "Successfully submitted (HTTP #{response.code})" - else - Bridgetown.logger.warn "IndexNow:", "API returned HTTP #{response.code}: #{response.body}" - end - rescue => e - Bridgetown.logger.error "IndexNow:", "Submission failed: #{e.class} - #{e.message}" - end -end diff --git a/src/404.html b/src/404.html new file mode 100644 index 0000000..064563d --- /dev/null +++ b/src/404.html @@ -0,0 +1,21 @@ +--- +layout: page +title: "Page not found" +description: "That page doesn't exist (anymore). Head back to Rakefire's homepage, our work, or get in touch." +permalink: /404.html +noindex: true +sitemap: false +--- + +
+
+ +

This page went up in smoke.

+

The link may be old, or the page moved. Here's where to go instead.

+

+ Back to home + See our work + Get in touch +

+
+
diff --git a/src/_includes/head.html b/src/_includes/head.html index bb247ec..540f85a 100644 --- a/src/_includes/head.html +++ b/src/_includes/head.html @@ -13,6 +13,7 @@ + @@ -26,8 +27,8 @@ {% endif %} - - + + @@ -56,7 +57,7 @@ diff --git a/src/css/refresh.css b/src/css/refresh.css index dd86f6d..fde5b68 100644 --- a/src/css/refresh.css +++ b/src/css/refresh.css @@ -896,6 +896,49 @@ section .section-heading.text-center .subtext { text-align: center; } transform: translateY(-1px); } +/* ─── 404 (src/404.html) — same dark night + flame glow as the hero ── */ + +#not-found { + background: + radial-gradient(60% 80% at 78% 20%, rgba(255, 95, 59, 0.22), transparent 70%), + radial-gradient(50% 70% at 18% 78%, rgba(255, 175, 130, 0.10), transparent 70%), + var(--rf-night); + color: var(--rf-bg); + text-align: center; + padding: clamp(96px, 14vw, 168px) 0; + min-height: 70vh; +} +#not-found .nf-code { + font-family: 'Fraunces', serif; + font-variation-settings: 'opsz' 144, 'SOFT' 100, 'WONK' 1; + font-size: clamp(96px, 18vw, 220px); + line-height: 0.9; + margin: 0 0 16px; + color: transparent; + -webkit-text-stroke: 1.5px rgba(255, 95, 59, 0.55); + letter-spacing: -0.04em; +} +#not-found h1 { + font-family: 'Fraunces', serif; + font-variation-settings: 'opsz' 144, 'SOFT' 100, 'WONK' 1; + font-weight: 350; + font-size: var(--rf-fs-section-h); + color: var(--rf-bg); + margin: 0 auto 20px; + max-width: 18ch; + text-wrap: balance; +} +#not-found h1 em { color: var(--rf-accent); font-family: 'Fraunces', serif; } +#not-found .nf-sub { + color: rgba(250, 247, 242, 0.78); + font-size: var(--rf-fs-hero-sub); + max-width: 44ch; + margin: 0 auto 36px; +} +#not-found .nf-actions { display: flex; gap: 12px 28px; justify-content: center; align-items: center; flex-wrap: wrap; } +#not-found .nf-link { color: var(--rf-bg); font-weight: 600; border-bottom: 1px solid rgba(250, 247, 242, 0.3); } +#not-found .nf-link:hover { color: var(--rf-accent); border-color: var(--rf-accent); } + /* ─── Stoked widget (3rd-party launcher) ──────────────────────────── */ /* The "Talk to a former client" pill — let it sit on the new bg colors */ diff --git a/test/minitest_helper.rb b/test/minitest_helper.rb new file mode 100644 index 0000000..6a1a1eb --- /dev/null +++ b/test/minitest_helper.rb @@ -0,0 +1,26 @@ +ENV["MT_NO_EXPECTATIONS"] = "true" +require "minitest/autorun" +require "bridgetown/test" + +OUTPUT = File.expand_path("../output", __dir__) +abort "No build found. Run `bin/bridgetown build` (or `bundle exec rake deploy`) first." unless File.exist?("#{OUTPUT}/index.html") + +# ponytail: no server/ dir on this static site, so use Bridgetown's default Roda app (serves output/) +class RodaApp < Roda + plugin :bridgetown_server + route(&:bridgetown) +end + +class Bridgetown::Test + SITE_URL = "https://www.rakefire.io" + + # Every built HTML page except redirect stubs and vendored font demos. + def self.html_pages + Dir.glob("**/index.html", base: OUTPUT) + .reject { |f| f.start_with?("fonts/") || File.read("#{OUTPUT}/#{f}").include?('http-equiv="refresh"') } + .map { |f| "/#{f.delete_suffix("index.html")}" } + .sort + end + + def meta(name) = document.query_selector("meta[name='#{name}'], meta[property='#{name}']")&.[]("content") +end diff --git a/test/test_homepage.rb b/test/test_homepage.rb new file mode 100644 index 0000000..d4a0cb3 --- /dev/null +++ b/test/test_homepage.rb @@ -0,0 +1,53 @@ +require "minitest_helper" + +class TestHomepage < Bridgetown::Test + before { html get("/") } + + it "renders successfully" do + expect(last_response.status) == 200 + expect(document.query_selector("html")["lang"]) == "en" + end + + it "has the site title and description" do + expect(document.query_selector("title").text) == "Rakefire | Ruby on Rails Web Application Development" + expect(meta("description")).include? "Ruby on Rails agency and product studio" + end + + it "has social sharing tags pointing at the canonical URL" do + expect(meta("og:url")) == "#{SITE_URL}/" + expect(meta("og:image")) == "#{SITE_URL}/images/rakefire_logo.png" + expect(meta("twitter:card")) == "summary" + end + + it "is indexable" do + expect(meta("robots").to_s).exclude? "noindex" + end + + it "has every section the nav links to" do + targets = document.query_selector_all("#navbar a").map { _1["href"].split("#").last } + expect(targets) == %w[home products work services about contact] + targets.each { expect(document.query_selector("section##{_1}")).not_nil? } + end + + it "has exactly one h1" do + expect(document.query_selector_all("h1").size) == 1 + end + + it "links to both products" do + hrefs = document.query_selector_all("#products a").map { _1["href"] } + expect(hrefs).include? "https://www.causey.app/" + expect(hrefs).include? "https://get.stokedhq.com/" + end + + it "shows client work" do + expect(document.query_selector_all("#work h3").to_a).not_empty? + end + + it "has a contact email" do + expect(document.query_selector("a[href='mailto:contact@rakefire.io']")).not_nil? + end + + it "links to its markdown twin" do + expect(document.query_selector("link[rel=alternate][type='text/markdown']")["href"]) == "/index.md" + end +end diff --git a/test/test_machine_readable.rb b/test/test_machine_readable.rb new file mode 100644 index 0000000..8a5bbfd --- /dev/null +++ b/test/test_machine_readable.rb @@ -0,0 +1,70 @@ +require "minitest_helper" +require "digest" +require "rexml/document" + +# robots, sitemap, feed, IndexNow, llms.txt, agent skills, api-catalog +class TestMachineReadable < Bridgetown::Test + def sitemap_urls + REXML::Document.new(get("/sitemap.xml").body).elements.collect("urlset/url/loc", &:text) + end + + it "serves the custom domain CNAME" do + expect(get("/CNAME").body.strip) == "www.rakefire.io" + end + + it "allows crawling and points robots at the sitemap" do + body = get("/robots.txt").body + expect(body).include? "Allow: /" + expect(body).include? "Sitemap: #{SITE_URL}/sitemap.xml" + end + + it "lists every indexable page in the sitemap and nothing else" do + indexable = self.class.html_pages.reject { html(get(_1)) && meta("robots").to_s.include?("noindex") } + expect(sitemap_urls.sort) == indexable.map { "#{SITE_URL}#{_1}" }.sort + end + + it "keeps redirect stubs out of the sitemap" do + expect(sitemap_urls.grep(%r{/(ricky|stoked|causey)/})).empty? + end + + it "has a parseable Atom feed" do + feed = REXML::Document.new(get("/feed.xml").body) + expect(feed.root.name) == "feed" + end + + it "serves the IndexNow key file" do + key = File.read(File.expand_path("../.github/workflows/pages.yml", __dir__))[/INDEXNOW_KEY: (\S+)/, 1] + expect(get("/#{key}.txt").body.strip) == key + end + + it "serves llms.txt with links that resolve" do + body = get("/llms.txt").body + expect(body).include? "# Rakefire" + local = body.scan(%r{\]\((/[^)]+)\)}).flatten + expect(local).not_empty? + local.each { expect(get(_1).ok?).true?(_1) } + end + + describe "agent skills" do + let(:index) { JSON.parse(get("/.well-known/agent-skills/index.json").body) } + + it "lists every skill in _data/agent_skills.yml" do + expected = YAML.load_file(File.expand_path("../src/_data/agent_skills.yml", __dir__))["skills"].map { _1["name"] } + expect(index["skills"].map { _1["name"] }) == expected + end + + it "publishes SKILL.md files whose digests match" do + index["skills"].each do |skill| + res = get(skill["url"]) + expect(res.ok?).true?(skill["url"]) + expect(skill["digest"]) == "sha256:#{Digest::SHA256.hexdigest(res.body)}" + end + end + end + + it "has an api-catalog linkset pointing at the agent skills index" do + catalog = JSON.parse(get("/.well-known/api-catalog").body) + hrefs = catalog["linkset"].flat_map { _1["service-doc"] }.map { _1["href"] } + expect(hrefs).include? "#{SITE_URL}/.well-known/agent-skills/index.json" + end +end diff --git a/test/test_pages.rb b/test/test_pages.rb new file mode 100644 index 0000000..0c7cba3 --- /dev/null +++ b/test/test_pages.rb @@ -0,0 +1,83 @@ +require "minitest_helper" + +class TestPages < Bridgetown::Test + html_pages.each do |path| + describe path do + before { html get(path) } + + it "renders with a title, description and og:url" do + expect(last_response.status) == 200 + expect(document.query_selector("title").text).not_empty? + expect(meta("description").to_s).not_empty? + expect(meta("og:url")) == "#{SITE_URL}#{path}" + expect(document.query_selector("link[rel=canonical]")["href"]) == "#{SITE_URL}#{path}" + end + + it "has exactly one h1" do + expect(document.query_selector_all("h1").size) == 1 + end + + it "gives every image alt text" do + expect(document.query_selector_all("img:not([alt])").to_a).empty? + end + + it "has no broken internal links or assets" do + broken = document.query_selector_all("a[href], link[href], script[src], img[src]") + .map { _1["href"] || _1["src"] } + .reject { _1.match?(%r{\A(https?:|//|mailto:|tel:|#|data:|javascript:)}) } + .map { URI.join("http://x#{path}", _1).path } + .uniq + .reject { get(_1).ok? } + expect(broken).empty? + end + + it "has a markdown twin" do + expect(get("#{path}index.md").ok?).true? + end + end + end + + describe "/presentations/ilead-2017/" do + it "offers the PDF download" do + html get("/presentations/ilead-2017/") + pdf = document.query_selector("a[download]")["href"] + expect(get(pdf).ok?).true? + end + end + + describe "/map-demo/" do + it "is kept out of search engines" do + html get("/map-demo/") + expect(meta("robots")).include? "noindex" + end + end + + it "gives every page a unique title and description" do + heads = self.class.html_pages.map { html(get(_1)) && [document.query_selector("title").text, meta("description")] } + expect(heads.map(&:first).uniq.size) == heads.size + expect(heads.map(&:last).uniq.size) == heads.size + end + + # GitHub Pages serves output/404.html (with a 404 status) for any missing URL + describe "/404.html" do + before { html get("/404.html") } + + it "is branded, noindex, and kept out of the sitemap" do + expect(last_response.status) == 200 + expect(document.query_selector("h1").text).include? "smoke" + expect(meta("robots")) == "noindex" + expect(get("/sitemap.xml").body).exclude? "404" + end + + it "only uses root-relative or absolute URLs (it's served at arbitrary depths)" do + relative = document.query_selector_all("a[href], link[href], script[src], img[src]") + .map { _1["href"] || _1["src"] } + .reject { _1.match?(%r{\A(/|https?:|mailto:|tel:|#)}) } + expect(relative).empty? + end + + it "links somewhere that works" do + document.query_selector_all("#not-found a").each { expect(get(_1["href"].split("#").first).ok?).true?(_1["href"]) } + end + end +end diff --git a/test/test_redirects.rb b/test/test_redirects.rb new file mode 100644 index 0000000..0c84760 --- /dev/null +++ b/test/test_redirects.rb @@ -0,0 +1,14 @@ +require "minitest_helper" +require "csv" + +class TestRedirects < Bridgetown::Test + CSV.read(File.expand_path("../src/_data/redirects.csv", __dir__), headers: true).each do |row| + it "redirects /#{row["from"]}/ to #{row["to"]}" do + html get("/#{row["from"]}/") + expect(last_response.status) == 200 + expect(document.query_selector("meta[http-equiv=refresh]")["content"]) == "0; url=#{row["to"]}" + expect(document.query_selector("link[rel=canonical]")["href"]) == row["to"] + expect(meta("robots")) == "noindex" + end + end +end