Add basic support for h-entry categories, which are actually more like tags than categories really

This commit is contained in:
Danielle McLean 2017-10-14 14:59:51 +11:00
parent dfafe33e06
commit 474ed3cf28
Signed by: 00dani
GPG key ID: 5A5D2D1AFF12EEC5
5 changed files with 35 additions and 0 deletions

22
src/Handler/Categories.hs Normal file
View file

@ -0,0 +1,22 @@
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
module Handler.Categories where
import Import hiding ( on, (==.) )
import Database.Esqueleto
import Web.Slug ( Slug, unSlug )
import Widget.Feed ( hFeed )
import qualified Data.Text as T
getCategoryR :: Slug -> Handler Html
getCategoryR tag = do
entries <- runDB . select . from $ \(category `InnerJoin` ec `InnerJoin` entry) -> do
on $ entry ^. EntryId ==. ec ^. EntryCategoryEntryId
on $ category ^. CategoryId ==. ec ^. EntryCategoryCategoryId
where_ $ category ^. CategoryTag ==. val tag
return entry
defaultLayout $ do
setTitle . toHtml . T.cons '#' . unSlug $ tag
hFeed entries