added medium site

This commit is contained in:
nek0 2014-08-18 06:06:16 +02:00
parent 71440a65ce
commit 8b6d75a997
8 changed files with 45 additions and 6 deletions

View file

@ -35,6 +35,7 @@ import Handler.Profile
import Handler.Upload import Handler.Upload
import Handler.NewAlbum import Handler.NewAlbum
import Handler.Album import Handler.Album
import Handler.Medium
-- This line actually creates our YesodDispatch instance. It is the second half -- 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 -- of the call to mkYesodData which occurs in Foundation.hs. Please see the

26
Handler/Medium.hs Normal file
View file

@ -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

View file

@ -11,4 +11,5 @@
/user/#UserId ProfileR GET /user/#UserId ProfileR GET
/upload UploadR GET POST /upload UploadR GET POST
/newalbum NewAlbumR GET POST /newalbum NewAlbumR GET POST
/user/#UserId/album/#AlbumId AlbumR GET /album/#AlbumId AlbumR GET
/medium/#MediumId MediumR GET

View file

@ -28,6 +28,7 @@ library
Handler.Upload Handler.Upload
Handler.NewAlbum Handler.NewAlbum
Handler.Album Handler.Album
Handler.Medium
if flag(dev) || flag(library-only) if flag(dev) || flag(library-only)
cpp-options: -DDEVELOPMENT cpp-options: -DDEVELOPMENT
@ -83,6 +84,7 @@ library
, time , time
, yesod-persistent , yesod-persistent
, transformers , transformers
, old-locale
executable eidolon executable eidolon
if flag(library-only) if flag(library-only)

View file

@ -11,6 +11,5 @@ by <a href=@{ProfileR ownerId}>#{ownerName}</a>
Images in this album: Images in this album:
$forall (medium) <- media $forall (medium) <- media
<div class="thumbnails"> <div class="thumbnails">
<a href=#{mediumPath medium}>
<img src=#{mediumPath medium}><br> <img src=#{mediumPath medium}><br>
#{mediumTitle medium} #{mediumTitle medium}

View file

@ -3,6 +3,6 @@ $if null recentMedia
$else $else
$forall (Entity mediumId medium) <- recentMedia $forall (Entity mediumId medium) <- recentMedia
<div class="thumbnails"> <div class="thumbnails">
<a href=#{mediumPath medium}> <a href=@{MediumR mediumId}>
<img src=#{mediumPath medium}><br> <img src=#{mediumPath medium}><br>
#{mediumTitle medium} #{mediumTitle medium}

9
templates/medium.hamlet Normal file
View file

@ -0,0 +1,9 @@
<h3>#{mediumTitle medium}
<div class="image">
<img src=#{mediumPath medium}>
<div class="desc">
Uploaded on: #{formatTime defaultTimeLocale "%A %F %H:%M" (mediumTime medium)}
Description:<br>
#{mediumDescription medium}

View file

@ -7,7 +7,7 @@ $else
Albums of this user: Albums of this user:
$forall (Entity albumId album) <- userAlbs $forall (Entity albumId album) <- userAlbs
<div class="thumbnails"> <div class="thumbnails">
<a href=@{AlbumR ownerId albumId}> <a href=@{AlbumR albumId}>
<img width="200px" src="/static/img/album.jpg"><br> <img width="200px" src="/static/img/album.jpg"><br>
#{albumTitle album} #{albumTitle album}
@ -15,6 +15,7 @@ $if null recentMedia
This user has not uploaded any images This user has not uploaded any images
$else $else
Newest images: Newest images:
$forall (Entity mediaId medium) <- take 10 recentMedia $forall (Entity mediumId medium) <- take 10 recentMedia
<div class="thumbnails"> <div class="thumbnails">
<img src=#{mediumPath medium}> <a href=@{MediumR mediumId}>
<img src=#{mediumPath medium}>