2024-04-15 01:30:58 +02:00
|
|
|
#!/bin/sh
|
2024-09-14 02:23:39 +02:00
|
|
|
SourceApps="$(ls ./source/)"
|
2024-08-05 02:11:30 +02:00
|
|
|
HubSdkApps="${SourceApps} MatrixStickerHelper"
|
2024-07-30 23:29:01 +02:00
|
|
|
HtmlHeadInject='<script src="../../shared/OctoHub-Global.js"></script>'
|
2024-04-21 00:58:00 +02:00
|
|
|
|
|
|
|
quoteVar(){ echo '"'"$1"'"' ;}
|
|
|
|
|
|
|
|
getMetaAttr(){
|
|
|
|
file="$1"
|
|
|
|
name="$2"
|
2024-07-30 23:29:01 +02:00
|
|
|
key="$([ -n "$3" ] && echo "$3" || echo property)"
|
2024-04-21 00:58:00 +02:00
|
|
|
grep '<meta '"$key"'="'"$name"'"' "$file" | grep '>' | cut -d '"' -f4
|
|
|
|
}
|
2024-04-19 00:34:22 +02:00
|
|
|
|
|
|
|
rm -vrf ./public || true
|
|
|
|
cp -vr ./static ./public
|
|
|
|
cp -vr ./shared ./public/shared
|
|
|
|
|
2024-04-19 00:37:07 +02:00
|
|
|
for App in ${SourceApps}
|
2024-04-15 01:30:58 +02:00
|
|
|
do
|
2024-04-21 00:58:00 +02:00
|
|
|
mkdir -p "./public/${App}"
|
|
|
|
cd "./source/${App}"
|
2024-08-05 02:11:30 +02:00
|
|
|
if [ -f ./Requirements.sh ]
|
|
|
|
then sh ./Requirements.sh
|
|
|
|
else
|
|
|
|
[ -f ./package.json ] && (npm update; npm install)
|
|
|
|
fi
|
|
|
|
copyfiles="$(sh ./Build.sh)"
|
|
|
|
cp -vr $copyfiles "../../public/${App}/"
|
|
|
|
for file in $copyfiles
|
|
|
|
do
|
|
|
|
path="../../public/${App}/${file}"
|
|
|
|
if [ ! -e "${path}" ]
|
|
|
|
then mkdir -p "${path}" && rm -rf "${path}" && cp "${file}" "${path}"
|
|
|
|
fi
|
|
|
|
done
|
2024-04-15 01:30:58 +02:00
|
|
|
cd ../..
|
|
|
|
done
|
2024-04-19 00:34:22 +02:00
|
|
|
|
2024-04-15 01:30:58 +02:00
|
|
|
cd ./public
|
|
|
|
node ../WriteRedirectPages.js
|
2024-04-19 00:34:22 +02:00
|
|
|
|
2024-04-19 00:37:07 +02:00
|
|
|
for App in ${HubSdkApps}
|
2024-04-19 00:34:22 +02:00
|
|
|
do
|
2024-04-21 00:58:00 +02:00
|
|
|
file="./${App}/index.html"
|
2024-07-30 23:29:01 +02:00
|
|
|
name="$( getMetaAttr "${file}" og:title)"
|
|
|
|
description="$(getMetaAttr "${file}" og:description)"
|
2024-08-05 02:11:30 +02:00
|
|
|
url="$( getMetaAttr "${file}" OctoSpaccHubSdk:Url)"
|
2024-04-21 00:58:00 +02:00
|
|
|
cat << [OctoSpaccHubSdk-WebManifest-EOF] > "./${App}/WebManifest.json"
|
|
|
|
{
|
2024-08-05 02:11:30 +02:00
|
|
|
$(getMetaAttr "${file}" OctoSpaccHubSdk:WebManifestExtra | sed s/\'/\"/g)
|
2024-04-21 00:58:00 +02:00
|
|
|
$([ -n "${description}" ] && echo "$(quoteVar description): $(quoteVar "${description}"),")
|
|
|
|
"start_url": "${url}",
|
|
|
|
"scope": "${url}",
|
|
|
|
"name": "${name}"
|
|
|
|
}
|
|
|
|
[OctoSpaccHubSdk-WebManifest-EOF]
|
2024-07-30 23:29:01 +02:00
|
|
|
htmltitle='<title>'"${name}"'</title>'
|
|
|
|
htmlcanonical='<link rel="canonical" href="'"${url}"'"/>'
|
|
|
|
sed -i 's|</head>|<link rel="manifest" href="./WebManifest.json"/>'"${htmltitle}${htmlcanonical}${htmlmanifest}${HtmlHeadInject}"'</head>|' "${file}"
|
2024-04-19 00:34:22 +02:00
|
|
|
done
|