diff options
author | Bart Visscher <bartv@thisnet.nl> | 2012-10-05 11:42:36 +0400 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2012-10-05 11:42:36 +0400 |
commit | f3a211c03c3dd017e263ac5226a52eb62562d198 (patch) | |
tree | 4161ed0ab3b5fe695d08dc0d51df0a0ea02fe313 /lib | |
parent | 167e9c1cc025ce920e48032ff5331fcb4f84de3d (diff) |
Implement routing on javascript side
Diffstat (limited to 'lib')
-rw-r--r-- | lib/base.php | 1 | ||||
-rw-r--r-- | lib/router.php | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/base.php b/lib/base.php index 2d82d5a40fc..f7967329c29 100644 --- a/lib/base.php +++ b/lib/base.php @@ -253,6 +253,7 @@ class OC{ OC_Util::addScript( "config" ); //OC_Util::addScript( "multiselect" ); OC_Util::addScript('search', 'result'); + OC_Util::addScript('router'); if( OC_Config::getValue( 'installed', false )) { if( OC_Appconfig::getValue( 'core', 'backgroundjobs_mode', 'ajax' ) == 'ajax' ) { diff --git a/lib/router.php b/lib/router.php index da491e217fc..04a3d410060 100644 --- a/lib/router.php +++ b/lib/router.php @@ -94,4 +94,22 @@ class OC_Router { { return $this->getGenerator()->generate($name, $parameters, $absolute); } + + public static function JSRoutes() + { + // TODO: http caching + $routes = array(); + $router = OC::getRouter(); + $root = $router->getCollection('root'); + foreach($root->all() as $name => $route) { + $compiled_route = $route->compile(); + $defaults = $route->getDefaults(); + unset($defaults['action']); + $routes[$name] = array( + 'tokens' => $compiled_route->getTokens(), + 'defaults' => $defaults, + ); + } + OCP\JSON::success ( array( 'data' => $routes ) ); + } } |