diff --git a/doc/todo.md b/doc/todo.md index f8673c1..8863eef 100644 --- a/doc/todo.md +++ b/doc/todo.md @@ -5,17 +5,15 @@ - user pages - search form - page tags should link to the tag index -- error pages: 404, 500, etc # wishlist - prefers-color-scheme - robots.txt, sitemap.xml - firefox alternative stylesheets too maybe (send more js for chrome to do the thing too) -- explicitly block brave (also needs js) +- make /unsupported-browser page for brave - rss/atom - indieweb: microformats2, webmentions, websub, rel=me -- reject brave (lol) - support tor and opennic - activitypub - gopher and gemini variants diff --git a/init.rkt b/init.rkt index 87f2060..0438e41 100644 --- a/init.rkt +++ b/init.rkt @@ -13,6 +13,7 @@ (define src (simple-form-path (build-path dir "src"))) (define target (simple-form-path (build-path dir "target"))) (make-directory* src) + (make-directory* target) (with-output-to-file (build-path src "index.md") (λ () @@ -37,6 +38,22 @@ (build-path src "config.rktd") (λ () (pretty-write (list (list 'base "http://localhost:8080"))))) + (with-output-to-file + (build-path src "40x.md") + (λ () + (pretty-write + '((title "error page") + (lang "en"))) + (write-string "\n# error\n\nno such page; or you are not authorized to view it"))) + + (with-output-to-file + (build-path src "50x.md") + (λ () + (pretty-write + '((title "error page") + (lang "en"))) + (write-string "\n# error\n\nthe server ran into an error :("))) + (with-output-to-file (build-path dir "nginx.conf") (λ () diff --git a/render.rkt b/render.rkt index d477428..7dbc6ea 100644 --- a/render.rkt +++ b/render.rkt @@ -22,7 +22,10 @@ (define *reserved-slugs* (apply set (map build-path '("hashtag" "user" "tech" "capybara" "dynamic" "robots.txt" - "sitemap.xml" "feeds")))) + "sitemap.xml" "feeds" "unsupported-browser")))) + +(define *special-slugs* + (apply set (map build-path '("/40x" "/50x")))) (define (read-input-doc xref-name [port (current-input-port)]) (define metadata (read port)) @@ -293,7 +296,8 @@ ;; TODO : this sucks ;; we should have a radix tree (define xrefs-repo - (for/set ([spec (in-list rule-specs)]) + (for/set ([spec (in-list rule-specs)] + #:unless (set-member? *special-slugs* (rule-spec-xref-name spec))) (define exploded (explode-path (rule-spec-xref-name spec))) (when (and (> (length exploded) 1) (set-member? *reserved-slugs* (second exploded))) diff --git a/support/nginx-dev.conf b/support/nginx-dev.conf index a956180..5183a80 100644 --- a/support/nginx-dev.conf +++ b/support/nginx-dev.conf @@ -30,6 +30,8 @@ http { location / { try_files $uri $uri.html $uri/ =404; sub_filter "__X_MATHJAX_POLYFILL_PLACEHOLDER__" $mathjax_polyfill; + error_page 401 403 404 410 /40x.html; + error_page 500 502 503 504 /50x.html; } } }