summaryrefslogtreecommitdiffstats
path: root/sandstorm.js
diff options
context:
space:
mode:
authorMaxime Quandalle <maxime@quandalle.com>2015-11-25 21:53:58 -0800
committerMaxime Quandalle <maxime@quandalle.com>2015-11-27 16:36:38 -0800
commit827663f2550ba691067535b317dd9f0b0bec12ba (patch)
treec0ccbc02f16d0542c1f3d80cc52d335db4bf12f3 /sandstorm.js
parent875cf0ad563b935fd4d9bf18bebe8674e59df2e5 (diff)
downloadwekan-827663f2550ba691067535b317dd9f0b0bec12ba.tar.gz
wekan-827663f2550ba691067535b317dd9f0b0bec12ba.tar.bz2
wekan-827663f2550ba691067535b317dd9f0b0bec12ba.zip
Sync Sandstorm URL and page title with the inner Wekan grain
The page title synchronization required implementing reactivity in the kadira:dochead package, see https://github.com/kadirahq/meteor-dochead/pull/25 Closes #403.
Diffstat (limited to 'sandstorm.js')
-rw-r--r--sandstorm.js20
1 files changed, 18 insertions, 2 deletions
diff --git a/sandstorm.js b/sandstorm.js
index 997aed46..a711a960 100644
--- a/sandstorm.js
+++ b/sandstorm.js
@@ -54,10 +54,10 @@ if (isSandstorm && Meteor.isServer) {
// XXX If this routing scheme changes, this will break. We should generate
// the location URL using the router, but at the time of writing, the
// it is only accessible on the client.
- const path = `/boards/${sandstormBoard._id}/${sandstormBoard.slug}`;
+ const boardPath = `/b/${sandstormBoard._id}/${sandstormBoard.slug}`;
res.writeHead(301, {
- Location: base + path,
+ Location: base + boardPath,
});
res.end();
@@ -126,6 +126,22 @@ if (isSandstorm && Meteor.isServer) {
}
if (isSandstorm && Meteor.isClient) {
+ // Since the Sandstorm grain is displayed in an iframe of the Sandstorm shell,
+ // we need to explicitly expose meta data like the page title or the URL path
+ // so that they could appear in the browser window.
+ // See https://docs.sandstorm.io/en/latest/developing/path/
+ function updateSandstormMetaData(msg) {
+ return window.parent.postMessage(msg, '*');
+ }
+
+ FlowRouter.triggers.enter([({ path }) => {
+ updateSandstormMetaData({ setPath: path });
+ }]);
+
+ Tracker.autorun(() => {
+ updateSandstormMetaData({ setTitle: DocHead.getTitle() });
+ });
+
// XXX Hack. `Meteor.absoluteUrl` doesn't work in Sandstorm, since every
// session has a different URL whereas Meteor computes absoluteUrl based on
// the ROOT_URL environment variable. So we overwrite this function on a