From 48f040f9aac805fb80df4d4bde649c5e36353261 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Thu, 21 Aug 2014 08:32:36 +0200 Subject: [PATCH] index page showing server setting --- appinfo/app.php | 2 +- appinfo/application.php | 11 ++++++ appinfo/routes.php | 6 ++++ controller/guicontroller.php | 70 ++++++++++++++++++++++++++++++++++++ index.php | 10 ------ templates/index.php | 7 ++++ 6 files changed, 95 insertions(+), 11 deletions(-) create mode 100644 controller/guicontroller.php delete mode 100755 index.php create mode 100644 templates/index.php diff --git a/appinfo/app.php b/appinfo/app.php index 3da4f00..b3c2b46 100755 --- a/appinfo/app.php +++ b/appinfo/app.php @@ -5,7 +5,7 @@ OCP\App::addNavigationEntry( array( 'id' => 'grauphel', 'order' => 2342, - 'href' => OCP\Util::linkTo('grauphel', 'index.php'), + 'href' => \OCP\Util::linkToRoute('grauphel.gui.index'), 'icon' => OCP\Util::imagePath('grauphel', 'notes.png'), 'name' => 'Tomboy notes' ) diff --git a/appinfo/application.php b/appinfo/application.php index 69d1572..cc39ceb 100644 --- a/appinfo/application.php +++ b/appinfo/application.php @@ -45,6 +45,17 @@ class Application extends App ); } ); + $container->registerService( + 'GuiController', + function($c) { + return new \OCA\Grauphel\Controller\GuiController( + $c->query('AppName'), + $c->query('Request'), + $c->query('Session')->getUser(), + $c->query('ServerContainer')->getURLGenerator() + ); + } + ); } } ?> diff --git a/appinfo/routes.php b/appinfo/routes.php index 31e5692..5585bdb 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -57,6 +57,12 @@ $application->registerRoutes( 'name' => 'api#note', 'verb' => 'GET', ), + + array( + 'url' => '/', + 'name' => 'gui#index', + 'verb' => 'GET', + ), ) ) ); diff --git a/controller/guicontroller.php b/controller/guicontroller.php new file mode 100644 index 0000000..f3fce6b --- /dev/null +++ b/controller/guicontroller.php @@ -0,0 +1,70 @@ + + * @copyright 2014 Christian Weiske + * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3 + * @link http://cweiske.de/grauphel.htm + */ +namespace OCA\Grauphel\Controller; + +use \OCP\AppFramework\Controller; +use \OCP\AppFramework\Http\TemplateResponse; + +/** + * Owncloud frontend + * + * @category Tools + * @package Grauphel + * @author Christian Weiske + * @copyright 2014 Christian Weiske + * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3 + * @version Release: @package_version@ + * @link http://cweiske.de/grauphel.htm + */ +class GuiController extends Controller +{ + /** + * constructor of the controller + * + * @param string $appName Name of the app + * @param IRequest $request Instance of the request + */ + public function __construct($appName, \OCP\IRequest $request, $user, $urlGen) + { + parent::__construct($appName, $request); + $this->user = $user; + $this->urlGen = $urlGen; + + //default http header: we assume something is broken + header('HTTP/1.0 500 Internal Server Error'); + } + + /** + * Main page / + * + * @NoAdminRequired + * @NoCSRFRequired + */ + public function index() + { + $res = new TemplateResponse('grauphel', 'index'); + $res->setParams( + array( + 'apiurl' => $this->urlGen->getAbsoluteURL( + $this->urlGen->linkToRoute( + 'grauphel.gui.index' + ) + ), + ) + ); + return $res; + + } +} +?> diff --git a/index.php b/index.php deleted file mode 100755 index 1129766..0000000 --- a/index.php +++ /dev/null @@ -1,10 +0,0 @@ -assign( 'somesetting', $somesetting ); -$tmpl->printPage(); diff --git a/templates/index.php b/templates/index.php new file mode 100644 index 0000000..f1fd34c --- /dev/null +++ b/templates/index.php @@ -0,0 +1,7 @@ +
+

Tomboy notes server

+

+ To use the REST API, use the follwing server with tomboy: +

+
+
-- 2.30.2