now working
This commit is contained in:
parent
22f4cdce73
commit
ac2cb03de8
4 changed files with 27 additions and 8 deletions
|
@ -108,23 +108,35 @@ deleteMedium mId medium = do
|
||||||
|
|
||||||
moveMedium :: Medium -> MediumId -> AlbumId -> Handler ()
|
moveMedium :: Medium -> MediumId -> AlbumId -> Handler ()
|
||||||
moveMedium med mId destId = do
|
moveMedium med mId destId = do
|
||||||
|
$(logError) "getting destination"
|
||||||
dest <- runDB $ getJust destId
|
dest <- runDB $ getJust destId
|
||||||
-- remove reference
|
-- remove reference
|
||||||
|
$(logError) "removing reference"
|
||||||
removeReference mId $ mediumAlbum med
|
removeReference mId $ mediumAlbum med
|
||||||
-- move physical Files
|
-- move physical Files
|
||||||
let filen = show $ length (albumContent dest) + 1
|
let filen = show $ length (albumContent dest) + 1
|
||||||
ext = takeExtension $ mediumPath med
|
ext = takeExtension $ mediumPath med
|
||||||
nPath = "static" </> "data" </> T.unpack (extractKey $ albumOwner dest) </> T.unpack (extractKey destId) </> filen ++ ext
|
prefix = "static" </> "data" </> T.unpack (extractKey $ albumOwner dest) </> T.unpack (extractKey destId)
|
||||||
nThumb = takeBaseName nPath ++ "_thumb.jpg"
|
nPath = prefix </> filen ++ ext
|
||||||
nPrev = takeBaseName nPath ++ "_preview.jpg"
|
nThumb = prefix </> takeBaseName nPath ++ "_thumb.jpg"
|
||||||
liftIO $ renameFile (mediumPath med) nPath
|
nPrev = prefix </> takeBaseName nPath ++ "_preview.jpg"
|
||||||
liftIO $ renameFile (mediumThumb med) nThumb
|
$(logError) $ T.pack $ "copyFile" ++ nPath
|
||||||
liftIO $ renameFile (mediumPreview med) nPrev
|
liftIO $ copyFile (L.tail $ mediumPath med) nPath
|
||||||
|
liftIO $ copyFile (L.tail $ mediumThumb med) nThumb
|
||||||
|
liftIO $ copyFile (L.tail $ mediumPreview med) nPrev
|
||||||
|
-- remove physical files
|
||||||
|
$(logError) "removeFile"
|
||||||
|
mapM_ (liftIO . removeFile . normalise . L.tail)
|
||||||
|
[ mediumPath med
|
||||||
|
, mediumThumb med
|
||||||
|
, mediumPreview med
|
||||||
|
]
|
||||||
-- chenge filenames in database
|
-- chenge filenames in database
|
||||||
runDB $ update mId
|
runDB $ update mId
|
||||||
[ MediumPath =. '/' : nPath
|
[ MediumPath =. '/' : nPath
|
||||||
, MediumThumb =. '/' : nThumb
|
, MediumThumb =. '/' : nThumb
|
||||||
, MediumPreview =. '/' : nPrev
|
, MediumPreview =. '/' : nPrev
|
||||||
|
, MediumAlbum =. destId
|
||||||
]
|
]
|
||||||
-- create new references
|
-- create new references
|
||||||
let newMediaList = mId : albumContent dest
|
let newMediaList = mId : albumContent dest
|
||||||
|
|
|
@ -147,6 +147,9 @@ postMediumMoveR mId = do
|
||||||
moveMedium medium mId aId
|
moveMedium medium mId aId
|
||||||
setMessage "Medium successfully moved"
|
setMessage "Medium successfully moved"
|
||||||
redirect $ MediumR mId
|
redirect $ MediumR mId
|
||||||
|
Left (err, route) -> do
|
||||||
|
setMessage err
|
||||||
|
redirect route
|
||||||
|
|
||||||
mediumMoveForm :: Medium -> AForm Handler AlbumId
|
mediumMoveForm :: Medium -> AForm Handler AlbumId
|
||||||
mediumMoveForm medium = id
|
mediumMoveForm medium = id
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
/album/#AlbumId/delete AlbumDeleteR GET POST
|
/album/#AlbumId/delete AlbumDeleteR GET POST
|
||||||
/medium/#MediumId/settings MediumSettingsR GET POST
|
/medium/#MediumId/settings MediumSettingsR GET POST
|
||||||
/medium/#MediumId/delete MediumDeleteR GET POST
|
/medium/#MediumId/delete MediumDeleteR GET POST
|
||||||
|
/medium/#MediumId/move MediumMoveR GET POST
|
||||||
/comment/#CommentId/reply CommentReplyR GET POST
|
/comment/#CommentId/reply CommentReplyR GET POST
|
||||||
/comment/#CommentId/delcom CommentDeleteR GET POST
|
/comment/#CommentId/delcom CommentDeleteR GET POST
|
||||||
/reactivate ReactivateR GET POST
|
/reactivate ReactivateR GET POST
|
||||||
|
|
|
@ -4,8 +4,11 @@ $newline always
|
||||||
|
|
||||||
<form method="post" enctype=#{enctype}>
|
<form method="post" enctype=#{enctype}>
|
||||||
^{mediumSettingsWidget}
|
^{mediumSettingsWidget}
|
||||||
|
<ul>
|
||||||
<a href=@{MediumDeleteR mediumId}>Delete this image
|
<li>
|
||||||
|
<a href=@{MediumDeleteR mediumId}>Delete this image
|
||||||
|
<li>
|
||||||
|
<a href=@{MediumMoveR mediumId}>Move this image
|
||||||
|
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
body{background-image: url('/static/css/images/overlay.png'), -webkit-linear-gradient(top, rgba(0,0,0,0) 75%, rgba(0,0,0,0.65)), url('@{StaticR $ StaticRoute (drop 2 $ map T.pack $ splitDirectories $ mediumPath medium) []}');background-attachment:fixed;background-image: url('/static/css/images/overlay.png'), -moz-linear-gradient(center top , transparent 75%, rgba(0, 0, 0, 0.65)), url('@{StaticR $ StaticRoute (drop 2 $ map T.pack $ splitDirectories $ mediumPath medium) []}');}
|
body{background-image: url('/static/css/images/overlay.png'), -webkit-linear-gradient(top, rgba(0,0,0,0) 75%, rgba(0,0,0,0.65)), url('@{StaticR $ StaticRoute (drop 2 $ map T.pack $ splitDirectories $ mediumPath medium) []}');background-attachment:fixed;background-image: url('/static/css/images/overlay.png'), -moz-linear-gradient(center top , transparent 75%, rgba(0, 0, 0, 0.65)), url('@{StaticR $ StaticRoute (drop 2 $ map T.pack $ splitDirectories $ mediumPath medium) []}');}
|
||||||
|
|
Loading…
Reference in a new issue