From 05ea4501c05097e3c401c24f8c38d0d0db002e00 Mon Sep 17 00:00:00 2001 From: Joel Stålnacke Date: Sun, 3 Aug 2025 16:07:43 +0300 Subject: Add a base path /tj Fix deployment --- .gitignore | 4 +++- Aamukampa.Core/Aamukampa.Core.fsproj | 1 + Aamukampa.Core/Config.fs | 4 ++++ Aamukampa.Core/Views.fs | 29 +++++++++++++++++------------ Aamukampa.Web/Aamukampa.Web.fsproj | 2 +- Aamukampa.Web/Modules/Index.fs | 2 +- Aamukampa.Web/Program.fs | 4 ++++ Aamukampa.Web/wwwroot/styles.css | 20 +++++++++----------- 8 files changed, 40 insertions(+), 26 deletions(-) create mode 100644 Aamukampa.Core/Config.fs diff --git a/.gitignore b/.gitignore index 5f54bfb..5318173 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ bin/ obj/ core +publish/ +*.tar.gz # Fable *.fs.js @@ -9,4 +11,4 @@ node_modules/ dist/ *.fable-temp.csproj -TJLaskuri.Web/wwwroot/js/app.js +Aamukampa.Web/wwwroot/app.js diff --git a/Aamukampa.Core/Aamukampa.Core.fsproj b/Aamukampa.Core/Aamukampa.Core.fsproj index bc6029f..c0afaae 100644 --- a/Aamukampa.Core/Aamukampa.Core.fsproj +++ b/Aamukampa.Core/Aamukampa.Core.fsproj @@ -7,6 +7,7 @@ + diff --git a/Aamukampa.Core/Config.fs b/Aamukampa.Core/Config.fs new file mode 100644 index 0000000..f960fb2 --- /dev/null +++ b/Aamukampa.Core/Config.fs @@ -0,0 +1,4 @@ +module Aamukampa.Core.Config + +[] +let pathBase = "/tj/" diff --git a/Aamukampa.Core/Views.fs b/Aamukampa.Core/Views.fs index 09bc236..a447688 100644 --- a/Aamukampa.Core/Views.fs +++ b/Aamukampa.Core/Views.fs @@ -1,10 +1,12 @@ -namespace TJLaskuri.Core.Views +namespace Aamukampa.Core.Views open System +open System.IO open Falco.Markup open Elem open Attr open Text +open Aamukampa.Core module Document = let view documentBody = @@ -13,8 +15,8 @@ module Document = meta [ charset "utf-8" ] meta [ name "viewport"; content "width=device-width" ] Elem.title [] [ raw "Aamukampa" ] - script [ type' "module"; src "/js/app.js" ] [] - link [ rel "stylesheet"; href "/styles.css" ] + script [ type' "module"; src (Path.Combine(Config.pathBase, "js/app.js")) ] [] + link [ rel "stylesheet"; href (Path.Combine(Config.pathBase, "styles.css")) ] ] body [] [ documentBody @@ -37,7 +39,7 @@ module Main = enc (string <| Math.Ceiling model.TimeLeft.TotalDays) ] Elem.span [ class' "counter_mornings" ] [ - raw " aamua" + raw "aamua" ] ] @@ -45,20 +47,23 @@ module Main = let p = 100.0 * (1.0 - model.TimeLeft / (model.TimeLeft + model.TimeCompleted)) let cssWidth = sprintf "%s%%" (p.ToString("F2")) - div [ - class' "progress-bar_value" - style <| - sprintf "background-color: green; width: %s" - cssWidth - ] [ - span <| sprintf "%s %%" (p.ToString("F2")) + Elem.span [ class' "progress-bar_label" ] [ + raw <| sprintf "%s %%" (p.ToString("F2")) + ] + div [ class' "progress-bar_bar" ] [ + div [ + class' "progress-bar_value" + style <| + sprintf "width: %s" + cssWidth + ] [] ] ] Elem.p [ style "text-align: center; font-size: 1.5rem;" ] [ - enc "2/25 347" + enc "2/25 255" ] // div [] [ diff --git a/Aamukampa.Web/Aamukampa.Web.fsproj b/Aamukampa.Web/Aamukampa.Web.fsproj index b9bf516..1e24cf4 100644 --- a/Aamukampa.Web/Aamukampa.Web.fsproj +++ b/Aamukampa.Web/Aamukampa.Web.fsproj @@ -21,7 +21,7 @@ diff --git a/Aamukampa.Web/Modules/Index.fs b/Aamukampa.Web/Modules/Index.fs index 2682028..b6aacb6 100644 --- a/Aamukampa.Web/Modules/Index.fs +++ b/Aamukampa.Web/Modules/Index.fs @@ -20,7 +20,7 @@ let get : HttpHandler = fun ctx -> let time = DateTime.Now let kontingent = kontingent 2 2025 - let timeLeft = Domain.getTimeLeft kontingent ThreeFourSeven time |> Option.get + let timeLeft = Domain.getTimeLeft kontingent TwoFiveFive time |> Option.get let completed = Domain.getTimeCompleted kontingent time |> Option.get view { diff --git a/Aamukampa.Web/Program.fs b/Aamukampa.Web/Program.fs index 92ff800..81ed098 100644 --- a/Aamukampa.Web/Program.fs +++ b/Aamukampa.Web/Program.fs @@ -2,6 +2,7 @@ open Microsoft.AspNetCore.Builder open Microsoft.Extensions.Hosting open Falco open Falco.Routing +open Aamukampa.Core open Aamukampa.Web.Modules let endpoints = [ @@ -15,6 +16,9 @@ let main args = app.MapStaticAssets() |> ignore + if (Config.pathBase.TrimEnd('/')) <> "" then + app.UsePathBase(Config.pathBase) |> ignore + app .UseRouting() .UseFalco(endpoints) diff --git a/Aamukampa.Web/wwwroot/styles.css b/Aamukampa.Web/wwwroot/styles.css index 66a6ef5..d492bd1 100644 --- a/Aamukampa.Web/wwwroot/styles.css +++ b/Aamukampa.Web/wwwroot/styles.css @@ -1,6 +1,5 @@ * { box-sizing: border-box; - max-width: none; } html { @@ -51,22 +50,21 @@ body { display: block; } -.progress-bar { - height: 25px; +.progress-bar_label { + display: inline-block; + width: 100%; + text-align: center; +} + +.progress-bar_bar { + height: 1.2rem; border-radius: 5px; border: 1px solid black; background-color: lightgrey; } .progress-bar_value { - color: white; + background-color: green; height: 100%; - display: flex; - padding: 0 10px; - justify-content: flex-end; - align-items: center; - white-space: nowrap; - text-align: center; border-radius: 5px; - min-width: 0; } -- cgit v1.2.3