Improve addon readme display

- Add maintainer display support
- Remove extra comma after author/maintainer lists
This commit is contained in:
Hypolite Petovan 2018-01-28 00:05:28 -05:00
parent b158914c41
commit 17faeca241
2 changed files with 28 additions and 27 deletions

View File

@ -254,25 +254,26 @@ class Addon
*
* like
* \code
*...* Name: addon
* * Description: An addon which plugs in
* . * Version: 1.2.3
* * Author: John <profile url>
* * Author: Jane <email>
* *
* *\endcode
* @param string $addon the name of the addon
* @return array with the addon information
*/
* * Name: addon
* * Description: An addon which plugs in
* . * Version: 1.2.3
* * Author: John <profile url>
* * Author: Jane <email>
* * Maintainer: Jess <email>
* *
* *\endcode
* @param string $addon the name of the addon
* @return array with the addon information
*/
public static function getInfo($addon)
{
$a = get_app();
$info=[
$info = [
'name' => $addon,
'description' => "",
'author' => [],
'maintainer' => [],
'version' => "",
'status' => ""
];
@ -292,18 +293,18 @@ class Addon
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);
list($type, $v) = array_map("trim", explode(":", $l, 2));
$type = strtolower($type);
if ($type == "author" || $type == "maintainer") {
$r = preg_match("|([^<]+)<([^>]+)>|", $v, $m);
if ($r) {
$info['author'][] = ['name'=>$m[1], 'link'=>$m[2]];
$info[$type][] = ['name' => $m[1], 'link' => $m[2]];
} else {
$info['author'][] = ['name'=>$v];
$info[$type][] = ['name' => $v];
}
} else {
if (array_key_exists($k, $info)) {
$info[$k]=$v;
if (array_key_exists($type, $info)) {
$info[$type] = $v;
}
}
}

View File

@ -1,22 +1,22 @@
<div id='adminpage'>
<h1>{{$title}} - {{$page}}</h1>
<p><span class='toggleplugin icon {{$status}}'></span> {{$info.name}} - {{$info.version}} : <a href="{{$baseurl}}/admin/{{$function}}/{{$addon}}/?a=t&amp;t={{$form_security_token}}">{{$action}}</a></p>
<p>{{$info.description}}</p>
<p class="author">{{$str_author}}
{{foreach $info.author as $a}}
{{if $a.link}}<a href="{{$a.link}}">{{$a.name}}</a>{{else}}{{$a.name}}{{/if}},
{{foreach $info.author as $a name=authors}}
{{if $a.link}}<a href="{{$a.link}}">{{$a.name}}</a>{{else}}{{$a.name}}{{/if}}{{if $smarty.foreach.authors.last}}{{else}}, {{/if}}
{{/foreach}}
</p>
<p class="maintainer">{{$str_maintainer}}
{{foreach $info.maintainer as $a}}
{{if $a.link}}<a href="{{$a.link}}">{{$a.name}}</a>{{else}}{{$a.name}}{{/if}},
{{foreach $info.maintainer as $a name=maintainers}}
{{if $a.link}}<a href="{{$a.link}}">{{$a.name}}</a>{{else}}{{$a.name}}{{/if}}{{if $smarty.foreach.maintainers.last}}{{else}}, {{/if}}
{{/foreach}}
</p>
{{if $screenshot}}
<a href="{{$screenshot.0}}" class='screenshot'><img src="{{$screenshot.0}}" alt="{{$screenshot.1}}" /></a>
{{/if}}