diff options
author | stuebinm | 2021-12-21 21:20:43 +0100 |
---|---|---|
committer | stuebinm | 2021-12-21 21:20:43 +0100 |
commit | 714ddd55d1cc6ef55941ecba1b0fdbce2f3193db (patch) | |
tree | d6a0b2c8d3ac3a36a8580e49c4774e743bd8c9b0 | |
parent | 92d73fdfd296a38cb385108ce63291bdc718fc40 (diff) |
correct bbb link substitution
(unfortunately this one's hardcoded, the config options just aren't
general enough)
-rw-r--r-- | config.json | 6 | ||||
-rw-r--r-- | lib/Properties.hs | 21 |
2 files changed, 11 insertions, 16 deletions
diff --git a/config.json b/config.json index 28d347e..f7fc59d 100644 --- a/config.json +++ b/config.json @@ -16,12 +16,6 @@ "scope" : ["map"], "substs" : { } - }, - "bbb" : { - "scope" : ["bbb"], - "allowed" : [], - "blocked" : [], - "prefix" : "https://bbb.rc3.world/" } } } diff --git a/lib/Properties.hs b/lib/Properties.hs index 37b6bc4..dd680ea 100644 --- a/lib/Properties.hs +++ b/lib/Properties.hs @@ -40,7 +40,7 @@ import LintWriter (LintWriter, adjust, askContext, askFileDepth, import Paths (PathResult (..), RelPath (..), getExtension, isOldStyle, parsePath) import Types (Dep (Link, Local, LocalMap, MapLink)) -import Uris (SubstError (..), applySubst) +import Uris (SubstError (..), applySubst, parseUri) -- | Checks an entire map for "general" lints. @@ -289,15 +289,16 @@ checkTileLayerProperty p@(Property name _value) = case name of isIntInRange 0 100 p "bbbRoom" -> do removeProperty "bbbRoom" - unwrapURI (Proxy @"bbb") p - (\link -> do - dependsOn (Link link) - setProperty "openWebsite" link - setProperty "silent" (BoolProp True) - setProperty "openWebsitePolicy" - ("fullscreen;camera;microphone;display-capture" :: Text) - ) - (const $ complain "property \"bbbRoom\" cannot be used with local links.") + unwrapString p $ \str -> case parseUri str of + Just ("bbb",assembly_slug, room_slug) + | "/" `isPrefixOf` room_slug && T.length room_slug >= 2 -> do + let link = "https://rc3.world/assembly/"<>assembly_slug<>"/bbb"<>room_slug + dependsOn (Link link) + setProperty "openWebsite" link + setProperty "silent" (BoolProp True) + setProperty "openWebsitePolicy" + ("fullscreen;camera;microphone;display-capture" :: Text) + _ -> complain "the \"bbbRoom\" property must take a link of the form bbb://assembly_slug/room_slug." "bbbTrigger" -> do removeProperty "bbbTrigger" requireProperty "bbbRoom" |