Make generated CSS files group-readable so that nginx can actually serve them without me manually chmodding
This commit is contained in:
parent
c517baac1c
commit
035cc1de3b
2 changed files with 11 additions and 1 deletions
|
@ -25,7 +25,9 @@ import Entry.Kind ( EntryKind, allEntryKinds, pluralise )
|
|||
|
||||
import Data.Aeson ( encode, object )
|
||||
import qualified Text.Blaze.Internal as B
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.Lazy.Encoding as E
|
||||
import qualified System.Posix.Files as F
|
||||
|
||||
-- | The foundation datatype for your application. This can be a good place to
|
||||
-- keep settings and values requiring initialization before your application
|
||||
|
@ -130,7 +132,7 @@ instance Yesod App where
|
|||
addStaticContent ext mime content = do
|
||||
master <- getYesod
|
||||
let staticDir = appStaticDir $ appSettings master
|
||||
addStaticContentExternal
|
||||
external <- addStaticContentExternal
|
||||
minifym
|
||||
genFileName
|
||||
staticDir
|
||||
|
@ -138,6 +140,13 @@ instance Yesod App where
|
|||
ext
|
||||
mime
|
||||
content
|
||||
case external of
|
||||
(Just (Right (StaticR (StaticRoute filePath _), _))) -> liftIO $ do
|
||||
let staticPath = ((staticDir ++ "/") ++) . T.unpack . T.intercalate "/" $ filePath
|
||||
mode <- F.fileMode <$> F.getFileStatus staticPath
|
||||
F.setFileMode staticPath $ mode `F.unionFileModes` F.groupReadMode
|
||||
_ -> return ()
|
||||
return external
|
||||
where
|
||||
-- Generate a unique filename based on the content itself
|
||||
genFileName lbs = "autogen-" ++ base64md5 lbs
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue