diff --git a/samples/apachemodule/Apache24/logs/do_not_delete_me b/samples/apachemodule/Apache24/logs/do_not_delete_me new file mode 100644 index 00000000..e69de29b diff --git a/samples/htmx_website/ControllerU.pas b/samples/htmx_website/ControllerU.pas index 5701e947..bf67c603 100644 --- a/samples/htmx_website/ControllerU.pas +++ b/samples/htmx_website/ControllerU.pas @@ -33,11 +33,17 @@ type implementation uses - System.StrUtils, System.SysUtils, MVCFramework.Logger, MVCFramework.HTMX; + System.StrUtils, System.SysUtils, MVCFramework.Logger, MVCFramework.HTMX, RandomUtilsU; function TMyController.Customers: String; begin - Result := Page(['pages/customers']); + var lCustomers := GetPeople(); + try + ViewData['customers'] := lCustomers; + Result := Page(['pages/customers']); + finally + lCustomers.Free; + end; end; function TMyController.Home: String; @@ -54,12 +60,24 @@ end; function TMyController.Posts: String; begin - Result := Page(['pages/posts']); + var lPosts := GetPosts(20); + try + ViewData['posts'] := lPosts; + Result := Page(['pages/posts']); + finally + lPosts.Free; + end; end; function TMyController.Users: String; begin - Result := Page(['pages/users']); + var lUsers := GetUsers(); + try + ViewData['users'] := lUsers; + Result := Page(['pages/users']); + finally + lUsers.Free; + end; end; end. diff --git a/samples/htmx_website/WebModuleU.pas b/samples/htmx_website/WebModuleU.pas index 6521ab9f..cdc21a83 100644 --- a/samples/htmx_website/WebModuleU.pas +++ b/samples/htmx_website/WebModuleU.pas @@ -33,7 +33,8 @@ uses MVCFramework.Middleware.Trace, MVCFramework.Middleware.CORS, MVCFramework.Middleware.ETag, - MVCFramework.Middleware.Compression, ControllerU; + MVCFramework.Middleware.Compression, + ControllerU; procedure TMyWebModule.WebModuleCreate(Sender: TObject); begin diff --git a/samples/htmx_website/bin/templates/_footer.html b/samples/htmx_website/bin/templates/_footer.html deleted file mode 100644 index 42c8a899..00000000 --- a/samples/htmx_website/bin/templates/_footer.html +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/samples/htmx_website/bin/templates/_header.html b/samples/htmx_website/bin/templates/baselayout.html similarity index 79% rename from samples/htmx_website/bin/templates/_header.html rename to samples/htmx_website/bin/templates/baselayout.html index 08503baa..439d6817 100644 --- a/samples/htmx_website/bin/templates/_header.html +++ b/samples/htmx_website/bin/templates/baselayout.html @@ -1,3 +1,4 @@ +{{if ispage}} @@ -55,13 +56,34 @@ padding: 1rem; } + .right { + text-align: end; + } + + .center { + text-align: center; + } + + table, tr, td, th{ + padding: 0.2rem; + } + - +
{{include "partials/sidenav.html"}} -
\ No newline at end of file +
+{{endif}} +{{block "body"}}Please, override block "body"{{endblock}} +{{if ispage}} +
+
+
+ + +{{endif}} \ No newline at end of file diff --git a/samples/htmx_website/bin/templates/pages/customers.html b/samples/htmx_website/bin/templates/pages/customers.html index 8d6640fc..bdf1cd13 100644 --- a/samples/htmx_website/bin/templates/pages/customers.html +++ b/samples/htmx_website/bin/templates/pages/customers.html @@ -1,3 +1,28 @@ -{{if ispage}}{{include "../_header.html"}}{{endif}} +{{extends "../baselayout.html"}} +{{block "body"}}

Customers

