From bd3a93d628a6a8ecfdfb8ba9217e3981b9631385 Mon Sep 17 00:00:00 2001 From: caleb Date: Tue, 8 Jul 2025 21:22:14 +0900 Subject: [PATCH] get it to run --- .editorconfig | 3 +++ Client.fs | 21 ++++----------------- Startup.fs | 9 ++++++--- wwwroot/index.html | 15 +-------------- 4 files changed, 14 insertions(+), 34 deletions(-) diff --git a/.editorconfig b/.editorconfig index 21c68e2..79d5877 100644 --- a/.editorconfig +++ b/.editorconfig @@ -15,6 +15,9 @@ fsharp_space_before_uppercase_invocation = true [*.{fs,fsx,fsi}] fsharp_bar_before_discriminated_union_declaration = true max_line_length = 120 +fsharp_array_or_list_multiline_formatter = number_of_items +fsharp_max_array_or_list_number_of_items = 4 +fsharp_max_function_binding_width=0 # C# files [*.cs] diff --git a/Client.fs b/Client.fs index ae72468..2137110 100644 --- a/Client.fs +++ b/Client.fs @@ -4,27 +4,14 @@ open WebSharper open WebSharper.JavaScript open WebSharper.UI open WebSharper.UI.Client +open WebSharper.UI.Html open WebSharper.UI.Templating [] module Client = - // The templates are loaded from the DOM, so you just can edit index.html - // and refresh your browser, no need to recompile unless you add or remove holes. - type IndexTemplate = Template<"wwwroot/index.html", ClientLoad.FromDocument> - - let People = ListModel.FromSeq [ "John"; "Paul" ] - - [] let Main () = - let newName = Var.Create "" - - IndexTemplate - .Main() - .ListContainer(People.View.DocSeqCached (fun (name: string) -> IndexTemplate.ListItem().Name(name).Doc ())) - .Name(newName) - .Add(fun _ -> - People.Add newName.Value - newName.Value <- "") - .Doc () + div [] [ + p [] [ text "hello world" ] + ] |> Doc.RunById "main" diff --git a/Startup.fs b/Startup.fs index 00834cb..a87eeb9 100644 --- a/Startup.fs +++ b/Startup.fs @@ -8,10 +8,13 @@ open web_api_cookbook [] let main args = - let builder = WebApplication.CreateBuilder (args) + let builder = WebApplication.CreateBuilder args // Add services to the container. - builder.Services.AddWebSharper().AddAuthentication("WebSharper").AddCookie ("WebSharper", fun options -> ()) + builder.Services + .AddWebSharper() + .AddAuthentication("WebSharper") + .AddCookie ("WebSharper", fun options -> ()) |> ignore let app = builder.Build () @@ -27,7 +30,7 @@ let main args = app .UseHttpsRedirection() #if DEBUG - .UseWebSharperScriptRedirect(startVite = true) +// .UseWebSharperScriptRedirect(startVite = true) #endif .UseDefaultFiles() .UseStaticFiles() diff --git a/wwwroot/index.html b/wwwroot/index.html index a3f483c..947fd9e 100644 --- a/wwwroot/index.html +++ b/wwwroot/index.html @@ -5,23 +5,10 @@ - -

My list of unique people

-
-
    -
  • ${Name}
  • -
-
- - -
You are about to add: ${Name}
-
+