[Pkg-owncloud-commits] [php-sabredav] 26/64: Added a 'plugins' page to the browser plugin.
David Prévot
taffit at moszumanska.debian.org
Thu Dec 11 15:13:24 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to tag 2.2.0alpha1
in repository php-sabredav.
commit 9a8fe641f5f2c9e9e22a00f780afc26d88defb04
Author: Evert Pot <evert at rooftopsolutions.nl>
Date: Thu Nov 20 16:04:56 2014 -0500
Added a 'plugins' page to the browser plugin.
---
ChangeLog.md | 3 +
lib/CalDAV/Plugin.php | 21 ++++
lib/CalDAV/Schedule/Plugin.php | 20 ++++
lib/CardDAV/Plugin.php | 35 +++++++
lib/DAV/Auth/Plugin.php | 21 ++++
lib/DAV/Browser/Plugin.php | 231 +++++++++++++++++++++++++++++------------
lib/DAV/CorePlugin.php | 21 ++++
lib/DAV/ServerPlugin.php | 21 ++++
lib/DAV/Sync/Plugin.php | 21 ++++
lib/DAVACL/Plugin.php | 21 ++++
10 files changed, 349 insertions(+), 66 deletions(-)
diff --git a/ChangeLog.md b/ChangeLog.md
index b23baa7..431de59 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -4,6 +4,9 @@ ChangeLog
2.2.0-alpha1 (????-??-??)
-------------------------
+* The browser plugin now has a new page with information about your sabredav
+ server, and shows information about every plugin that's loaded in the
+ system.
* Removed: all `$tableName` arguments from every PDO backend. This was already
deprecated, but has now been fully removed. All of these have been replaced
with public properties.
diff --git a/lib/CalDAV/Plugin.php b/lib/CalDAV/Plugin.php
index d482962..6ef6dbf 100644
--- a/lib/CalDAV/Plugin.php
+++ b/lib/CalDAV/Plugin.php
@@ -1037,4 +1037,25 @@ class Plugin extends DAV\ServerPlugin {
}
+ /**
+ * Returns a bunch of meta-data about the plugin.
+ *
+ * Providing this information is optional, and is mainly displayed by the
+ * Browser plugin.
+ *
+ * The description key in the returned array may contain html and will not
+ * be sanitized.
+ *
+ * @return array
+ */
+ function getPluginInfo() {
+
+ return [
+ 'name' => $this->getPluginName(),
+ 'description' => 'Adds support for CalDAV (rfc4791)',
+ 'link' => 'http://sabre.io/dav/caldav/',
+ ];
+
+ }
+
}
diff --git a/lib/CalDAV/Schedule/Plugin.php b/lib/CalDAV/Schedule/Plugin.php
index 19604d4..078f08b 100644
--- a/lib/CalDAV/Schedule/Plugin.php
+++ b/lib/CalDAV/Schedule/Plugin.php
@@ -874,4 +874,24 @@ class Plugin extends ServerPlugin {
}
+ /**
+ * Returns a bunch of meta-data about the plugin.
+ *
+ * Providing this information is optional, and is mainly displayed by the
+ * Browser plugin.
+ *
+ * The description key in the returned array may contain html and will not
+ * be sanitized.
+ *
+ * @return array
+ */
+ function getPluginInfo() {
+
+ return [
+ 'name' => $this->getPluginName(),
+ 'description' => 'Adds calendar-auto-schedule, as defined in rf6868',
+ 'link' => 'http://sabre.io/dav/scheduling/',
+ ];
+
+ }
}
diff --git a/lib/CardDAV/Plugin.php b/lib/CardDAV/Plugin.php
index 047ee1a..ab268aa 100644
--- a/lib/CardDAV/Plugin.php
+++ b/lib/CardDAV/Plugin.php
@@ -910,4 +910,39 @@ class Plugin extends DAV\ServerPlugin {
}
+ /**
+ * Returns a plugin name.
+ *
+ * Using this name other plugins will be able to access other plugins
+ * using DAV\Server::getPlugin
+ *
+ * @return string
+ */
+ function getPluginName() {
+
+ return 'carddav';
+
+ }
+
+ /**
+ * Returns a bunch of meta-data about the plugin.
+ *
+ * Providing this information is optional, and is mainly displayed by the
+ * Browser plugin.
+ *
+ * The description key in the returned array may contain html and will not
+ * be sanitized.
+ *
+ * @return array
+ */
+ function getPluginInfo() {
+
+ return [
+ 'name' => $this->getPluginName(),
+ 'description' => 'Adds support for CardDAV (rfc6352)',
+ 'link' => 'http://sabre.io/dav/carddav/',
+ ];
+
+ }
+
}
diff --git a/lib/DAV/Auth/Plugin.php b/lib/DAV/Auth/Plugin.php
index 858449d..a9a691f 100644
--- a/lib/DAV/Auth/Plugin.php
+++ b/lib/DAV/Auth/Plugin.php
@@ -119,4 +119,25 @@ class Plugin extends DAV\ServerPlugin {
}
+ /**
+ * Returns a bunch of meta-data about the plugin.
+ *
+ * Providing this information is optional, and is mainly displayed by the
+ * Browser plugin.
+ *
+ * The description key in the returned array may contain html and will not
+ * be sanitized.
+ *
+ * @return array
+ */
+ function getPluginInfo() {
+
+ return [
+ 'name' => $this->getPluginName(),
+ 'description' => 'Generic authentication plugin',
+ 'link' => 'http://sabre.io/dav/authentication/',
+ ];
+
+ }
+
}
diff --git a/lib/DAV/Browser/Plugin.php b/lib/DAV/Browser/Plugin.php
index d488a01..48d232b 100644
--- a/lib/DAV/Browser/Plugin.php
+++ b/lib/DAV/Browser/Plugin.php
@@ -79,30 +79,47 @@ class Plugin extends DAV\ServerPlugin {
// unit testable.
$getVars = $request->getQueryParameters();
+ // CSP headers
+ $this->server->httpResponse->setHeader('Content-Security-Policy', "img-src 'self'; style-src 'self';");
+
$sabreAction = isset($getVars['sabreAction'])?$getVars['sabreAction']:null;
- // Asset handling, such as images
- if ($sabreAction === 'asset' && isset($getVars['assetName'])) {
- $this->serveAsset($getVars['assetName']);
- return false;
- }
+ switch($sabreAction) {
- try {
- $this->server->tree->getNodeForPath($request->getPath());
- } catch (DAV\Exception\NotFound $e) {
- // We're simply stopping when the file isn't found to not interfere
- // with other plugins.
- return;
- }
+ case 'asset' :
+ // Asset handling, such as images
+ $this->serveAsset(isset($getVars['assetName'])?$getVars['assetName']:null);
+ return false;
+ default :
+ case 'nodeInfo' :
+ try {
+ $this->server->tree->getNodeForPath($request->getPath());
+ } catch (DAV\Exception\NotFound $e) {
+ // We're simply stopping when the file isn't found to not interfere
+ // with other plugins.
+ return;
+ }
- $response->setStatus(200);
- $response->setHeader('Content-Type','text/html; charset=utf-8');
+ $response->setStatus(200);
+ $response->setHeader('Content-Type','text/html; charset=utf-8');
- $response->setBody(
- $this->generateDirectoryIndex($request->getPath())
- );
+ $response->setBody(
+ $this->generateDirectoryIndex($request->getPath())
+ );
- return false;
+ return false;
+
+ case 'plugins' :
+ $response->setStatus(200);
+ $response->setHeader('Content-Type','text/html; charset=utf-8');
+
+ $response->setBody(
+ $this->generatePluginListing()
+ );
+
+ return false;
+
+ }
}
@@ -188,50 +205,7 @@ class Plugin extends DAV\ServerPlugin {
*/
function generateDirectoryIndex($path) {
- $version = '';
- if (DAV\Server::$exposeVersion) {
- $version = DAV\Version::VERSION;
- }
-
- $vars = [
- 'path' => $this->escapeHTML($path),
- 'favicon' => $this->escapeHTML($this->getAssetUrl('favicon.ico')),
- 'style' => $this->escapeHTML($this->getAssetUrl('sabredav.css')),
- 'iconstyle' => $this->escapeHTML($this->getAssetUrl('openiconic/open-iconic.css')),
- 'logo' => $this->escapeHTML($this->getAssetUrl('sabredav.png')),
- 'baseUrl' => $this->server->getBaseUri(),
- ];
-
- $html = <<<HTML
-<!DOCTYPE html>
-<html>
-<head>
- <title>$vars[path]/ - sabre/dav $version</title>
- <link rel="shortcut icon" href="$vars[favicon]" type="image/vnd.microsoft.icon" />
- <link rel="stylesheet" href="$vars[style]" type="text/css" />
- <link rel="stylesheet" href="$vars[iconstyle]" type="text/css" />
-
-</head>
-<body>
- <header>
- <div class="logo">
- <a href="$vars[baseUrl]"><img src="$vars[logo]" alt="sabre/dav" /> $vars[path]/</a>
- </div>
- </header>
-
- <nav>
-HTML;
-
- // If the path is empty, there's no parent.
- if ($path) {
- list($parentUri) = URLUtil::splitPath($path);
- $fullPath = URLUtil::encodePath($this->server->getBaseUri() . $parentUri);
- $html.='<a href="' . $fullPath . '" class="btn">⇤ Go to parent</a>';
- } else {
- $html.='<span class="btn disabled">⇤ Go to parent</span>';
- }
-
- $html.="</nav>";
+ $html = $this->generateHeader($path . '/', $path);
$node = $this->server->tree->getNodeForPath($path);
if ($node instanceof DAV\ICollection) {
@@ -322,10 +296,7 @@ HTML;
$html.="</section>\n";
}
- $html.= "
- <footer>Generated by SabreDAV " . $version . " (c)2007-2014 <a href=\"http://sabre.io/\">http://sabre.io/</a></footer>
- </body>
- </html>";
+ $html.=$this->generateFooter();
$this->server->httpResponse->setHeader('Content-Security-Policy', "img-src 'self'; style-src 'self';");
@@ -334,6 +305,99 @@ HTML;
}
/**
+ * Generates the 'plugins' page.
+ *
+ * @return string
+ */
+ function generatePluginListing() {
+
+ $html = $this->generateHeader('Plugins');
+
+ $html.="<section><h1>Plugins</h1>";
+ $html.="<table class=\"propTable\">";
+ foreach($this->server->getPlugins() as $plugin) {
+ $info = $plugin->getPluginInfo();
+ $html.='<tr><th>' . $info['name'] . '</th>';
+ $html.='<td>' . $info['description'] . '</td>';
+ $html.='<td>';
+ if (isset($info['link']) && $info['link']) {
+ $html.='<a href="' . $this->escapeHTML($info['link']) . '"><span class="oi" data-glyph="book"></span></a>';
+ }
+ $html.='</td></tr>';
+ }
+ $html.="</table>";
+ $html.="</section>";
+
+ /* Start of generating actions */
+
+ $html.=$this->generateFooter();
+
+ return $html;
+
+ }
+
+ function generateHeader($title, $path = null) {
+
+ $version = DAV\Version::VERSION;
+
+ $vars = [
+ 'title' => $this->escapeHTML($title),
+ 'favicon' => $this->escapeHTML($this->getAssetUrl('favicon.ico')),
+ 'style' => $this->escapeHTML($this->getAssetUrl('sabredav.css')),
+ 'iconstyle' => $this->escapeHTML($this->getAssetUrl('openiconic/open-iconic.css')),
+ 'logo' => $this->escapeHTML($this->getAssetUrl('sabredav.png')),
+ 'baseUrl' => $this->server->getBaseUri(),
+ ];
+
+ $html = <<<HTML
+<!DOCTYPE html>
+<html>
+<head>
+ <title>$vars[title] - sabre/dav $version</title>
+ <link rel="shortcut icon" href="$vars[favicon]" type="image/vnd.microsoft.icon" />
+ <link rel="stylesheet" href="$vars[style]" type="text/css" />
+ <link rel="stylesheet" href="$vars[iconstyle]" type="text/css" />
+
+</head>
+<body>
+ <header>
+ <div class="logo">
+ <a href="$vars[baseUrl]"><img src="$vars[logo]" alt="sabre/dav" /> $vars[title]</a>
+ </div>
+ </header>
+
+ <nav>
+HTML;
+
+ // If the path is empty, there's no parent.
+ if ($path) {
+ list($parentUri) = URLUtil::splitPath($path);
+ $fullPath = URLUtil::encodePath($this->server->getBaseUri() . $parentUri);
+ $html.='<a href="' . $fullPath . '" class="btn">⇤ Go to parent</a>';
+ } else {
+ $html.='<span class="btn disabled">⇤ Go to parent</span>';
+ }
+
+ $html.= ' <a href="?sabreAction=plugins" class="btn"><span class="oi" data-glyph="puzzle-piece"></span> Plugins</a>';
+
+ $html.="</nav>";
+
+ return $html;
+
+ }
+
+ function generateFooter() {
+
+ $version = DAV\Version::VERSION;
+ return <<<HTML
+<footer>Generated by SabreDAV $version (c)2007-2014 <a href="http://sabre.io/">http://sabre.io/</a></footer>
+</body>
+</html>
+HTML;
+
+ }
+
+ /**
* This method is used to generate the 'actions panel' output for
* collections.
*
@@ -665,4 +729,39 @@ HTML;
}
+ /**
+ * Returns a plugin name.
+ *
+ * Using this name other plugins will be able to access other plugins;
+ * using \Sabre\DAV\Server::getPlugin
+ *
+ * @return string
+ */
+ function getPluginName() {
+
+ return 'browser';
+
+ }
+
+ /**
+ * Returns a bunch of meta-data about the plugin.
+ *
+ * Providing this information is optional, and is mainly displayed by the
+ * Browser plugin.
+ *
+ * The description key in the returned array may contain html and will not
+ * be sanitized.
+ *
+ * @return array
+ */
+ function getPluginInfo() {
+
+ return [
+ 'name' => $this->getPluginName(),
+ 'description' => 'Generates HTML indexes and debug information for your sabre/dav server',
+ 'link' => 'http://sabre.io/dav/browser-plugin/',
+ ];
+
+ }
+
}
diff --git a/lib/DAV/CorePlugin.php b/lib/DAV/CorePlugin.php
index 8547c3e..fb41456 100644
--- a/lib/DAV/CorePlugin.php
+++ b/lib/DAV/CorePlugin.php
@@ -891,4 +891,25 @@ class CorePlugin extends ServerPlugin {
});
}
+
+ /**
+ * Returns a bunch of meta-data about the plugin.
+ *
+ * Providing this information is optional, and is mainly displayed by the
+ * Browser plugin.
+ *
+ * The description key in the returned array may contain html and will not
+ * be sanitized.
+ *
+ * @return array
+ */
+ function getPluginInfo() {
+
+ return [
+ 'name' => $this->getPluginName(),
+ 'description' => 'The Core plugin provides a lot of the basic functionality required by WebDAV, such as a default implementation for all HTTP and WebDAV methods.',
+ 'link' => null,
+ ];
+
+ }
}
diff --git a/lib/DAV/ServerPlugin.php b/lib/DAV/ServerPlugin.php
index 415b1e6..f002c1b 100644
--- a/lib/DAV/ServerPlugin.php
+++ b/lib/DAV/ServerPlugin.php
@@ -86,5 +86,26 @@ abstract class ServerPlugin {
}
+ /**
+ * Returns a bunch of meta-data about the plugin.
+ *
+ * Providing this information is optional, and is mainly displayed by the
+ * Browser plugin.
+ *
+ * The description key in the returned array may contain html and will not
+ * be sanitized.
+ *
+ * @return array
+ */
+ function getPluginInfo() {
+
+ return [
+ 'name' => $this->getPluginName(),
+ 'description' => null,
+ 'link' => null,
+ ];
+
+ }
+
}
diff --git a/lib/DAV/Sync/Plugin.php b/lib/DAV/Sync/Plugin.php
index d0cfdea..29edc4e 100644
--- a/lib/DAV/Sync/Plugin.php
+++ b/lib/DAV/Sync/Plugin.php
@@ -333,5 +333,26 @@ class Plugin extends DAV\ServerPlugin {
}
+ /**
+ * Returns a bunch of meta-data about the plugin.
+ *
+ * Providing this information is optional, and is mainly displayed by the
+ * Browser plugin.
+ *
+ * The description key in the returned array may contain html and will not
+ * be sanitized.
+ *
+ * @return array
+ */
+ function getPluginInfo() {
+
+ return [
+ 'name' => $this->getPluginName(),
+ 'description' => 'Adds support for WebDAV Collection Sync (rfc6578)',
+ 'link' => 'http://sabre.io/dav/sync/',
+ ];
+
+ }
+
}
diff --git a/lib/DAVACL/Plugin.php b/lib/DAVACL/Plugin.php
index e1a5583..3cc8df3 100644
--- a/lib/DAVACL/Plugin.php
+++ b/lib/DAVACL/Plugin.php
@@ -1404,4 +1404,25 @@ class Plugin extends DAV\ServerPlugin {
/* }}} */
+
+ /**
+ * Returns a bunch of meta-data about the plugin.
+ *
+ * Providing this information is optional, and is mainly displayed by the
+ * Browser plugin.
+ *
+ * The description key in the returned array may contain html and will not
+ * be sanitized.
+ *
+ * @return array
+ */
+ function getPluginInfo() {
+
+ return [
+ 'name' => $this->getPluginName(),
+ 'description' => 'Adds support for WebDAV ACL (rfc3744)',
+ 'link' => 'http://sabre.io/dav/acl/',
+ ];
+
+ }
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabredav.git
More information about the Pkg-owncloud-commits
mailing list