Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
walint
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This project is archived. Its data is
read-only
.
Show more breadcrumbs
hub
walint
Commits
727f2cbc
Unverified
Commit
727f2cbc
authored
Sep 20, 2021
by
stuebinm
Browse files
Options
Downloads
Patches
Plain Diff
simple parsing of local dependency paths
parent
d3548568
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
lib/LintWriter.hs
+1
-0
1 addition, 0 deletions
lib/LintWriter.hs
lib/Properties.hs
+16
-11
16 additions, 11 deletions
lib/Properties.hs
lib/Types.hs
+7
-9
7 additions, 9 deletions
lib/Types.hs
tiled-hs.cabal
+3
-1
3 additions, 1 deletion
tiled-hs.cabal
with
27 additions
and
21 deletions
lib/LintWriter.hs
+
1
−
0
View file @
727f2cbc
...
...
@@ -64,6 +64,7 @@ lint level = tell . (: []) . hint level
dependsOn
::
Dep
->
LintWriter
()
dependsOn
dep
=
tell
.
(
:
[]
)
$
Depends
dep
warn
=
lint
Warning
info
=
lint
Info
forbid
=
lint
Forbidden
...
...
This diff is collapsed.
Click to expand it.
lib/Properties.hs
+
16
−
11
View file @
727f2cbc
...
...
@@ -14,10 +14,10 @@ import Util (layerIsEmpty, prettyprint)
import
LintWriter
(
LintWriter
,
complain
,
dependsOn
,
forbid
,
info
,
suggest
,
warn
)
import
Paths
import
Types
(
Dep
(
Link
,
Local
,
LocalMap
,
MapLink
))
-- | Checks an entire map for "general" lints.
--
-- Note that it does /not/ call checkMapProperty; this is handled
...
...
@@ -70,7 +70,7 @@ checkMapProperty map (Property name value) = case name of
checkTileset
::
Tileset
->
LintWriter
()
checkTileset
tileset
=
do
-- TODO: can tilesets be non-local dependencies?
dependsOn
$
Local
(
tilesetImage
tileset
)
unwrapPath
(
tilesetImage
tileset
)
(
dependsOn
.
Local
)
-- reject tilesets unsuitable for workadventure
unless
(
tilesetTilewidth
tileset
==
32
&&
tilesetTileheight
tileset
==
32
)
...
...
@@ -104,9 +104,9 @@ checkLayerProperty layer p@(Property name value) = case name of
"jitsiRoomAdminTag"
->
isForbidden
"playAudio"
->
do
uselessEmptyLayer
unwrapLink
p
$
\
link
->
dependsOn
$
if
"https://"
`
isPrefixOf
`
link
then
Link
link
else
Local
link
unwrapLink
p
$
\
link
->
if
"https://"
`
isPrefixOf
`
link
then
dependsOn
$
Link
link
else
unwrapPath
link
(
dependsOn
.
Local
)
"audioLoop"
->
do
isBool
p
requireProp
"playAudio"
...
...
@@ -116,9 +116,9 @@ checkLayerProperty layer p@(Property name value) = case name of
"openWebsite"
->
do
uselessEmptyLayer
suggestProp
$
Property
"openWebsiteTrigger"
(
StrProp
"onaction"
)
unwrapLink
p
$
\
link
->
dependsOn
$
if
"https://"
`
isPrefixOf
`
link
then
Link
link
else
Local
link
unwrapLink
p
$
\
link
->
if
"https://"
`
isPrefixOf
`
link
then
dependsOn
$
Link
link
else
unwrapPath
link
(
dependsOn
.
Local
)
"openWebsiteTrigger"
->
do
isString
p
unless
(
hasProperty
"openWebsiteTriggerMessage"
)
...
...
@@ -137,9 +137,9 @@ checkLayerProperty layer p@(Property name value) = case name of
"allowApi"
->
isForbidden
"exitUrl"
->
do
forbidEmptyLayer
unwrapLink
p
$
\
link
->
dependsOn
$
if
"https://"
`
isPrefixOf
`
link
then
MapLink
link
else
LocalMap
link
unwrapLink
p
$
\
link
->
if
"https://"
`
isPrefixOf
`
link
then
dependsOn
$
MapLink
link
else
unwrapPath
link
(
dependsOn
.
LocalMap
)
"startLayer"
->
do
forbidEmptyLayer
unwrapBool
p
$
\
case
...
...
@@ -206,6 +206,11 @@ unwrapBool (Property name value) f = case value of
BoolProp
b
->
f
b
_
->
complain
$
"type mismatch in property "
<>
name
<>
"; should be of type bool"
unwrapPath
::
Text
->
(
RelPath
->
LintWriter
()
)
->
LintWriter
()
unwrapPath
str
f
=
case
parsePath
str
of
Just
path
->
f
path
Nothing
->
complain
$
"path
\"
"
<>
str
<>
"
\"
is invalid"
-- | just asserts that this is a string
isString
::
Property
->
LintWriter
()
isString
=
flip
unwrapString
(
const
$
pure
()
)
...
...
This diff is collapsed.
Click to expand it.
lib/Types.hs
+
7
−
9
View file @
727f2cbc
...
...
@@ -15,11 +15,9 @@ import Data.Text (Text)
import
GHC.Generics
(
Generic
)
import
qualified
Data.Aeson
as
A
import
Tiled2
(
Property
(
Property
),
PropertyValue
(
BoolProp
,
StrProp
))
import
Paths
(
RelPath
)
import
Util
(
PrettyPrint
(
..
),
showText
)
-- | Levels of errors and warnings, collectively called
-- "Hints" until I can think of some better name
data
Level
=
Warning
|
Suggestion
|
Info
|
Forbidden
|
Error
|
Fatal
...
...
@@ -30,7 +28,7 @@ data Level = Warning | Suggestion | Info | Forbidden | Error | Fatal
data
Lint
=
Depends
Dep
|
Lint
Hint
-- | TODO: add a reasonable representation of possible urls
data
Dep
=
Local
Text
|
Link
Text
|
MapLink
Text
|
LocalMap
Text
data
Dep
=
Local
RelPath
|
Link
Text
|
MapLink
Text
|
LocalMap
RelPath
deriving
(
Generic
)
data
Hint
=
Hint
...
...
@@ -38,7 +36,7 @@ data Hint = Hint
,
hintMsg
::
Text
}
deriving
(
Generic
,
ToJSON
)
-- | shorter constructor (called
l
int because (a) older name and
-- | shorter constructor (called
h
int because (a) older name and
-- (b) lint also exists and is monadic)
hint
::
Level
->
Text
->
Lint
hint
level
msg
=
Lint
Hint
{
hintLevel
=
level
,
hintMsg
=
msg
}
...
...
@@ -62,17 +60,17 @@ instance ToJSON Lint where
instance
ToJSON
Dep
where
toJSON
=
\
case
Local
text
->
json
"local"
text
Local
text
->
json
"local"
$
prettyprint
text
Link
text
->
json
"link"
text
MapLink
text
->
json
"mapservice"
text
LocalMap
text
->
json
"map"
text
LocalMap
text
->
json
"map"
$
prettyprint
text
where
json
::
A
.
Value
->
Text
->
A
.
Value
json
kind
text
=
A
.
object
[
"kind"
.=
kind
,
"dep"
.=
text
]
instance
PrettyPrint
Dep
where
prettyprint
=
\
case
Local
dep
->
"[local dep: "
<>
dep
<>
"]"
Local
dep
->
"[local dep: "
<>
prettyprint
dep
<>
"]"
Link
dep
->
"[link dep: "
<>
dep
<>
"]"
MapLink
dep
->
"[map service dep: "
<>
dep
<>
"]"
LocalMap
dep
->
"[local map dep: "
<>
dep
<>
"]"
LocalMap
dep
->
"[local map dep: "
<>
prettyprint
dep
<>
"]"
This diff is collapsed.
Click to expand it.
tiled-hs.cabal
+
3
−
1
View file @
727f2cbc
...
...
@@ -32,6 +32,7 @@ library
Tiled2
Util
Types
Paths
build-depends: base ^>=4.14.1.0,
aeson,
bytestring,
...
...
@@ -40,7 +41,8 @@ library
vector,
transformers,
mtl,
either
either,
regex-tdfa ^>= 1.3.1.1
-- TODO: move more stuff into lib, these dependencies are silly
executable tiled-hs
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment