diff --git a/config/models b/config/models index 786b9cc..17a4302 100644 --- a/config/models +++ b/config/models @@ -26,7 +26,6 @@ Profile displayName Text Maybe sqltype=varchar(255) Entry - slug Slug Maybe maxlen=255 kind EntryKind maxlen=255 name Text Maybe maxlen=255 content Text sqltype=longtext diff --git a/src/Model.hs b/src/Model.hs index b587826..98d0306 100644 --- a/src/Model.hs +++ b/src/Model.hs @@ -12,7 +12,6 @@ module Model where import ClassyPrelude.Yesod import Database.Persist.Quasi import Yesod.Auth.HashDB ( HashDBUser(..) ) -import Web.Slug ( Slug ) import Text.Mustache ( (~>) ) import qualified Text.Mustache as M diff --git a/src/Widget/Entry.hs b/src/Widget/Entry.hs index d73ad9e..4743ee3 100644 --- a/src/Widget/Entry.hs +++ b/src/Widget/Entry.hs @@ -10,6 +10,7 @@ import Database.Esqueleto ( (^.) ) import qualified Database.Esqueleto as E import Data.Time.Format ( defaultTimeLocale, formatTime, iso8601DateFormat ) import Data.Time.Format.Human ( humanReadableTime ) +import Web.Slug ( mkSlug ) data FormattedTime = FormattedTime { timeUnfriendly :: String @@ -22,7 +23,7 @@ toFormattedTime time = FormattedTime (unfriendly time) <$> friendly time friendly = liftIO . humanReadableTime entryR :: Entity Entry -> Route App -entryR (Entity entryId Entry {..}) = route entrySlug entryKind entryId +entryR (Entity entryId Entry {..}) = route (entryName >>= mkSlug) entryKind entryId where route (Just s) = \k i -> EntryWithSlugR k i s route Nothing = EntryR