lambdacms-media 0.0.2 → 0.2.0
raw patch · 8 files changed
+123/−18 lines, 8 filesdep ~lambdacms-core
Dependency ranges changed: lambdacms-core
Files
- LICENSE +20/−1
- LambdaCms/Media/Foundation.hs +1/−1
- LambdaCms/Media/Handler/Media.hs +5/−5
- README.md +88/−2
- config/routes +1/−1
- lambdacms-media.cabal +6/−6
- templates/edit.hamlet +1/−1
- templates/new.hamlet +1/−1
LICENSE view
@@ -1,1 +1,20 @@-MIT+Copyright (c) 2015 Hoppinger BV, http://lambdacms.org++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be+included in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
LambdaCms/Media/Foundation.hs view
@@ -53,7 +53,7 @@ renderMediaMessage _ _ = defaultMessage defaultMediaAdminMenu :: LambdaCmsMedia master => (Route MediaAdmin -> Route master) -> [AdminMenuItem master]-defaultMediaAdminMenu tp = [ MenuItem (SomeMessage Msg.MenuMedia) (tp MediaAdminIndexR) "picture" ]+defaultMediaAdminMenu tp = [ MenuItem (SomeMessage Msg.MenuMedia) (tp MediaAdminR) "picture" ] attachedMaybeMedia :: LambdaCmsMedia master => model
LambdaCms/Media/Handler/Media.hs view
@@ -5,7 +5,7 @@ {-# LANGUAGE TemplateHaskell #-} module LambdaCms.Media.Handler.Media- ( getMediaAdminIndexR+ ( getMediaAdminR , getMediaAdminNewR , postMediaAdminNewR , getMediaAdminEditR@@ -25,7 +25,7 @@ import System.FilePath import Text.Lucius (luciusFile) -getMediaAdminIndexR :: MediaHandler Html+getMediaAdminR :: MediaHandler Html getMediaAdminNewR :: MediaHandler Html postMediaAdminNewR :: MediaHandler Html getMediaAdminEditR :: MediaId -> MediaHandler Html@@ -33,7 +33,7 @@ deleteMediaAdminEditR :: MediaId -> MediaHandler Html patchMediaAdminRenameR :: MediaId -> MediaHandler Html -getMediaAdminIndexR = lift $ do+getMediaAdminR = lift $ do can <- getCan y <- getYesod let sr = unpack $ staticRoot y@@ -57,7 +57,7 @@ (location, ctype) <- upload file (unpack name) _ <- lift . runDB . insert $ Media location ctype label description ct lift . setMessageI $ Msg.SaveSuccess label- redirect MediaAdminIndexR+ redirect MediaAdminR _ -> lift $ do can <- getCan adminLayout $ do@@ -98,7 +98,7 @@ case isDeleted of True -> do lift . setMessageI $ Msg.DeleteSuccess (mediaLabel file)- redirect MediaAdminIndexR+ redirect MediaAdminR False -> do lift . setMessageI $ Msg.DeleteFail (mediaLabel file) redirect $ MediaAdminEditR fileId
README.md view
@@ -1,3 +1,89 @@-# LambdaCms Media Extension+lambdacms-media+=============== -LambdaCms Media is an extension for LambdaCms which allows admins to manage media files.+This is an extension for [LambdaCms](http://lambdacms.org) which allows admins to manage media files.++**NOTE:** At this point the functionality provided by this extension is very basic. Pull request adding features are most welcome.+++# Installing++LambdaCms extensions come as plain Haskell packages and need to be added to the+project's `.cabal` file like any other package dependency.++The following guide expects a newly initialized LambdaCms base application.+When you have an existing base app this guide show still be easy to follow.++In the `library` section of your base application's `.cabal` file append the following+line to `build-depends`:++```+ , lambdacms-media+```++The media extension's admin section needs to be mounted in the base app's+router, therefor add the following line to your `config/routes` file:++```+/admin/media MediaAdminSubR MediaAdmin getLambdaCmsMedia+```++To `Application.hs` add `import LambdaCms.Media` and the following line:++```haskell+[...]+ let getLambdaCms = CoreAdmin+ getLambdaCmsMedia = MediaAdmin -- add this line+ mkFoundation appConnPool = App {..}+[...]+```++The procede by including the `migrateLambdaCmsMedia` function to `Application.hs`+as shown in this snippet:++```haskell+[...]+ runLoggingT+ (runSqlPool (mapM_ runMigration [migrateAll, migrateLambdaCmsCore, migrateLambdaCmsMedia]) pool)+ (messageLoggerSource theFoundation appLogger)+[...]+```+++To `Foundation.hs` also add `import LambdaCms.Media` and the following two lines:++```haskell+[...]+ , getLambdaCms :: CoreAdmin+ , getLambdaCmsMedia :: MediaAdmin -- add this line+ }+[...]+ adminMenu = (defaultCoreAdminMenu CoreAdminR)+ ++ (defaultMediaAdminMenu MediaAdminR) -- add this line+ renderLanguages _ = ["en", "nl"]+[...]+```++The last line hooks the media admin section into the admin menu.++Finally the following instance needs to be defined in `Foundation.hs`:++```haskell+instance LambdaCmsMedia App where+ mediaR = MediaAdminSubR+ staticDir y = appStaticDir $ appSettings y+ staticRoot _ = "/static"+```+++That's it! You can now `cabal install` the new dependency and run+`yesod devel` to test drive the freshly installed extension.++++# License++All code in this repository is released under the MIT license, as specified+in the [LICENSE file](https://github.com/lambdacms/lambdacms-core/blob/master/LICENSE).++
config/routes view
@@ -1,4 +1,4 @@-/ MediaAdminIndexR GET+/ MediaAdminR GET /new MediaAdminNewR GET POST /#MediaId/rename MediaAdminRenameR PATCH !/#MediaId MediaAdminEditR GET PATCH DELETE
lambdacms-media.cabal view
@@ -1,13 +1,13 @@ name: lambdacms-media-version: 0.0.2+version: 0.2.0 license: MIT license-file: LICENSE author: Mats Rietdijk, Cies Breijs maintainer: mats@AT-hoppinger.com-copyright: (c) 2014 Hoppinger-bug-reports: https://github.com/lambdacms/lambdacms-media-homepage: http://lambdacms.org/media-synopsis: Media CMS extension for Yesod apps+copyright: (c) 2014-2015 Hoppinger BV+bug-reports: https://github.com/lambdacms/lambdacms-media/issues+homepage: http://lambdacms.org+synopsis: LambdaCms "media" extension description: LambdaCms is a Content Management System (CMS) in Haskell using Yesod. This package contains the "media" extension. stability: alpha@@ -40,7 +40,7 @@ build-depends: base >= 4.3 && < 5 , yesod , yesod-form- , lambdacms-core >= 0.0.7.3 && < 0.1+ , lambdacms-core >= 0.0.7.3 && < 0.2 , persistent , text , time
templates/edit.hamlet view
@@ -1,6 +1,6 @@ <div .row> <div .col-xs-12>- $maybe r <- can (mediaR MediaAdminIndexR) "GET"+ $maybe r <- can (mediaR MediaAdminR) "GET" <a href=@{r}> <span .glyphicon .glyphicon-arrow-left> _{Msg.Back}
templates/new.hamlet view
@@ -1,6 +1,6 @@ <div .row> <div .col-xs-12>- $maybe r <- can (mediaR MediaAdminIndexR) "GET"+ $maybe r <- can (mediaR MediaAdminR) "GET" <a href=@{r}> <span .glyphicon .glyphicon-arrow-left> _{Msg.Back}