diff --git a/Application.hs b/Application.hs index 123aaf9..b23b11f 100644 --- a/Application.hs +++ b/Application.hs @@ -35,6 +35,7 @@ import Handler.Profile import Handler.Upload import Handler.NewAlbum import Handler.Album +import Handler.Medium -- 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/Medium.hs b/Handler/Medium.hs new file mode 100644 index 0000000..e2b0b54 --- /dev/null +++ b/Handler/Medium.hs @@ -0,0 +1,26 @@ +module Handler.Medium where + +import Import +import Data.Time +import System.Locale + +getMediumR :: MediumId -> Handler Html +getMediumR mediumId = do + tempMedium <- runDB $ get mediumId + case tempMedium of + Just medium -> do + ownerId <- return $ mediumOwner medium + owner <- runDB $ getJust ownerId + ownerName <- return $ userName owner + msu <- lookupSession "userId" + presence <- case msu of + Just tempUserId -> do + userId <- return $ getUserIdFromText tempUserId + return (userId == ownerId) + Nothing -> + return False + defaultLayout $ do + $(widgetFile "medium") + Nothing -> do + setMessage "This image does not exist" + redirect $ HomeR diff --git a/config/routes b/config/routes index 3bc51e8..fa54457 100644 --- a/config/routes +++ b/config/routes @@ -11,4 +11,5 @@ /user/#UserId ProfileR GET /upload UploadR GET POST /newalbum NewAlbumR GET POST -/user/#UserId/album/#AlbumId AlbumR GET +/album/#AlbumId AlbumR GET +/medium/#MediumId MediumR GET diff --git a/eidolon.cabal b/eidolon.cabal index eaba0eb..d045fe7 100644 --- a/eidolon.cabal +++ b/eidolon.cabal @@ -28,6 +28,7 @@ library Handler.Upload Handler.NewAlbum Handler.Album + Handler.Medium if flag(dev) || flag(library-only) cpp-options: -DDEVELOPMENT @@ -83,6 +84,7 @@ library , time , yesod-persistent , transformers + , old-locale executable eidolon if flag(library-only) diff --git a/templates/album.hamlet b/templates/album.hamlet index d95f7db..6734980 100644 --- a/templates/album.hamlet +++ b/templates/album.hamlet @@ -11,6 +11,5 @@ by #{ownerName} Images in this album: $forall (medium) <- media
-
#{mediumTitle medium} diff --git a/templates/home.hamlet b/templates/home.hamlet index 1a326df..ea1778e 100644 --- a/templates/home.hamlet +++ b/templates/home.hamlet @@ -3,6 +3,6 @@ $if null recentMedia $else $forall (Entity mediumId medium) <- recentMedia
- +
#{mediumTitle medium} diff --git a/templates/medium.hamlet b/templates/medium.hamlet new file mode 100644 index 0000000..81709b2 --- /dev/null +++ b/templates/medium.hamlet @@ -0,0 +1,9 @@ +

#{mediumTitle medium} + +