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
|
data EntryKind = Note | Article | Photo | Video | Audio
|
||||||
| Reply | Repost | Like | Favourite | Bookmark | Quote | Rsvp
|
| Reply | Repost | Like | Favourite | Bookmark | Quote | Rsvp
|
||||||
| Listen | Jam | Watch | Play | Read
|
| Listen | Jam | Watch | Play | Read
|
||||||
deriving (Eq, Read, Show)
|
deriving (Enum, Eq, Read, Show)
|
||||||
derivePersistField "EntryKind"
|
derivePersistField "EntryKind"
|
||||||
|
|
||||||
|
allEntryKinds :: [EntryKind]
|
||||||
|
allEntryKinds = [Note ..]
|
||||||
|
|
||||||
singularise :: T.Text -> Maybe EntryKind
|
singularise :: T.Text -> Maybe EntryKind
|
||||||
singularise "replies" = Just Reply
|
singularise "replies" = Just Reply
|
||||||
singularise "watches" = Just Watch
|
singularise "watches" = Just Watch
|
||||||
|
|
|
@ -21,7 +21,7 @@ import Yesod.Core.Types (Logger)
|
||||||
import qualified Yesod.Core.Unsafe as Unsafe
|
import qualified Yesod.Core.Unsafe as Unsafe
|
||||||
|
|
||||||
import Package
|
import Package
|
||||||
import Entry.Kind ( EntryKind, pluralise )
|
import Entry.Kind ( EntryKind, allEntryKinds, pluralise )
|
||||||
|
|
||||||
import Data.Aeson ( encode, object )
|
import Data.Aeson ( encode, object )
|
||||||
import qualified Text.Blaze.Internal as B
|
import qualified Text.Blaze.Internal as B
|
||||||
|
@ -152,7 +152,8 @@ instance Yesod App where
|
||||||
makeLogger = return . appLogger
|
makeLogger = return . appLogger
|
||||||
|
|
||||||
leftMenuItems, rightMenuItems :: Maybe (UserId, User) -> [MenuItem]
|
leftMenuItems, rightMenuItems :: Maybe (UserId, User) -> [MenuItem]
|
||||||
leftMenuItems _ = []
|
leftMenuItems _ = toMenuItem <$> take 5 allEntryKinds
|
||||||
|
where toMenuItem kind = pluralise kind `MenuItem` EntriesR kind
|
||||||
rightMenuItems = loggedOutItems `maybe` loggedInItems
|
rightMenuItems = loggedOutItems `maybe` loggedInItems
|
||||||
where loggedOutItems =
|
where loggedOutItems =
|
||||||
[ "log in" `MenuItem` AuthR LoginR
|
[ "log in" `MenuItem` AuthR LoginR
|
||||||
|
|
Loading…
Reference in a new issue