From e04ff565ee87810626341aa1f8dea6a09b842f95 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Sun, 23 Nov 2025 03:00:44 +1300 Subject: [PATCH] add rudimentary up navigation --- lib/archive-file-mappings.rkt | 5 ++++- src/application-globals.rkt | 13 ++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/archive-file-mappings.rkt b/lib/archive-file-mappings.rkt index 03f97f5..94b4578 100644 --- a/lib/archive-file-mappings.rkt +++ b/lib/archive-file-mappings.rkt @@ -32,4 +32,7 @@ (uri-decode (regexp-replace* #rx"#" str "/"))) (define (url-segments->guess-title segments) - (regexp-replace* #rx"_" (cadr segments) " ")) + (string-join + (for/list ([s (in-list (cdr segments))]) + (regexp-replace* #rx"_" s " ")) + "/")) diff --git a/src/application-globals.rkt b/src/application-globals.rkt index 0d6b3dd..8011d01 100644 --- a/src/application-globals.rkt +++ b/src/application-globals.rkt @@ -235,7 +235,18 @@ (main (@ (class "page__main")) ,(extwiki-notice wikiname title req user-cookies) (div (@ (class "custom-top")) - (h1 (@ (class "page-title")) ,title) + (h1 (@ (class "page-title")) + ;; adds rudimentary "up" navigation, e.g. /minecraft/wiki/Bastion_Remnant/Structure/Blueprints/Bastion_treasure_corners_edge_middle_blueprint + ,@(let ([segments (string-split title "/")]) + (add-between + (for/list ([segment (in-list segments)] + [depth (in-naturals 1)]) + (define anti-depth (- (length segments) depth)) + (define up-href (string-join (make-list anti-depth "..") "/")) + (if (non-empty-string? up-href) + `(a (@ (href ,(format "~a/~a" up-href segment))) ,segment) + segment)) + "/"))) (nav (@ (class "sitesearch")) (form (@ (action ,(format "/~a/search" wikiname)) (class "bw-search-form")