Commit 0224b64f authored by Jérome Perrin's avatar Jérome Perrin

software/theia: Make the application installable

Add a webmanifest and a service worker for to support "Add to home screen"
parent 8633dc9c
Pipeline #25915 passed with stage
in 0 seconds
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
[preloadTemplate.html] [preloadTemplate.html]
_update_hash_filename_ = preloadTemplate.html _update_hash_filename_ = preloadTemplate.html
md5sum = 8157c22134200bd862a07c6521ebf799 md5sum = 6343592161a349bb40e0de16ce67aa51
[yarn.lock] [yarn.lock]
_update_hash_filename_ = yarn.lock _update_hash_filename_ = yarn.lock
......
<script> <script>
let link = document.createElement('link'); let link = document.createElement('link');
link.rel = "stylesheet"; link.rel = "stylesheet";
link.href = "/css/slapos.css"; link.href = "/css/slapos.css";
document.head.appendChild(link); document.head.appendChild(link);
link = document.createElement('link');
link.rel = "manifest";
link.href = "/theia.webmanifest";
document.head.appendChild(link);
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/theia-serviceworker.js').then(function (reg) {
console.log('Successfully registered service worker', reg);
}).catch(function (err) {
console.warn('Error whilst registering service worker', err);
});
}
</script> </script>
\ No newline at end of file
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
[instance-theia] [instance-theia]
_update_hash_filename_ = instance-theia.cfg.jinja.in _update_hash_filename_ = instance-theia.cfg.jinja.in
md5sum = 937f8ebdfa8112aafe11235a23fb85a9 md5sum = ca0f353d00131851a992cd3519bec5b0
[instance] [instance]
_update_hash_filename_ = instance.cfg.in _update_hash_filename_ = instance.cfg.in
......
...@@ -324,7 +324,9 @@ inline = ...@@ -324,7 +324,9 @@ inline =
bind $${:ip}:$${:port} ssl crt $${frontend-instance-certificate:cert-file} alpn h2,http/1.1 bind $${:ip}:$${:port} ssl crt $${frontend-instance-certificate:cert-file} alpn h2,http/1.1
# writing twice the same ACL is doing OR # writing twice the same ACL is doing OR
acl is_public path_beg /public/ acl is_public path_beg /public/
acl is_public path /$${favicon.ico:filename} acl is_public path /$${frontend-instance-favicon.ico:filename}
acl is_public path /$${frontend-instance-theia.webmanifest:filename}
acl is_public path /$${frontend-instance-theia-serviceworker.js:filename}
acl auth_ok http_auth(basic-auth-list) acl auth_ok http_auth(basic-auth-list)
# No authentication for public folder # No authentication for public folder
http-request auth unless auth_ok || is_public http-request auth unless auth_ok || is_public
...@@ -386,7 +388,42 @@ folder-name = css ...@@ -386,7 +388,42 @@ folder-name = css
context = context =
key logo_image frontend-instance-logo:filename key logo_image frontend-instance-logo:filename
[favicon.ico] [frontend-instance-theia.webmanifest]
recipe = slapos.recipe.build
short-name = {{ root_title }}
name = Theia SlapOS $${:short-name}
background-color = #3c3c3c
install =
import json
with open(options['location'], 'w') as f:
json.dump({
"name": options["name"],
"short_name": options["short-name"],
"icons": [
{
"src": "/" + self.buildout["frontend-instance-favicon.ico"]["filename"],
"sizes": "256x256",
"type": "image/png"
},
],
"start_url": "/",
"display": "fullscreen",
"background_color": options["background-color"]
}, f)
location = $${directory:frontend-static}/$${:filename}
filename = theia.webmanifest
[frontend-instance-theia-serviceworker.js]
recipe = slapos.recipe.template
inline =
/* minimal service worker for A2HS */
self.addEventListener("fetch", function(event) { });
output = $${directory:frontend-static}/$${:filename}
filename = theia-serviceworker.js
[frontend-instance-favicon.ico]
# generate a pseudo random favicon, different for each instance name. # generate a pseudo random favicon, different for each instance name.
recipe = slapos.recipe.build recipe = slapos.recipe.build
seed = {{ root_title }} seed = {{ root_title }}
...@@ -408,7 +445,7 @@ install = ...@@ -408,7 +445,7 @@ install =
self.buildout['buildout']['offline'] = buildout_offline self.buildout['buildout']['offline'] = buildout_offline
location = $${directory:frontend-static}/$${:filename} location = $${directory:frontend-static}/$${:filename}
filename = $${:_buildout_section_name_} filename = favicon.ico
# Local Python Server # Local Python Server
# ------------------- # -------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment