aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio Comuni <fabrix.xm@gmail.com>2011-06-14 14:21:43 +0200
committerFabio Comuni <fabrix.xm@gmail.com>2011-06-14 14:21:43 +0200
commit00e142e4f753005a8b4003585c6a88548f006315 (patch)
tree95ff3c0c6a7ad53be0d4e0042a93b8720f5c9941
parent283160901fcb5670b48c7897ccce615872cb956e (diff)
downloadvolse-hubzilla-00e142e4f753005a8b4003585c6a88548f006315.tar.gz
volse-hubzilla-00e142e4f753005a8b4003585c6a88548f006315.tar.bz2
volse-hubzilla-00e142e4f753005a8b4003585c6a88548f006315.zip
Load plugin info from plugin file. Show README.md or README from plugin dir in plugin details page
-rw-r--r--addon/oembed/oembed.php9
-rw-r--r--boot.php52
-rw-r--r--mod/admin.php20
-rw-r--r--view/admin_plugins.tpl7
-rw-r--r--view/admin_plugins_details.tpl16
5 files changed, 88 insertions, 16 deletions
diff --git a/addon/oembed/oembed.php b/addon/oembed/oembed.php
index a0a0239aa..f5be44194 100644
--- a/addon/oembed/oembed.php
+++ b/addon/oembed/oembed.php
@@ -1,10 +1,9 @@
<?php
/**
- * oembed plugin
- *
- * oEmbed is a format for allowing an embedded representation of a URL on third party sites
- * http://www.oembed.com/
- *
+ * Name: OEmbed
+ * Description: OEmbed is a format for allowing an embedded representation of a URL on third party sites http://www.oembed.com/
+ * Version: 1.2
+ * Author: Fabio Comuni <http://kirgroup.com/profile/fabrix>
*/
require_once('include/oembed.php');
diff --git a/boot.php b/boot.php
index 42b0ca41e..5d45de36f 100644
--- a/boot.php
+++ b/boot.php
@@ -2828,3 +2828,55 @@ function is_site_admin() {
return false;
}}
+/*
+ * parse plugin comment in search of plugin infos.
+ * like
+ *
+ * * Name: Plugin
+ * * Description: A plugin which plugs in
+ * * Version: 1.2.3
+ * * Author: John <profile url>
+ * * Author: Jane <email>
+ * *
+ */
+
+if (! function_exists('get_plugin_info')){
+function get_plugin_info($plugin){
+ if (!is_file("addon/$plugin/$plugin.php")) return false;
+
+ $f = file_get_contents("addon/$plugin/$plugin.php");
+ $r = preg_match("|/\*.*\*/|msU", $f, $m);
+
+ $info=Array(
+ 'name' => $plugin,
+ 'description' => "",
+ 'author' => array(),
+ 'version' => ""
+ );
+
+ if ($r){
+ $ll = explode("\n", $m[0]);
+ foreach( $ll as $l ) {
+ $l = trim($l,"\t\n\r */");
+ if ($l!=""){
+ list($k,$v) = array_map("trim", explode(":",$l,2));
+ $k= strtolower($k);
+ if ($k=="author"){
+ $r=preg_match("|([^<]+)<([^>]+)>|", $v, $m);
+ if ($r) {
+ $info['author'][] = array('name'=>$m[1], 'link'=>$m[2]);
+ } else {
+ $info['author'][] = array('name'=>$v);
+ }
+ } else {
+ if (array_key_exists($k,$info)){
+ $info[$k]=$v;
+ }
+ }
+
+ }
+ }
+
+ }
+ return $info;
+}}
diff --git a/mod/admin.php b/mod/admin.php
index e40c50396..6386e6ebc 100644
--- a/mod/admin.php
+++ b/mod/admin.php
@@ -340,7 +340,7 @@ function admin_page_plugins(&$a){
return; // NOTREACHED
}
// display plugin details
-
+ require_once('library/markdown.php');
if (in_array($plugin, $a->plugins)){
$status="on"; $action= t("Disable");
@@ -348,6 +348,14 @@ function admin_page_plugins(&$a){
$status="off"; $action= t("Enable");
}
+ $readme=Null;
+ if (is_file("addon/$plugin/README.md")){
+ $readme = file_get_contents("addon/$plugin/README.md");
+ $readme = Markdown($readme);
+ } else if (is_file("addon/$plugin/README")){
+ $readme = "<pre>". file_get_contents("addon/$plugin/README") ."</pre>";
+ }
+
$t = get_markup_template("admin_plugins_details.tpl");
return replace_macros($t, array(
'$title' => t('Administration'),
@@ -357,7 +365,10 @@ function admin_page_plugins(&$a){
'$plugin' => $plugin,
'$status' => $status,
- '$action' => $action
+ '$action' => $action,
+ '$info' => get_plugin_info($plugin),
+
+ '$readme' => $readme
));
}
@@ -373,9 +384,8 @@ function admin_page_plugins(&$a){
foreach($files as $file) {
if (is_dir($file)){
list($tmp, $id)=array_map("trim", explode("/",$file));
- // TODO: plugins info
- $name=$author=$description=$homepage="";
- $plugins[] = array( $id, (in_array($id, $a->plugins)?"on":"off") , $name, $author, $description, $homepage);
+ $info = get_plugin_info($id);
+ $plugins[] = array( $id, (in_array($id, $a->plugins)?"on":"off") , $info);
}
}
}
diff --git a/view/admin_plugins.tpl b/view/admin_plugins.tpl
index d29665a06..ee0fa67e6 100644
--- a/view/admin_plugins.tpl
+++ b/view/admin_plugins.tpl
@@ -4,10 +4,9 @@
<ul id='pluginslist'>
{{ for $plugins as $p }}
<li class='plugin $p.1'>
- <a class='toggle' href='$baseurl/admin/plugins/$p.0?a=t'><span class='icon $p.1'></span></a>
- <a href='$baseurl/admin/plugins/$p.0'>
- <span class='name'>$p.0</span>
- </a>
+ <a class='toggleplugin' href='$baseurl/admin/plugins/$p.0?a=t'><span class='icon $p.1'></span></a>
+ <a href='$baseurl/admin/plugins/$p.0'><span class='name'>$p.2.name</span></a> - <span class="version">$p.2.version</span>
+ <div class='desc'>$p.2.description</div>
</li>
{{ endfor }}
</ul>
diff --git a/view/admin_plugins_details.tpl b/view/admin_plugins_details.tpl
index 7e2e95521..acb3d2862 100644
--- a/view/admin_plugins_details.tpl
+++ b/view/admin_plugins_details.tpl
@@ -1,7 +1,19 @@
<div id='adminpage'>
<h1>$title - $page</h1>
- <p><span class='icon $status'></span> $plugin</p>
+ <p><span class='toggleplugin icon $status'></span> $info.name - $info.version : <a href="$baseurl/admin/plugins/$plugin/?a=t">$action</a></p>
+ <p>$info.description</p>
+ <p>
+ {{ for $info.author as $a }}
+ <a href="$a.link">$a.name</a>
+ {{ endfor }}
+ </p>
- <p><a href="$baseurl/admin/plugins/$plugin/?a=t">$action</a></p>
+
+ {{ if $readme }}
+ <h3>Readme</h3>
+ <div id="plugin_readme">
+ $readme
+ </div>
+ {{ endif }}
</div>