From ec2b14c9acde1d1dd2cdf14b5bfa4a60f2b1d93e Mon Sep 17 00:00:00 2001 From: librasteve Date: Tue, 13 Aug 2024 13:59:11 +0100 Subject: [PATCH] HTMOO spike --- README.md | 3 ++- bin/server.raku | 6 +++--- lib/HTMOO.rakumod | 24 +++++++++++++++++++----- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 50f50f5..3974d1d 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ NAME This module provides a programmatic style for HTML and HTMX ([htmx.org]) web content. -For now it's missing the server side piece, likely will start with Hummingbird. +For now it's missing the server side piece, likely will start with Cro. SYNOPSIS ======== @@ -93,6 +93,7 @@ TODOS #### Rejected - [ ] Do the ΒΆ term - NOPE this messes with editor code preview + AUTHOR ====== diff --git a/bin/server.raku b/bin/server.raku index 9726c92..7dbc17a 100644 --- a/bin/server.raku +++ b/bin/server.raku @@ -10,12 +10,12 @@ my $application = route { } } -my Cro::Service $hello = Cro::HTTP::Server.new: +my Cro::Service $service = Cro::HTTP::Server.new: :host, :port<10000>, :$application; -$hello.start; +$service.start; -react whenever signal(SIGINT) { $hello.stop; exit; } +react whenever signal(SIGINT) { $service.stop; exit; } #raku server.raku #lynx localhost:10000/greet/librasteve \ No newline at end of file diff --git a/lib/HTMOO.rakumod b/lib/HTMOO.rakumod index 6f4f2cb..fffbb28 100644 --- a/lib/HTMOO.rakumod +++ b/lib/HTMOO.rakumod @@ -16,10 +16,10 @@ class Meta { } class Title { - has $.title; + has $.text; method render { - '' ~ $!title ~ '' ~ "\n" + '' ~ $!text ~ '' ~ "\n" } } @@ -94,11 +94,25 @@ class Page { # example ... refactor to .new iamerejh my $page = Page.new: - Html => Html.new: - Head => Head.new: + Html => Html.new: ( + Head => ( Head.new: Meta => [ Meta.new: m1, Meta.new: m2 ], - Title => Title.new: + Title => Title.new: text => "a title", + Script => [ + Script.new: s1, + Script.new: s2 + ], + Link => [ + Link.new: l1, + ], + Style => [ + Style.new: s1, + ] + ), + Body => Body.new: text => $bt, + ), +; #iamerejh