62 lines
1.6 KiB
Factor
62 lines
1.6 KiB
Factor
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 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>
|
|
[
|
|
t "show-header?" set-value
|
|
tbl-games tbl-games>schedule "schedule" set-value
|
|
] >>init
|
|
{ tbl "schedule" } >>template ;
|
|
|
|
: <tbl> ( -- responder )
|
|
tbl new-dispatcher
|
|
"resource:work/triangle-beer-league" <static> >>default
|
|
<splash-action> "" add-responder
|
|
<schedule-action> "schedule" add-responder
|
|
<boilerplate>
|
|
{ tbl "tbl-common" } >>template ;
|
|
|
|
: <tbl-website-server> ( -- threaded-server )
|
|
<http-server>
|
|
f >>secure
|
|
8080 >>insecure ;
|
|
|
|
: start-tbl-site ( -- server )
|
|
<tbl> main-responder set-global
|
|
<tbl-website-server> start-server ;
|
|
|
|
: start-tbl ( -- )
|
|
start-tbl-site wait-for-server ;
|
|
|
|
MAIN: start-tbl
|