From 54ea45cf33a337b1d22716ccf67523d263621163 Mon Sep 17 00:00:00 2001
From: Steve Ayerhart <steve@ayerh.art>
Date: Fri, 8 Sep 2023 16:24:48 -0400
Subject: [PATCH] refactor chloe

---
 triangle-beer-league/daysmart/daysmart.factor |  5 +++-
 triangle-beer-league/entities/entities.factor |  2 +-
 triangle-beer-league/tbl.css                  | 20 ++++++-------
 triangle-beer-league/tbl.css.map              |  2 +-
 .../triangle-beer-league.factor               | 28 ++++++++++++++++---
 5 files changed, 40 insertions(+), 17 deletions(-)

diff --git a/triangle-beer-league/daysmart/daysmart.factor b/triangle-beer-league/daysmart/daysmart.factor
index b4c3a66..5efdaaf 100644
--- a/triangle-beer-league/daysmart/daysmart.factor
+++ b/triangle-beer-league/daysmart/daysmart.factor
@@ -50,7 +50,7 @@ CONSTANT: datetime-regex "^(?<month>\\w{3}) (?<day>\\d{0,2}).{7}(?<hour>\\d{0,2}
         [ name>> text = ] filter
         [ text>> ] map
         [ first R/ \s*Game$/ "" re-replace ]
-        [ second ] [ fourth ] tri [ normalize-team-name ] bi@ schedule boa
+        [ second ] [ fourth ] tri [ normalize-team-name ] bi@ team-schedule boa
     ] { } map-as
     [ home>> tbl-team-name? ] filter ;
 
@@ -134,5 +134,8 @@ CONSTANT: datetime-regex "^(?<month>\\w{3}) (?<day>\\d{0,2}).{7}(?<hour>\\d{0,2}
      </section>
     XML] ;
 
+: tbl-games? ( -- ? )
+    tbl-games empty? not ;
+
 : render-schedule ( -- )
     tbl-games [ render-day-schedule pprint-xml ] each ;
diff --git a/triangle-beer-league/entities/entities.factor b/triangle-beer-league/entities/entities.factor
index 263355b..9118a99 100644
--- a/triangle-beer-league/entities/entities.factor
+++ b/triangle-beer-league/entities/entities.factor
@@ -6,7 +6,7 @@ TUPLE: team
 TUPLE: team-schedule
     start home away ;
 
-TUPLE: schedule
+TUPLE: game-schedule
     start away home ;
 
 CONSTANT: teams
diff --git a/triangle-beer-league/tbl.css b/triangle-beer-league/tbl.css
index 0fafd01..a05a21a 100644
--- a/triangle-beer-league/tbl.css
+++ b/triangle-beer-league/tbl.css
@@ -147,25 +147,25 @@ main {
           text-transform: uppercase;
           display: flex;
           flex-direction: column; }
