diff --git a/src/Entry/Kind.hs b/src/Entry/Kind.hs index c11427a..b68488e 100644 --- a/src/Entry/Kind.hs +++ b/src/Entry/Kind.hs @@ -11,9 +11,12 @@ import Text.Read ( readMaybe ) data EntryKind = Note | Article | Photo | Video | Audio | Reply | Repost | Like | Favourite | Bookmark | Quote | Rsvp | Listen | Jam | Watch | Play | Read - deriving (Eq, Read, Show) + deriving (Enum, Eq, Read, Show) derivePersistField "EntryKind" +allEntryKinds :: [EntryKind] +allEntryKinds = [Note ..] + singularise :: T.Text -> Maybe EntryKind singularise "replies" = Just Reply singularise "watches" = Just Watch diff --git a/src/Foundation.hs b/src/Foundation.hs index ef81603..30d2afe 100644 --- a/src/Foundation.hs +++ b/src/Foundation.hs @@ -21,7 +21,7 @@ import Yesod.Core.Types (Logger) import qualified Yesod.Core.Unsafe as Unsafe import Package -import Entry.Kind ( EntryKind, pluralise ) +import Entry.Kind ( EntryKind, allEntryKinds, pluralise ) import Data.Aeson ( encode, object ) import qualified Text.Blaze.Internal as B @@ -152,7 +152,8 @@ instance Yesod App where makeLogger = return . appLogger leftMenuItems, rightMenuItems :: Maybe (UserId, User) -> [MenuItem] -leftMenuItems _ = [] +leftMenuItems _ = toMenuItem <$> take 5 allEntryKinds + where toMenuItem kind = pluralise kind `MenuItem` EntriesR kind rightMenuItems = loggedOutItems `maybe` loggedInItems where loggedOutItems = [ "log in" `MenuItem` AuthR LoginR @@ -164,7 +165,7 @@ rightMenuItems = loggedOutItems `maybe` loggedInItems -- Define breadcrumbs. instance YesodBreadcrumbs App where - breadcrumb (AuthR _) = return ("login", Just HomeR) + breadcrumb (AuthR _) = return ("log in", Just HomeR) breadcrumb (EntriesR kind) = return (pluralise kind, Just HomeR) breadcrumb (EntryR kind entryId _) = do entry <- runDB . get404 $ entryId