Skip to content

Commit 5fa537f

Browse files
Persijn Kwekkeboompoi33
authored andcommitted
Manifest.json bugfix #675
Changed how we get the webapp hosted url for the manifest.json
1 parent 43145d1 commit 5fa537f

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ node {
2121
dependencies {
2222
compile "com.enonic.xp:core-api:${xpVersion}"
2323
compile "com.enonic.xp:portal-api:${xpVersion}"
24+
implementation "com.enonic.xp:web-api:${xpVersion}"
2425
include "com.enonic.xp:lib-auth:${xpVersion}"
2526
include "com.enonic.xp:lib-content:${xpVersion}"
2627
include "com.enonic.xp:lib-context:${xpVersion}"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.enonic.app.officeleague;
2+
3+
import com.enonic.xp.portal.PortalRequest;
4+
import com.enonic.xp.script.bean.BeanContext;
5+
import com.enonic.xp.script.bean.ScriptBean;
6+
import com.enonic.xp.web.vhost.VirtualHostHelper;
7+
8+
public class VhostHandler
9+
implements ScriptBean
10+
{
11+
protected PortalRequest request;
12+
13+
@Override
14+
public void initialize( final BeanContext context )
15+
{
16+
this.request = context.getBinding( PortalRequest.class ).get();
17+
}
18+
19+
public String getVirtualHost() {
20+
return VirtualHostHelper.getVirtualHost(this.request.getRawRequest())
21+
.getHost();
22+
23+
}
24+
}

src/main/resources/lib/pwa/manifest-controller.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@ var portalLib = require('/lib/xp/portal');
22
var mustache = require('/lib/mustache');
33

44
exports.get = function(req) {
5-
var startUrl = portalLib.url({ path: "/", type: "absolute" });
5+
6+
var bean = __.newBean('com.enonic.app.officeleague.VhostHandler');
7+
const vhost = bean.getVirtualHost();
8+
9+
var startUrl = vhost + "/app";
610

711
var params = {
812
startUrl,
913
iconUrl : portalLib.assetUrl({path: '/icons'})
1014
};
1115
var res = mustache.render(resolve('manifest.json'), params);
12-
16+
1317
return {
1418
body: res,
1519
contentType: 'application/json'

src/main/resources/lib/pwa/manifest.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "Office League",
33
"short_name": "Office League",
4+
"id": "office league",
45
"description": "Foosball app for leagues, teams, matches and score keeping",
56
"theme_color": "#1C2641",
67
"background_color": "#1C2641",

0 commit comments

Comments
 (0)