Create Component Library (#43)
* Move src under playlet-lib * Update configuration * Update script * Update script * Working version * Vs code config WIP * Package lock sync * Lint fix * Fix images * Reuse config files * Kind of a working setup * Lock node version * Rename scripts to tools * Fix build scripts, lib url system * Lint fix * rale * Fix args and web server * Load fallbacks and build script cleanups * Remove unused method * no message * no message * Remove generic message field * Lint fix * no message * Use loading indicator on main app * Add playlet lib version to settings --------- Co-authored-by: github-action linter <githubaction@githubaction.com>
This commit is contained in:
1 parent
90df81df4b
commit
9d8a3d1cea
156 files changed
+3341
-213
No files matched your search
@@ -0,0 +1,117 @@
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
namespace WebUtils
|
||||
function UrlQueryComponents(url as string) as object
|
||||
query = {}
|
||||
index = Instr(0, url, "?")
|
||||
url = Mid(url, index + 1)
|
||||
components = url.split("&")
|
||||
for each component in components
|
||||
key = component
|
||||
value = ""
|
||||
hasValue = false
|
||||
if Instr(0, component, "=")
|
||||
keyValue = component.split("=")
|
||||
key = keyValue[0]
|
||||
value = keyValue[1]
|
||||
hasValue = true
|
||||
end if
|
||||
|
||||
if query.DoesExist(key) and hasValue
|
||||
oldValue = query[key]
|
||||
if GetInterface(oldValue, "ifArray") = invalid
|
||||
oldValue = [oldValue]
|
||||
end if
|
||||
oldValue.push(value)
|
||||
value = oldValue
|
||||
end if
|
||||
|
||||
query[key] = value
|
||||
end for
|
||||
return query
|
||||
end function
|
||||
|
||||
function MimeType(uri = "" as string) as string
|
||||
map = m.MimeTypes
|
||||
if map = invalid
|
||||
map = {
|
||||
' Default mimetype mappings
|
||||
ogg: "application/ogg",
|
||||
pdf: "application/pdf",
|
||||
xsl: "application/xml",
|
||||
xml: "application/xml",
|
||||
dtd: "application/xml-dtd",
|
||||
xslt: "application/xslt+xml",
|
||||
zip: "application/zip",
|
||||
mp2: "audio/mpeg",
|
||||
mp3: "audio/mpeg",
|
||||
mpga: "audio/mpeg",
|
||||
gif: "image/gif",
|
||||
jpeg: "image/jpeg",
|
||||
jpe: "image/jpeg",
|
||||
jpg: "image/jpeg",
|
||||
png: "image/png",
|
||||
svg: "image/svg+xml",
|
||||
css: "text/css",
|
||||
html: "text/html",
|
||||
js: "text/javascript",
|
||||
txt: "text/plain",
|
||||
asc: "text/plain",
|
||||
brs: "text/plain",
|
||||
bs: "text/plain",
|
||||
map: "text/plain",
|
||||
mpeg: "video/mpeg",
|
||||
mpe: "video/mpeg",
|
||||
mpg: "video/mpeg",
|
||||
qt: "video/quicktime",
|
||||
mov: "video/quicktime",
|
||||
avi: "video/x-msvideo",
|
||||
default: "application/octet-stream"
|
||||
}
|
||||
m.MimeTypes = map
|
||||
end if
|
||||
ext = WebUtils.GetExtension(uri)
|
||||
if map.doesexist(ext)
|
||||
return map[ext]
|
||||
else
|
||||
return map.default
|
||||
end if
|
||||
end function
|
||||
|
||||
function GetExtension(fn as string) as string
|
||||
l = fn.tokenize(".")
|
||||
if l.count() > 0
|
||||
return l.GetTail()
|
||||
else
|
||||
return ""
|
||||
end if
|
||||
end function
|
||||
|
||||
function HttpTitle(code = 0 as integer) as string
|
||||
hcm = m.HttpTitles
|
||||
if hcm = invalid
|
||||
hcm = { n101: "Switching Protocols" }
|
||||
hcm.append({ n200: "OK", n206: "Partial Content" })
|
||||
hcm.append({ n301: "Moved Permanently", n304: "Not Modified" })
|
||||
hcm.append({ n400: "Bad Request", n401: "Unauthorized", n403: "Forbidden", n404: "Not Found", n413: "Request Entity Too Large" })
|
||||
hcm.append({ n500: "Internal Server Error", n501: "Not Implemented" })
|
||||
m.HttpTitles = hcm
|
||||
end if
|
||||
return validstr(hcm["n" + Stri(code).trim()])
|
||||
end function
|
||||
|
||||
function EscapeUrlForXml(url as string) as string
|
||||
urlEscapeChars = {}
|
||||
urlEscapeChars["&"] = "&"
|
||||
urlEscapeChars["'"] = "'"
|
||||
urlEscapeChars[`"`] = """
|
||||
urlEscapeChars["<"] = "<"
|
||||
urlEscapeChars[">"] = ">"
|
||||
|
||||
for each escapeChar in urlEscapeChars
|
||||
url = url.Replace(escapeChar, urlEscapeChars[escapeChar])
|
||||
end for
|
||||
return url
|
||||
end function
|
||||
|
||||
end namespace
|
||||
Reference in new issue
Block a user