-          main.schedule .game .team-times .teams .team.maroon {
+          main.schedule .game .team-times .teams span.maroon {
             color: maroon; }
-          main.schedule .game .team-times .teams .team.yellow {
+          main.schedule .game .team-times .teams span.yellow {
             color: yellow; }
-          main.schedule .game .team-times .teams .team.black {
+          main.schedule .game .team-times .teams span.black {
             color: black; }
-          main.schedule .game .team-times .teams .team.white {
+          main.schedule .game .team-times .teams span.white {
             color: white; }
-          main.schedule .game .team-times .teams .team.red {
+          main.schedule .game .team-times .teams span.red {
             color: red; }
-          main.schedule .game .team-times .teams .team.blue {
+          main.schedule .game .team-times .teams span.blue {
             color: blue; }
-          main.schedule .game .team-times .teams .team.light-blue {
+          main.schedule .game .team-times .teams span.light.blue {
             color: lightblue; }
-          main.schedule .game .team-times .teams .team.orange {
+          main.schedule .game .team-times .teams span.orange {
             color: orange; }
-          main.schedule .game .team-times .teams .team.teal {
+          main.schedule .game .team-times .teams span.teal {
             color: teal; }
-          main.schedule .game .team-times .teams .team.green {
+          main.schedule .game .team-times .teams span.green {
             color: green; }
 
 #triangle {
diff --git a/triangle-beer-league/tbl.css.map b/triangle-beer-league/tbl.css.map
index 734dfd6..8c63326 100644
--- a/triangle-beer-league/tbl.css.map
+++ b/triangle-beer-league/tbl.css.map
@@ -1,6 +1,6 @@
 {
 "version": 3,
-"mappings": "AAAA,CAAE;EACE,MAAM,EAAE,CAAC;EACT,OAAO,EAAE,CAAC;;AAGd,sBAAuB;EACnB,UAAU,EAAE,UAAU;;AAG1B,iBAIC;EAHG,IAAK;IACD,SAAS,EAAE,aAAa;AAIhC,IAAK;EACD,OAAO,EAAE,IAAI;EACb,cAAc,EAAE,MAAM;EACtB,MAAM,EAAE,KAAK;EACb,KAAK,EAAE,KAAK;EACZ,WAAW,EAAE,MAAM;EACnB,gBAAgB,EAAE,OAA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K,EAAE,SAAS;UAGpB,kDAAS;YACL,KAAK,EAAE,MAAM;UAGjB,gDAAO;YACH,KAAK,EAAE,IAAI;UAEf,iDAAQ;YACJ,KAAK,EAAE,KAAK;;AASxC,SAAU;EACN,MAAM,EAAE,IAAI;EACZ,KAAK,EAAE,IAAI;EACX,SAAS,EAAE,KAAK;EAChB,UAAU,EAAE,KAAK;EACjB,SAAS,EAAE,8BAA8B;EACzC,QAAQ,EAAE,QAAQ;EAClB,OAAO,EAAE,CAAC;EAGV,QAAQ,EAAE,MAAM;EAChB,OAAO,EAAE,IAAI;EAEb,iBAAU;IACN,OAAO,EAAE,EAAE;IACX,QAAQ,EAAE,QAAQ;IAClB,OAAO,EAAE,EAAE;IACX,IAAI,EAAE,IAAI;IACV,GAAG,EAAE,IAAI;IACT,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,IAAI;IACZ,iBAAiB,EAAE,SAAS;IAC5B,eAAe,EAAE,gBAAgB;IACjC,mBAAmB,EAAE,8BAA8B;IACnD,gBAAgB,EAAE,0IAA0I;IAC5J,SAAS,EAAE,yBAAyB;EAGxC,gBAAS;IACL,gBAAgB,EAAE,8BAA8B;IAEhD,gBAAgB,EAAE,OAAO;IACzB,eAAe,EAAE,GAAG;IACpB,iBAAiB,EAAE,SAAS;IAC5B,mBAAmB,EAAE,UAAU;IAC/B,OAAO,EAAE,EAAE;IACX,QAAQ,EAAE,QAAQ;IAClB,OAAO,EAAE,EAAE;IACX,IAAI,EAAE,IAAI;IACV,GAAG,EAAE,GAAG;IACR,KAAK,EAAE,iBAAiB;IACxB,MAAM,EAAE,iBAAiB;IACzB,SAAS,EAAE,OAAO",
 "sources": ["../../../ayerhart-design/tbl/tbl.scss"],
 "names": [],
 "file": "tbl.css"
diff --git a/triangle-beer-league/triangle-beer-league.factor b/triangle-beer-league/triangle-beer-league.factor
index 1faace6..07224f9 100644
--- a/triangle-beer-league/triangle-beer-league.factor
+++ b/triangle-beer-league/triangle-beer-league.factor
@@ -1,26 +1,46 @@
-USING: accessors namespaces ;
+USING: accessors namespaces kernel sequences arrays urls present farkup ;
+USING: math.parser math.text.english ;
 USING: io.sockets.secure io.servers ;
-USING: furnace.actions furnace.boilerplate ;
+USING: furnace.actions furnace.boilerplate furnace.utilities furnace.chloe-tags ;
+USING: calendar calendar.english ;
+USING: html.forms ;
 USING: http.server http.server.dispatchers http.server.static ;
 
+USING: triangle-beer-league.daysmart ;
+
 IN: triangle-beer-league
 
 SYMBOLS: key-password key-file dh-file ;
 
+! DTO
+TUPLE: schedule header schedules ;
+
 TUPLE: tbl < dispatcher ;
 
 : <splash-action> ( -- action )
     <page-action>
     { tbl "tbl" } >>template ;
 
+: timestamp>day-header ( timestamp -- str )
+    [ day-of-week day-name ]
+    [ month>> month-name ]
+    [ day>> dup number>string swap ordinal-suffix append ] tri
+    3array " " join ;
+
+: tbl-games>schedule ( game-schedules -- schedules )
+    [ [ first timestamp>day-header ] [ second ] bi schedule boa ] map ;
+
 : <schedule-action> ( -- action )
     <page-action>
+    [ tbl-games tbl-games>schedule "schedule" set-value ] >>init
     { tbl "schedule" } >>template ;
 
 : <tbl> ( -- responder )
     tbl new-dispatcher
-    "resource:work/triangle-beer-league" <static> enable-fhtml >>default ;
-
+    "resource:work/triangle-beer-league" <static> >>default
+    <schedule-action> "schedule" add-responder
+    <boilerplate>
+    { tbl "tbl-common" } >>template ;
 
 : <tbl-website-server> ( -- threaded-server )
     <http-server>