feat(personalised-sheet-files): collated ignore
This commit is contained in:
parent
ed5fb6e218
commit
1fe63a23a0
21
config/personalised-sheet-files-collate
Normal file
21
config/personalised-sheet-files-collate
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
$# Syntax:
|
||||||
|
$# - Leere zeilen werden ignoriert
|
||||||
|
$# - Zeilen, die mit '$#' beginnen, werden ignoriert
|
||||||
|
$# - Verbleibende Zeilen werden jeweils als `Glob`-Pattern kompiliert
|
||||||
|
|
||||||
|
$# Ignoriere rekursiv alle Ordner __MACOSX und ihren Inhalt
|
||||||
|
**/__MACOSX
|
||||||
|
**/__MACOSX/*
|
||||||
|
**/__MACOSX/**/*
|
||||||
|
|
||||||
|
$# Ignoriere rekursiv alle Dateien .DS_Store (Mac OS)
|
||||||
|
**/.DS_Store
|
||||||
|
|
||||||
|
$# Ignoriere VI-Style-Backup-Files
|
||||||
|
**/*~
|
||||||
|
$# Ignoriere Emacs-Style-Backup-Files
|
||||||
|
**/.#*#
|
||||||
|
|
||||||
|
$# Ignoriere exportierte meta-informationen.yaml
|
||||||
|
**/meta-informationen_*.yaml
|
||||||
|
**/meta-information_*.yaml
|
||||||
@ -2668,6 +2668,8 @@ SubmissionDoneAlways: Always
|
|||||||
CorrUploadSubmissionDoneMode: Rating finished
|
CorrUploadSubmissionDoneMode: Rating finished
|
||||||
CorrUploadSubmissionDoneModeTip: Should uploaded corrections be marked as finished? The rating is only visible to the submittors and considered for any exam bonuses if it is finished.
|
CorrUploadSubmissionDoneModeTip: Should uploaded corrections be marked as finished? The rating is only visible to the submittors and considered for any exam bonuses if it is finished.
|
||||||
|
|
||||||
|
PersonalisedSheetFilesMetaFilename uid: meta-information_#{toPathPiece uid}.yaml
|
||||||
|
|
||||||
AdminCrontabNotGenerated: Crontab not (yet) generated
|
AdminCrontabNotGenerated: Crontab not (yet) generated
|
||||||
CronMatchAsap: ASAP
|
CronMatchAsap: ASAP
|
||||||
CronMatchNone: Never
|
CronMatchNone: Never
|
||||||
|
|||||||
@ -44,6 +44,7 @@ import Text.Unidecode (unidecode)
|
|||||||
import Data.Char (isAlphaNum)
|
import Data.Char (isAlphaNum)
|
||||||
|
|
||||||
import qualified System.FilePath as FilePath (joinPath)
|
import qualified System.FilePath as FilePath (joinPath)
|
||||||
|
import System.FilePath.Glob
|
||||||
|
|
||||||
import Control.Monad.Trans.State.Strict (StateT, runStateT)
|
import Control.Monad.Trans.State.Strict (StateT, runStateT)
|
||||||
import qualified Control.Monad.State as State
|
import qualified Control.Monad.State as State
|
||||||
@ -101,10 +102,14 @@ resolvePersonalisedSheetFiles fpL isDir cid sid = do
|
|||||||
Just (uid, sfType, fPath) -> PersonalisedSheetFileResidual sid uid sfType <$ (fpL .= fPath)
|
Just (uid, sfType, fPath) -> PersonalisedSheetFileResidual sid uid sfType <$ (fpL .= fPath)
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
isDirectory <- State.gets isDir
|
isDirectory <- State.gets isDir
|
||||||
|
fPath <- use fpL
|
||||||
if | isDirectory
|
if | isDirectory
|
||||||
-> lift $ throwE PSFUnresolvedDirectory
|
-> lift $ throwE PSFUnresolvedDirectory
|
||||||
|
| lstPtn : _ <- Map.keys $ Map.filter (`match'` fPath) personalisedSheetFilesCollatable
|
||||||
|
-> lift . throwE $ PSFUnresolvedCollatable lstPtn
|
||||||
| otherwise
|
| otherwise
|
||||||
-> lift $ throwE PSFUnresolved
|
-> lift $ throwE PSFUnresolved
|
||||||
|
where match' = matchWith $ matchDefault { matchDotsImplicitly = True }
|
||||||
|
|
||||||
|
|
||||||
sinkPersonalisedSheetFiles :: forall m.
|
sinkPersonalisedSheetFiles :: forall m.
|
||||||
|
|||||||
@ -1,31 +0,0 @@
|
|||||||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
|
||||||
|
|
||||||
module Handler.Utils.Submission.TH
|
|
||||||
( patternFile
|
|
||||||
) where
|
|
||||||
|
|
||||||
import ClassyPrelude.Yesod
|
|
||||||
import Language.Haskell.TH
|
|
||||||
import Language.Haskell.TH.Syntax (qAddDependentFile, Lift(..))
|
|
||||||
|
|
||||||
import System.FilePath.Glob
|
|
||||||
|
|
||||||
import qualified Data.Text as Text
|
|
||||||
import qualified Data.Text.IO as Text
|
|
||||||
|
|
||||||
deriving instance Lift CompOptions
|
|
||||||
|
|
||||||
-- $(patternFile compDefault file) :: [System.FilePath.Glob.Pattern]
|
|
||||||
patternFile :: CompOptions -> FilePath -> ExpQ
|
|
||||||
patternFile opts file = do
|
|
||||||
qAddDependentFile file
|
|
||||||
patternStrings <- runIO $ filter (not . isComment) . Text.lines <$> Text.readFile file
|
|
||||||
listE $ map (\(Text.unpack -> pat) -> [|compileWith opts pat|]) patternStrings
|
|
||||||
|
|
||||||
isComment :: Text -> Bool
|
|
||||||
isComment line = or
|
|
||||||
[ commentSymbol `Text.isPrefixOf` Text.stripStart line
|
|
||||||
, Text.null $ Text.strip line
|
|
||||||
]
|
|
||||||
where
|
|
||||||
commentSymbol = "$#"
|
|
||||||
@ -61,7 +61,7 @@ import qualified System.FilePath as FilePath
|
|||||||
import Jose.Jwt (JwtEncoding(..))
|
import Jose.Jwt (JwtEncoding(..))
|
||||||
|
|
||||||
import System.FilePath.Glob
|
import System.FilePath.Glob
|
||||||
import Handler.Utils.Submission.TH
|
import System.FilePath.Glob.TH
|
||||||
|
|
||||||
import qualified Web.ServerSession.Core as ServerSession
|
import qualified Web.ServerSession.Core as ServerSession
|
||||||
|
|
||||||
@ -543,7 +543,10 @@ widgetFileSettings = def
|
|||||||
|
|
||||||
|
|
||||||
submissionBlacklist :: [Pattern]
|
submissionBlacklist :: [Pattern]
|
||||||
submissionBlacklist = $(patternFile compDefault "config/submission-blacklist")
|
submissionBlacklist = $$(patternFile compDefault "config/submission-blacklist")
|
||||||
|
|
||||||
|
personalisedSheetFilesCollatable :: Map Text Pattern
|
||||||
|
personalisedSheetFilesCollatable = $$(patternFile' compDefault "config/personalised-sheet-files-collate")
|
||||||
|
|
||||||
-- The rest of this file contains settings which rarely need changing by a
|
-- The rest of this file contains settings which rarely need changing by a
|
||||||
-- user.
|
-- user.
|
||||||
|
|||||||
35
src/System/FilePath/Glob/TH.hs
Normal file
35
src/System/FilePath/Glob/TH.hs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||||
|
|
||||||
|
module System.FilePath.Glob.TH
|
||||||
|
( patternFile, patternFile'
|
||||||
|
) where
|
||||||
|
|
||||||
|
import ClassyPrelude.Yesod
|
||||||
|
import Language.Haskell.TH
|
||||||
|
import Language.Haskell.TH.Syntax (qAddDependentFile, Lift(..), unsafeTExpCoerce)
|
||||||
|
|
||||||
|
import System.FilePath.Glob
|
||||||
|
|
||||||
|
import qualified Data.Text as Text
|
||||||
|
import qualified Data.Text.IO as Text
|
||||||
|
|
||||||
|
import qualified Data.Map.Strict as Map
|
||||||
|
|
||||||
|
deriving instance Lift CompOptions
|
||||||
|
|
||||||
|
patternFile' :: CompOptions -> FilePath -> TExpQ (Map Text Pattern)
|
||||||
|
patternFile' opts file = do
|
||||||
|
qAddDependentFile file
|
||||||
|
patternStrings <- runIO $ filter (not . isComment) . Text.lines <$> Text.readFile file
|
||||||
|
unsafeTExpCoerce . appE [e|Map.fromList|] . listE $ map (\pat'@(Text.unpack -> pat) -> [e|(pat', compileWith opts pat)|]) patternStrings
|
||||||
|
|
||||||
|
patternFile :: CompOptions -> FilePath -> TExpQ [Pattern]
|
||||||
|
patternFile opts file = [||Map.elems $$(patternFile' opts file)||]
|
||||||
|
|
||||||
|
isComment :: Text -> Bool
|
||||||
|
isComment line = or
|
||||||
|
[ commentSymbol `Text.isPrefixOf` Text.stripStart line
|
||||||
|
, Text.null $ Text.strip line
|
||||||
|
]
|
||||||
|
where
|
||||||
|
commentSymbol = "$#"
|
||||||
Reference in New Issue
Block a user