add plugin category display support to the website
This commit is contained in:
parent
4073e56856
commit
362406f529
@ -3,3 +3,7 @@ body {
|
||||
background: url('../img/bg.jpg');
|
||||
}
|
||||
|
||||
|
||||
table tr.category_header {
|
||||
background: #ddd;
|
||||
}
|
||||
|
@ -16,8 +16,37 @@ function iitcDesktopDownload ( $build )
|
||||
|
||||
function iitcDesktopPluginDownloadTable ( $build )
|
||||
{
|
||||
$categories = Array (
|
||||
'Info' => "",
|
||||
'Keys' => "Key management",
|
||||
'Controls' => "Map controls",
|
||||
'Highlighter' => "Portal highliters",
|
||||
'Layer' => "Additional map layers",
|
||||
'Map Tiles' => "Alternative map layers",
|
||||
'Tweaks' => "Adjust IITC settings",
|
||||
'Misc' => "Unclassified plugins",
|
||||
);
|
||||
|
||||
$plugins = Array();
|
||||
|
||||
foreach ( glob ( "$build/plugins/*.user.js" ) as $path )
|
||||
{
|
||||
$basename = basename ( $path, ".user.js" );
|
||||
$details = loadUserScriptHeader ( $path );
|
||||
|
||||
$plugins[$basename] = $details;
|
||||
|
||||
$category = array_key_exists('@category',$details) ? $details['@category'] : 'Misc';
|
||||
|
||||
if ( !array_key_exists($category,$categories) )
|
||||
{
|
||||
# add missing categories
|
||||
$categories[$category] = '';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<table class="table table-condensed table-hover">
|
||||
<table class="table table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
@ -29,30 +58,41 @@ function iitcDesktopPluginDownloadTable ( $build )
|
||||
<tbody>
|
||||
|
||||
<?php
|
||||
foreach ( glob ( "$build/plugins/*.user.js" ) as $path )
|
||||
{
|
||||
$basename = basename ( $path, ".user.js" );
|
||||
foreach ( $categories as $category => $category_desc )
|
||||
{
|
||||
print "<tr class=\"category_header\"><th colspan=\"2\">Category: $category</th><td colspan=\"2\">$category_desc</td></tr>\n";
|
||||
|
||||
$details = loadUserScriptHeader ( $path );
|
||||
$empty = True;
|
||||
foreach ( $plugins as $basename => $details )
|
||||
{
|
||||
$this_category = array_key_exists('@category',$details) ? $details['@category'] : 'Misc';
|
||||
|
||||
print "<tr id=\"plugin-$basename\">\n";
|
||||
if ( $category != $this_category )
|
||||
continue;
|
||||
|
||||
# remove 'IITC Plugin: ' prefix if it's there, for neatness
|
||||
$name = preg_replace ( '/^IITC plugin: /i', '', $details['@name'] );
|
||||
$empty = False;
|
||||
|
||||
# format extended version info in less prominant font
|
||||
$version = preg_replace ( '/^(\d+\.\d+\.\d+)\.(\d{8}\.\d{6})/', '\1<small class="muted">.\2</small>', $details['@version'] );
|
||||
print "<tr id=\"plugin-$basename\">\n";
|
||||
|
||||
# remove unneeded prefix from description
|
||||
$description = preg_replace ( '/^\[[^]]*\] */', '', $details['@description'] );
|
||||
# remove 'IITC Plugin: ' prefix if it's there, for neatness
|
||||
$name = preg_replace ( '/^IITC plugin: /i', '', $details['@name'] );
|
||||
|
||||
print "<td>$name</td>";
|
||||
print "<td>$basename<br />$version</td>";
|
||||
print "<td>$description</td>";
|
||||
print "<td><a onclick=\"if(track){track('desktop','iitc-plugin-$basename','$build');}\" href=\"$path\" class=\"btn btn-small btn-primary\">Download</a></td>";
|
||||
print "</tr>\n";
|
||||
}
|
||||
# format extended version info in less prominant font
|
||||
$version = preg_replace ( '/^(\d+\.\d+\.\d+)\.(\d{8}\.\d{6})/', '\1<small class="muted">.\2</small>', $details['@version'] );
|
||||
|
||||
# remove unneeded prefix from description
|
||||
$description = preg_replace ( '/^\[[^]]*\] */', '', $details['@description'] );
|
||||
|
||||
print "<td>$name</td>";
|
||||
print "<td>$basename<br />$version</td>";
|
||||
print "<td>$description</td>";
|
||||
print "<td><a onclick=\"if(track){track('desktop','iitc-plugin-$basename','$build');}\" href=\"$path\" class=\"btn btn-small btn-primary\">Download</a></td>";
|
||||
print "</tr>\n";
|
||||
}
|
||||
if ( $empty )
|
||||
print "<tr><td colspan=\"4\">(no plugins in this category)</td></tr>\n";
|
||||
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
Loading…
x
Reference in New Issue
Block a user