linkify calendar entries

This commit is contained in:
Daniel Barlow 2024-11-10 17:30:28 +00:00
parent 7a1901af7b
commit ea2732e525

View File

@ -10,7 +10,9 @@ import Control.Monad.Logger (runStderrLoggingT)
import Control.Monad.Trans.Resource (runResourceT) import Control.Monad.Trans.Resource (runResourceT)
import Data.ByteString.Lazy as BS import Data.ByteString.Lazy as BS
import Data.List as List import Data.List as List
import Data.Time.Clock.POSIX (posixSecondsToUTCTime) import Data.Text as T
import Data.Time.Clock.POSIX (posixSecondsToUTCTime, utcTimeToPOSIXSeconds)
import Data.Time.Clock (nominalDiffTimeToSeconds)
import Database.Persist.Postgresql (ConnectionPool, ConnectionString, SqlBackend, runMigration, runSqlPool, getPgInterval, withPostgresqlPool) import Database.Persist.Postgresql (ConnectionPool, ConnectionString, SqlBackend, runMigration, runSqlPool, getPgInterval, withPostgresqlPool)
import Debug.Trace (traceShow) import Debug.Trace (traceShow)
import Session import Session
@ -56,6 +58,8 @@ instance YesodPersist Souplesse where
getCalendarR :: Handler Html getCalendarR :: Handler Html
getCalendarR = do getCalendarR = do
let fTime = T.pack . show . floor . utcTimeToPOSIXSeconds
fDur = T.pack . show . ceiling . nominalDiffTimeToSeconds . getPgInterval
(formWidget, _) <- generateFormPost uploadForm (formWidget, _) <- generateFormPost uploadForm
sessions' <- runDB Session.recents sessions' <- runDB Session.recents
defaultLayout defaultLayout
@ -65,8 +69,8 @@ getCalendarR = do
<p>A calendar view goes here <p>A calendar view goes here
<ul> <ul>
$forall s <- sessions' $forall s <- sessions'
<li>#{show $ sessionStartTime s} #{show $ getPgInterval (sessionDuration s)} <li>
<a href=@?{(TimelineR, [("start", fTime $ sessionStartTime s), ("duration", fDur $ sessionDuration s)])} > #{show $ sessionStartTime s} #{show $ getPgInterval (sessionDuration s)}
<form action="/upload" method=post enctype="multipart/form-data"> <form action="/upload" method=post enctype="multipart/form-data">
^{formWidget} ^{formWidget}