summaryrefslogtreecommitdiff
path: root/lib/Properties.hs
diff options
context:
space:
mode:
authorstuebinm2021-11-14 03:09:50 +0100
committerstuebinm2021-11-14 03:09:50 +0100
commit52b73711fc21e121267318677840a54fbe174b10 (patch)
treec6e65874b376ca5d0712930796908c3e4f6490d7 /lib/Properties.hs
parent24a0763b4b0a87b5abd488ebca67f4c5ff9b966d (diff)
Functional jitsiRoomAdminTag adjustment
also yet another typeclass™, because why not?
Diffstat (limited to '')
-rw-r--r--lib/Properties.hs17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/Properties.hs b/lib/Properties.hs
index 3ad8af2..e6a3384 100644
--- a/lib/Properties.hs
+++ b/lib/Properties.hs
@@ -9,14 +9,16 @@ module Properties (checkMap, checkTileset, checkLayer) where
import Control.Monad (unless, when)
import Data.Text (Text, isPrefixOf)
import Tiled2 (HasProperties (adjustProperties, getProperties),
- Layer (..), Property (..), PropertyValue (..),
+ IsProperty (asProperty), Layer (..),
+ Property (..), PropertyValue (..),
Tiledmap (..), Tileset (..))
import Util (layerIsEmpty, prettyprint)
import Data.Maybe (fromMaybe)
+import LintConfig (LintConfig (configAssemblyTag))
import LintWriter (LintWriter, adjust, askContext, askFileDepth,
- complain, dependsOn, forbid, offersEntrypoint,
- suggest, warn)
+ complain, dependsOn, forbid, lintConfig,
+ offersEntrypoint, suggest, warn)
import Paths (RelPath (..), parsePath)
import Types (Dep (Link, Local, LocalMap, MapLink))
@@ -108,7 +110,8 @@ checkLayer = do
checkLayerProperty :: Property -> LintWriter Layer
checkLayerProperty p@(Property name _value) = case name of
"jitsiRoom" -> do
- setProperty "jitsiRoomAdminTag" "Hello, World"
+ lintConfig configAssemblyTag
+ >>= setProperty "jitsiRoomAdminTag"
uselessEmptyLayer
unwrapString p $ \_val -> do
suggestProperty $ Property "jitsiTrigger" (StrProp "onaction")
@@ -228,9 +231,11 @@ suggestProperty (Property name value) =
$ suggest $ "set property " <> prettyprint name <> " to " <> prettyprint value
-- | set a property, overwriting whatever value it had previously
-setProperty :: HasProperties ctxt => Text -> PropertyValue -> LintWriter ctxt
+setProperty :: (IsProperty prop, HasProperties ctxt)
+ => Text -> prop -> LintWriter ctxt
setProperty name value = adjust $ \ctxt ->
- adjustProperties (\props -> Just $ Property name value : filter sameName props) ctxt
+ flip adjustProperties ctxt
+ $ \ps -> Just $ Property name (asProperty value) : filter sameName ps
where sameName (Property name' _) = name /= name'
-- | does this layer have the given property?