Skip to content

Commit

Permalink
Move FramesBrowser to built apps, update, add dependencies; Update bu…
Browse files Browse the repository at this point in the history
…ild process; Add TiVuocto icon
  • Loading branch information
octospacc committed Sep 14, 2024
1 parent 6372cfe commit 3e5a65f
Show file tree
Hide file tree
Showing 17 changed files with 331 additions and 69 deletions.
33 changes: 23 additions & 10 deletions Build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ getMetaAttr(){
grep '<meta '"$key"'="'"$name"'"' "$file" | grep '>' | cut -d '"' -f4
}

################################################################################

npm update
npm install
cd ./node_modules/SpaccDotWeb
npm install
npm run build:lib
cd ../..

rm -vrf ./public || true
cp -vr ./static ./public
cp -vr ./shared ./public/shared
Expand All @@ -21,9 +30,9 @@ do
mkdir -p "./public/${App}"
cd "./source/${App}"
if [ -f ./Requirements.sh ]
then sh ./Requirements.sh
else
[ -f ./package.json ] && (npm update; npm install)
then sh ./Requirements.sh
elif [ -f ./package.json ]
then (npm update; npm install)
fi
copyfiles="$(sh ./Build.sh)"
cp -vr $copyfiles "../../public/${App}/"
Expand All @@ -42,13 +51,17 @@ node ../WriteRedirectPages.js

for App in ${HubSdkApps}
do
file="./${App}/index.html"
name="$( getMetaAttr "${file}" og:title)"
description="$(getMetaAttr "${file}" og:description)"
url="$( getMetaAttr "${file}" OctoSpaccHubSdk:Url)"
cat << [OctoSpaccHubSdk-WebManifest-EOF] > "./${App}/WebManifest.json"
htmlfile="./${App}/index.html"
jsonfile="./${App}/WebManifest.json"
if [ -f "${jsonfile}" ]
then continue
fi
name="$( getMetaAttr "${htmlfile}" og:title)"
description="$(getMetaAttr "${htmlfile}" og:description)"
url="$( getMetaAttr "${htmlfile}" OctoSpaccHubSdk:Url)"
cat << [OctoSpaccHubSdk-WebManifest-EOF] > "${jsonfile}"
{
$(getMetaAttr "${file}" OctoSpaccHubSdk:WebManifestExtra | sed s/\'/\"/g)
$(getMetaAttr "${htmlfile}" OctoSpaccHubSdk:WebManifestExtra | sed s/\'/\"/g)
$([ -n "${description}" ] && echo "$(quoteVar description): $(quoteVar "${description}"),")
"start_url": "${url}",
"scope": "${url}",
Expand All @@ -57,5 +70,5 @@ do
[OctoSpaccHubSdk-WebManifest-EOF]
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}"
sed -i 's|</head>|<link rel="manifest" href="./WebManifest.json"/>'"${htmltitle}${htmlcanonical}${htmlmanifest}${HtmlHeadInject}"'</head>|' "${htmlfile}"
done
1 change: 1 addition & 0 deletions WriteRedirectPages.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env node
const fs = require('fs');
for (const page of [
{ path: "a/fb", target: "'../../FramesBrowser/'+location.hash" }, // Apps/FramesBrowser
Expand Down
39 changes: 38 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"devDependencies": {
"@babel/cli": "^7.23.9",
"@babel/core": "^7.23.9",
"@babel/preset-env": "^7.23.9"
"@babel/preset-env": "^7.23.9",
"SpaccDotWeb": "gitlab:SpaccInc/SpaccDotWeb"
}
}
1 change: 1 addition & 0 deletions source/FramesBrowser/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/html-data-url-loader-?.html
7 changes: 7 additions & 0 deletions source/FramesBrowser/Build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
for i in 0 1
do cp ./html-data-url-loader.html "./html-data-url-loader-${i}.html"
done
#echo "const fs=require('fs'); fs.writeFileSync('html2canvas.min.wrappedLib.js', 'window.FramesBrowser.Lib.html2canvas=' + JSON.stringify(fs.readFileSync('node_modules/html2canvas/dist/html2canvas.min.js', 'utf8')) + ';');" | node
echo index.html utils.js WebManifest.json icon.png html-data-url-loader-?.html \
node_modules/html2canvas/dist/html2canvas.min.js
File renamed without changes.
34 changes: 34 additions & 0 deletions source/FramesBrowser/html-data-url-loader.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html>
<head>
<script src="./utils.js"></script>
</head>
<body>
<script>(function(){

//window.addEventListener('load', (function(){

var [mime, body] = extractDataUrl(location.hash.slice(1)/*.split('#').slice(2).join('#')*/);
var dom = (new DOMParser).parseFromString(body, mime);
document.documentElement.innerHTML = dom.documentElement.innerHTML;
document.head.innerHTML = dom.head.innerHTML;
document.body.innerHTML = dom.body.innerHTML;

// hydrate scripts; TODO handle all attributes to copy
Array.from(document.querySelectorAll('script')).forEach(function(oldScriptEl){
newScriptEl = Object.assign(document.createElement('script'), {
id: oldScriptEl.id,
className: oldScriptEl.className,
innerHTML: oldScriptEl.innerHTML,
});
if (oldScriptEl.src) {
newScriptEl.src = oldScriptEl.src;
}
oldScriptEl.replaceWith(newScriptEl);
});

//}));

})();</script>
</body>
</html>
File renamed without changes
Loading

0 comments on commit 3e5a65f

Please sign in to comment.