-{{if ispage}}{{include "../_footer.html"}}{{endif}} \ No newline at end of file + + + + + + + + + + + + {{if customers}} + {{for cust in customers}} + + + + + + + + {{endfor}} + {{endif}} + +
CodeFirst NameLast NameCountryDOB
{{:cust.code|lpad,3,"0"}}{{:cust.first_name}}{{:cust.last_name}}{{:cust.country|capitalize}}{{:cust.dob}}
+{{endblock}} \ No newline at end of file diff --git a/samples/htmx_website/bin/templates/pages/home.html b/samples/htmx_website/bin/templates/pages/home.html index d028c799..1eb41e5d 100644 --- a/samples/htmx_website/bin/templates/pages/home.html +++ b/samples/htmx_website/bin/templates/pages/home.html @@ -1,4 +1,5 @@ -{{if ispage}}{{include "../_header.html"}}{{endif}} +{{extends "../baselayout.html"}} +{{block "body"}}

HTMX WebSite

Powered by DMVCFramework, TemplatePro and HTMX

-{{if ispage}}{{include "../_footer.html"}}{{endif}} \ No newline at end of file +{{endblock}} \ No newline at end of file diff --git a/samples/htmx_website/bin/templates/pages/posts.html b/samples/htmx_website/bin/templates/pages/posts.html index 9cd7d08b..6a580d36 100644 --- a/samples/htmx_website/bin/templates/pages/posts.html +++ b/samples/htmx_website/bin/templates/pages/posts.html @@ -1,3 +1,22 @@ -{{if ispage}}{{include "../_header.html"}}{{endif}} +{{extends "../baselayout.html"}} +{{block "body"}}

Posts

-{{if ispage}}{{include "../_footer.html"}}{{endif}} \ No newline at end of file +{{for p in posts}} +

+

+
+ {{if p.@@index|lt,4}}⭐{{endif}} + {{:p.@@index}}) {{:p.title|uppercase}} +
+ {{:p.abstract|trunc,200}} + +
+

+{{endfor}} +{{endblock}} \ No newline at end of file diff --git a/samples/htmx_website/bin/templates/pages/users.html b/samples/htmx_website/bin/templates/pages/users.html index cd587386..65b643f3 100644 --- a/samples/htmx_website/bin/templates/pages/users.html +++ b/samples/htmx_website/bin/templates/pages/users.html @@ -1,3 +1,24 @@ -{{if ispage}}{{include "../_header.html"}}{{endif}} +{{extends "../baselayout.html"}} +{{block "body"}}

Users

-{{if ispage}}{{include "../_footer.html"}}{{endif}} \ No newline at end of file + + + + + + + + + + + {{for user in users}} + + + + + + {{endfor}} + + +
First NameLast NameEMail
{{:user.first_name}}{{:user.last_name}}{{:user.email|lowercase}}
+{{endblock}} \ No newline at end of file diff --git a/samples/htmx_website/htmx_website.dpr b/samples/htmx_website/htmx_website.dpr index 0fcb47ff..03323851 100644 --- a/samples/htmx_website/htmx_website.dpr +++ b/samples/htmx_website/htmx_website.dpr @@ -13,10 +13,10 @@ uses MVCFramework.Logger, MVCFramework.DotEnv, MVCFramework.Commons, - mormot.core.mustache, MVCFramework.Signal, ControllerU in 'ControllerU.pas', - WebModuleU in 'WebModuleU.pas' {MyWebModule: TWebModule}; + WebModuleU in 'WebModuleU.pas' {MyWebModule: TWebModule}, + RandomUtilsU in '..\commons\RandomUtilsU.pas'; {$R *.res} diff --git a/samples/htmx_website/htmx_website.dproj b/samples/htmx_website/htmx_website.dproj index 1d5eaab3..5a7e62d5 100644 --- a/samples/htmx_website/htmx_website.dproj +++ b/samples/htmx_website/htmx_website.dproj @@ -126,6 +126,7 @@ dfm TWebModule + Base @@ -170,6 +171,12 @@ + + + htmx_website.exe + true + + 1