From 34f0ad4ebef9c492210c482f505b411d8ad6e004 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 24 Mar 2017 11:51:58 +0100 Subject: [PATCH 1/3] Allow to push a non-query URL to the browser history Signed-off-by: Joas Schilling --- core/js/js.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/core/js/js.js b/core/js/js.js index 370e68f560..683f73c0d1 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -2005,11 +2005,13 @@ OC.Util.History = { * Note: this includes a workaround for IE8/IE9 that uses * the hash part instead of the search part. * - * @param params to append to the URL, can be either a string + * @param {Object|string} params to append to the URL, can be either a string * or a map + * @param {string} [url] URL to be used, otherwise the current URL will be used, + * using the params as query string * @param {boolean} [replace=false] whether to replace instead of pushing */ - _pushState: function(params, replace) { + _pushState: function(params, url, replace) { var strParams; if (typeof(params) === 'string') { strParams = params; @@ -2018,7 +2020,7 @@ OC.Util.History = { strParams = OC.buildQueryString(params); } if (window.history.pushState) { - var url = location.pathname + '?' + strParams; + url = url || location.pathname + '?' + strParams; // Workaround for bug with SVG and window.history.pushState on Firefox < 51 // https://bugzilla.mozilla.org/show_bug.cgi?id=652991 var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1; @@ -2053,11 +2055,13 @@ OC.Util.History = { * Note: this includes a workaround for IE8/IE9 that uses * the hash part instead of the search part. * - * @param params to append to the URL, can be either a string + * @param {Object|string} params to append to the URL, can be either a string * or a map + * @param {string} [url] URL to be used, otherwise the current URL will be used, + * using the params as query string */ - pushState: function(params) { - return this._pushState(params, false); + pushState: function(params, url) { + return this._pushState(params, url, false); }, /** @@ -2066,11 +2070,13 @@ OC.Util.History = { * Note: this includes a workaround for IE8/IE9 that uses * the hash part instead of the search part. * - * @param params to append to the URL, can be either a string + * @param {Object|string} params to append to the URL, can be either a string * or a map + * @param {string} [url] URL to be used, otherwise the current URL will be used, + * using the params as query string */ - replaceState: function(params) { - return this._pushState(params, true); + replaceState: function(params, url) { + return this._pushState(params, url, true); }, /** From bc11c7ba97bcfb6115ed374b78cb767a2f328545 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 24 Mar 2017 11:52:42 +0100 Subject: [PATCH 2/3] Allow to use short URLs for calls Signed-off-by: Joas Schilling --- core/routes.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/routes.php b/core/routes.php index 5d61d58e03..5243691df4 100644 --- a/core/routes.php +++ b/core/routes.php @@ -82,6 +82,12 @@ $this->create('files.viewcontroller.showFile', '/f/{fileid}')->action(function($ $app->dispatch('ViewController', 'index'); }); +// Call routes +$this->create('spreed.pagecontroller.showCall', '/call/{token}')->action(function($urlParams) { + $app = new \OCA\Spreed\AppInfo\Application($urlParams); + $app->dispatch('PageController', 'index'); +}); + // Sharing routes $this->create('files_sharing.sharecontroller.showShare', '/s/{token}')->action(function($urlParams) { $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); From 4174d75f8661ca3a26ef8cdfd48a6f955491fdfe Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 24 Mar 2017 15:02:49 +0100 Subject: [PATCH 3/3] Throw a nice HintException when the apps are missing Signed-off-by: Joas Schilling --- core/routes.php | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/core/routes.php b/core/routes.php index 5243691df4..9b49b7198c 100644 --- a/core/routes.php +++ b/core/routes.php @@ -84,26 +84,46 @@ $this->create('files.viewcontroller.showFile', '/f/{fileid}')->action(function($ // Call routes $this->create('spreed.pagecontroller.showCall', '/call/{token}')->action(function($urlParams) { - $app = new \OCA\Spreed\AppInfo\Application($urlParams); - $app->dispatch('PageController', 'index'); + if (class_exists(\OCA\Spreed\AppInfo\Application::class, false)) { + $app = new \OCA\Spreed\AppInfo\Application($urlParams); + $app->dispatch('PageController', 'index'); + } else { + throw new \OC\HintException('App spreed is not enabled'); + } }); // Sharing routes $this->create('files_sharing.sharecontroller.showShare', '/s/{token}')->action(function($urlParams) { - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); - $app->dispatch('ShareController', 'showShare'); + if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); + $app->dispatch('ShareController', 'showShare'); + } else { + throw new \OC\HintException('App file sharing is not enabled'); + } }); $this->create('files_sharing.sharecontroller.authenticate', '/s/{token}/authenticate')->post()->action(function($urlParams) { - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); - $app->dispatch('ShareController', 'authenticate'); + if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); + $app->dispatch('ShareController', 'authenticate'); + } else { + throw new \OC\HintException('App file sharing is not enabled'); + } }); $this->create('files_sharing.sharecontroller.showAuthenticate', '/s/{token}/authenticate')->get()->action(function($urlParams) { - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); - $app->dispatch('ShareController', 'showAuthenticate'); + if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); + $app->dispatch('ShareController', 'showAuthenticate'); + } else { + throw new \OC\HintException('App file sharing is not enabled'); + } }); $this->create('files_sharing.sharecontroller.downloadShare', '/s/{token}/download')->get()->action(function($urlParams) { - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); - $app->dispatch('ShareController', 'downloadShare'); + if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); + $app->dispatch('ShareController', 'downloadShare'); + } else { + throw new \OC\HintException('App file sharing is not enabled'); + } }); // used for heartbeat