From 57610a8b996af5dc51e2f148e8b02d509f816f7d Mon Sep 17 00:00:00 2001 From: nek0 Date: Sun, 14 Sep 2014 05:03:13 +0200 Subject: [PATCH] working with tags --- Application.hs | 1 + Handler/Tag.hs | 16 ++++++++++++++++ config/routes | 1 + eidolon.cabal | 1 + templates/medium.hamlet | 9 +++++++++ templates/tagMedia.hamlet | 13 +++++++++++++ 6 files changed, 41 insertions(+) create mode 100644 Handler/Tag.hs create mode 100644 templates/tagMedia.hamlet diff --git a/Application.hs b/Application.hs index e3e25b5..ea65e10 100644 --- a/Application.hs +++ b/Application.hs @@ -45,6 +45,7 @@ import Handler.Admin import Handler.AdminProfileSettings import Handler.AdminAlbumSettings import Handler.AdminMediumSettings +import Handler.Tag -- This line actually creates our YesodDispatch instance. It is the second half -- of the call to mkYesodData which occurs in Foundation.hs. Please see the diff --git a/Handler/Tag.hs b/Handler/Tag.hs new file mode 100644 index 0000000..962fd7b --- /dev/null +++ b/Handler/Tag.hs @@ -0,0 +1,16 @@ +module Handler.Tag where + +import Import +import Data.Maybe + +getTagR :: Text -> Handler Html +getTagR tag = do + tempMedia <- runDB $ selectList [] [Desc MediumTitle] + almostMedia <- mapM (\a -> do + case tag `elem` (mediumTags $ entityVal a) of + True -> return (Just a) + False -> return Nothing + ) tempMedia + media <- return $ removeItem Nothing almostMedia + defaultLayout $ do + $(widgetFile "tagMedia") diff --git a/config/routes b/config/routes index fae32bc..cfb8ade 100644 --- a/config/routes +++ b/config/routes @@ -36,3 +36,4 @@ /admin/medium AdminMediaR GET /admin/medium/#MediumId AdminMediumSettingsR GET POST /admin/meidum/#MediumId/delete AdminMediumDeleteR GET +/tag/#Text TagR GET diff --git a/eidolon.cabal b/eidolon.cabal index 31d7d1d..489cfe7 100644 --- a/eidolon.cabal +++ b/eidolon.cabal @@ -38,6 +38,7 @@ library Handler.AdminProfileSettings Handler.AdminAlbumSettings Handler.AdminMediumSettings + Handler.Tag if flag(dev) || flag(library-only) cpp-options: -DDEVELOPMENT diff --git a/templates/medium.hamlet b/templates/medium.hamlet index 5549dd5..01f0d4f 100644 --- a/templates/medium.hamlet +++ b/templates/medium.hamlet @@ -13,5 +13,14 @@ by #{ownerName} from album #{mediumDescription medium}
+
+ Tags: +