module Hope.Module.Halbum2.Config (imgDir, imgImportDir, thumbsPerPage, imageImportEnabled, getThumbSize, getViewSize, settings) where import Hope.Module import Hope.Setting.Types import Hope.Module.Halbum2.Types import Control.Monad (liftM2) import System.Directory (doesDirectoryExist) name :: ModuleName name = "halbum2" settings :: [SettingDesc] settings = [settingDesc imgDir, settingDesc imgImportDir, settingDesc thumbsPerPage, settingDesc thumbWidth, settingDesc thumbHeight, settingDesc viewWidth, settingDesc viewHeight] -- | This is the directory where image files are -- are stored on the server. -- -- This directory should be somewhere outside your -- public web directory, so that the images can't -- be accessed by URL guessing. If don't care about -- restricting access to your images, this is -- not an issue. -- -- The directory must be readble and writable by the -- user that Hope runs as. imgDir :: Setting FilePath imgDir = setting name "imgDir" "../images" "Image directory" -- | If not Nothing, this is the directory from -- which you can import image files into halbum2. -- -- This directory should be somewhere outside your -- public web directory, so that it can't -- be accessed by URL guessing. If don't care about -- restricting access to your images, this is -- not an issue. -- -- The directory must be readble by the -- user that Hope runs as. imgImportDir :: Setting FilePath imgImportDir = setting name "imgImportDir" "../upload" "Image upload directory" imageImportEnabled :: Hope Bool imageImportEnabled = getSetting imgImportDir >>= liftIO . doesDirectoryExist -- | Default number of thumbnails per page. thumbsPerPage :: Setting Int thumbsPerPage = setting name "thumbsPerPage" 9 "Thumbs per page" getThumbSize :: Hope Size getThumbSize = liftM2 (,) (getSetting thumbWidth) (getSetting thumbHeight) getViewSize :: Hope Size getViewSize = liftM2 (,) (getSetting viewWidth) (getSetting viewHeight) thumbWidth :: Setting Int thumbWidth = setting name "thumbWidth" 200 "Max thumbnail width" thumbHeight :: Setting Int thumbHeight = setting name "thumbHeight" 150 "Max thumbnail height" viewWidth :: Setting Int viewWidth = setting name "viewWidth" 640 "Max image view width" viewHeight :: Setting Int viewHeight = setting name "viewHeight" 480 "Max image view height"