From 86adaa86a2de144894af16ac962c4847d3ef53b5 Mon Sep 17 00:00:00 2001 From: Ananth Venkatesh Date: Sat, 1 Mar 2025 02:38:24 -0500 Subject: [PATCH] fix: resolve all hosting and url addresses --- flake.lock | 6 +++--- src/Main.elm | 47 +++++++++++++++++++++++++++-------------------- src/index.html | 6 +++++- 3 files changed, 35 insertions(+), 24 deletions(-) diff --git a/flake.lock b/flake.lock index f23cbf4..bba39c3 100644 --- a/flake.lock +++ b/flake.lock @@ -119,11 +119,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1740560979, - "narHash": "sha256-Vr3Qi346M+8CjedtbyUevIGDZW8LcA1fTG0ugPY/Hic=", + "lastModified": 1740695751, + "narHash": "sha256-D+R+kFxy1KsheiIzkkx/6L63wEHBYX21OIwlFV8JvDs=", "owner": "nixos", "repo": "nixpkgs", - "rev": "5135c59491985879812717f4c9fea69604e7f26f", + "rev": "6313551cd05425cd5b3e63fe47dbc324eabb15e4", "type": "github" }, "original": { diff --git a/src/Main.elm b/src/Main.elm index 98b4618..9fd5861 100644 --- a/src/Main.elm +++ b/src/Main.elm @@ -82,6 +82,7 @@ type alias Model = , h : Int , last : String , url : Url.Url + , path : String , key : Nav.Key , mesh : Maybe Object3d , textures : Maybe (Material.Textured Obj.Decode.ObjCoordinates) @@ -95,19 +96,20 @@ type alias Model = type alias Flags = - ( Int, Int ) + ( Int, Int, String ) init : Flags -> Url.Url -> Nav.Key -> ( Model, Cmd Msg ) init flags url key = let - ( width, height ) = + ( width, height, path ) = flags in ( { w = width , h = height , last = "" , url = url + , path = path , key = key , mesh = Nothing , textures = Nothing @@ -459,12 +461,12 @@ id = Html.Attributes.id >> Element.htmlAttribute -getPaths : String -> List String -getPaths base = +getPaths : String -> String -> List String +getPaths path base = let root : String root = - "/" ++ base + path ++ base in List.map ((++) root) [ "", "/", "/index.html" ] @@ -484,13 +486,18 @@ itemize multikeys entry = [] -sitemap : Dict String (Model -> List (Html Msg)) -sitemap = +sitemap : Model -> Dict String (Model -> List (Html Msg)) +sitemap model = + let + getter : String -> List String + getter = + getPaths model.path + in Dict.fromList - (itemize ([ "/", "/index.html" ] ++ getPaths "src" ++ getPaths "index" ++ getPaths "home") pageHome - ++ itemize (getPaths "entries") pageEntries - ++ itemize (getPaths "about") pageAbout - ++ itemize (getPaths "colophon") colophon + (itemize ([ "/", "/index.html", model.path ] ++ getter "src" ++ getter "index" ++ getter "home") pageHome + ++ itemize (getter "entries") pageEntries + ++ itemize (getter "about") pageAbout + ++ itemize (getter "colophon") colophon ) @@ -499,7 +506,7 @@ loadUrl model = let req : Maybe (Model -> List (Html Msg)) req = - Dict.get model.url.path sitemap + Dict.get model.url.path (sitemap model) in case req of Just builder -> @@ -533,9 +540,9 @@ menu model = , Font.size 18 ] (row [ spacing 20 ] - [ inlineLinkInt "Entries" "/entries" - , inlineLinkInt "Access" "/about" - , inlineLinkInt "Colophon" "/colophon" + [ inlineLinkInt "Entries" (model.path ++ "entries") + , inlineLinkInt "Access" (model.path ++ "about") + , inlineLinkInt "Colophon" (model.path ++ "colophon") ] ) @@ -782,7 +789,7 @@ pageAbout model = , column [ spacing 15 ] [ row [ spacing 15 ] - [ linkBtnInt "← Back" "/" + [ linkBtnInt "← Back" model.path , btn "Directions" (Scroll "one") ] , row [ spacing 15 ] @@ -809,7 +816,7 @@ pageAbout model = , column (page model ++ [ id "one" ]) [ image (fullImage model) - { src = "../assets/img/map.png" + { src = model.path ++ "../assets/img/map.png" , description = "mit campus map with pin at macgregor house" } , column (pageText model) @@ -960,7 +967,7 @@ pageEntries model = [ row [ spacing 15 ] - [ linkBtnInt "← Back" "/" + [ linkBtnInt "← Back" model.path , btn "Explore ↓" (ScrollToEntry "J") ] ] @@ -1341,7 +1348,7 @@ notFound model = [ text "You were likely redirected here by a link to a page on the old website, the last known archive of which can be found " , inlineLink "here" "https://web.archive.org/web/20170529064230/http://macgregor.mit.edu/" , text ". Unless you want to conduct research on ancient MIT traditions, you can probably find what you're looking for on the new " - , inlineLinkInt "main page" "/src" + , inlineLinkInt "main page" (model.path ++ "/src") , text ". If you believe this page really is missing, " , inlineLink "contact the webmaster" "mailto:ananthv@mit.edu" , text "." @@ -1415,7 +1422,7 @@ colophon model = ] [ text "Colophon." , row [ spacing 15 ] - [ linkBtnInt "← Back" "/" + [ linkBtnInt "← Back" model.path , linkBtn "Source" "https://forgejo.mit.edu/ananthv/macgregor" , btn "Literature" (Scroll "one") ] diff --git a/src/index.html b/src/index.html index 453b42a..4d636ac 100644 --- a/src/index.html +++ b/src/index.html @@ -16,7 +16,11 @@