Pretty up the h-entry as a Bootstrap card
This commit is contained in:
parent
7cebf92356
commit
934457f671
3 changed files with 27 additions and 12 deletions
|
@ -48,6 +48,7 @@ dependencies:
|
||||||
- wai
|
- wai
|
||||||
|
|
||||||
- conduit-combinators >= 1.1 && < 1.2
|
- conduit-combinators >= 1.1 && < 1.2
|
||||||
|
- friendly-time >=0.4 && < 0.5
|
||||||
- libravatar >=0.4 && <0.5
|
- libravatar >=0.4 && <0.5
|
||||||
- slug >=0.1 && <0.2
|
- slug >=0.1 && <0.2
|
||||||
- split >=0.2 && <0.3
|
- split >=0.2 && <0.3
|
||||||
|
|
|
@ -5,10 +5,22 @@ module Widget.Entry ( entryR, hEntry ) where
|
||||||
|
|
||||||
import Import
|
import Import
|
||||||
|
|
||||||
|
import Data.Time.Format ( defaultTimeLocale, formatTime, iso8601DateFormat )
|
||||||
|
import Data.Time.Format.Human ( humanReadableTime )
|
||||||
|
|
||||||
|
data FormattedTime = FormattedTime { timeUnfriendly :: String, timeFriendly :: String }
|
||||||
|
|
||||||
|
toFormattedTime :: MonadIO m => UTCTime -> m FormattedTime
|
||||||
|
toFormattedTime time = FormattedTime (unfriendly time) <$> friendly time
|
||||||
|
where unfriendly = formatTime defaultTimeLocale . iso8601DateFormat . Just $ "%H:%M:%S%z"
|
||||||
|
friendly = liftIO . humanReadableTime
|
||||||
|
|
||||||
entryR :: Entity Entry -> Route App
|
entryR :: Entity Entry -> Route App
|
||||||
entryR (Entity entryId entry) = EntryR (entryKind entry) entryId (entrySlug entry)
|
entryR (Entity entryId entry) = EntryR (entryKind entry) entryId (entrySlug entry)
|
||||||
|
|
||||||
hEntry :: Entity Entry -> Widget
|
hEntry :: Entity Entry -> Widget
|
||||||
hEntry (Entity entryId entry) = do
|
hEntry (Entity entryId entry) = do
|
||||||
|
published <- toFormattedTime . entryPublished $ entry
|
||||||
|
updated <- toFormattedTime . entryUpdated $ entry
|
||||||
maybeAuthor <- handlerToWidget . runDB . get . entryAuthorId $ entry
|
maybeAuthor <- handlerToWidget . runDB . get . entryAuthorId $ entry
|
||||||
$(widgetFile "mf2/h-entry")
|
$(widgetFile "mf2/h-entry")
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
<article .h-entry>
|
<article .h-entry .card.bg-dark>
|
||||||
<h1 .p-name>#{entryName entry}
|
<div .card-body>
|
||||||
<a .u-url href="@{entryR (Entity entryId entry)}">permalink
|
<h4 .p-name .card-title>#{entryName entry}
|
||||||
<p>
|
|
||||||
published
|
|
||||||
$maybe author <- maybeAuthor
|
$maybe author <- maybeAuthor
|
||||||
\ by
|
<p .card-subtitle>
|
||||||
<a .p-author.h-card href=@{HomeR}>
|
published by
|
||||||
#{userFullName author}
|
<a .p-author.h-card href=@{HomeR}>#{userFullName author}
|
||||||
on
|
<div .e-content>
|
||||||
<time .dt-published datetime=#{show $ entryPublished entry}>
|
#{entryContent entry}
|
||||||
<div .e-content>
|
<a .u-url .card-link href="@{entryR (Entity entryId entry)}">permalink
|
||||||
#{entryContent entry}
|
<div .card-footer>
|
||||||
|
<time .dt-published datetime=#{timeUnfriendly published}>
|
||||||
|
#{timeFriendly published}
|
||||||
|
<time .dt-updated datetime=#{timeUnfriendly updated}>
|
||||||
|
#{timeFriendly updated}
|
||||||
|
|
Loading…
Reference in a new issue