Add the main entry kinds to the navbar
This commit is contained in:
parent
1b8a07a5f6
commit
41375abdd4
2 changed files with 8 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue