index page showing server setting
authorChristian Weiske <cweiske@cweiske.de>
Thu, 21 Aug 2014 06:32:36 +0000 (08:32 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Thu, 21 Aug 2014 06:33:05 +0000 (08:33 +0200)
appinfo/app.php
appinfo/application.php
appinfo/routes.php
controller/guicontroller.php [new file with mode: 0644]
index.php [deleted file]
templates/index.php [new file with mode: 0644]

index 3da4f00..b3c2b46 100755 (executable)
@@ -5,7 +5,7 @@ OCP\App::addNavigationEntry(
     array( 
         'id' => 'grauphel',
         'order' => 2342,
     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'
     )
         'icon' => OCP\Util::imagePath('grauphel', 'notes.png'),
         'name' => 'Tomboy notes'
     )
index 69d1572..cc39ceb 100644 (file)
@@ -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()
+                );
+            }
+        );
     }
 }
 ?>
     }
 }
 ?>
index 31e5692..5585bdb 100644 (file)
@@ -57,6 +57,12 @@ $application->registerRoutes(
                 'name' => 'api#note',
                 'verb' => 'GET',
             ),
                 '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 (file)
index 0000000..f3fce6b
--- /dev/null
@@ -0,0 +1,70 @@
+<?php
+/**
+ * Part of grauphel
+ *
+ * PHP version 5
+ *
+ * @category  Tools
+ * @package   Grauphel
+ * @author    Christian Weiske <cweiske@cweiske.de>
+ * @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 <cweiske@cweiske.de>
+ * @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 (executable)
index 1129766..0000000
--- a/index.php
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-
-// Check if we are a user
-OCP\User::checkLoggedIn();
-
-$somesetting = OCP\Config::getSystemValue( "somesetting", '' );
-OCP\App::setActiveNavigationEntry( 'grauphel' );
-$tmpl = new OCP\Template( 'grauphel', 'main', 'user' );
-$tmpl->assign( 'somesetting', $somesetting );
-$tmpl->printPage();
diff --git a/templates/index.php b/templates/index.php
new file mode 100644 (file)
index 0000000..f1fd34c
--- /dev/null
@@ -0,0 +1,7 @@
+<div style="margin: 1em;">
+ <h1 style="font-size: 2em; font-weight: bold">Tomboy notes server</h1>
+ <p style="margin: 1em;">
+  To use the REST API, use the follwing server with tomboy:
+ </p>
+ <pre style="margin: 1em; background-color: #DDD; padding: 1ex; font-family: monospace"><?php p($_['apiurl']); ?></pre>
+</div>