Improve changelog parsing

Recompile system LESS files
Refs #2414
This commit is contained in:
Samuel Georges 2016-10-17 07:38:20 +11:00
parent 9ddd3b71dc
commit 622384d432
6 changed files with 84 additions and 23 deletions

View File

@ -5,16 +5,16 @@
margin-top: 0; margin-top: 0;
} }
.plugin-details-content h1 { .plugin-details-content h1 {
font-size: 31px; font-size: 28px;
} }
.plugin-details-content h2 { .plugin-details-content h2 {
font-size: 26px; font-size: 24px;
} }
.plugin-details-content h3 { .plugin-details-content h3 {
font-size: 22px; font-size: 20px;
} }
.plugin-details-content h4 { .plugin-details-content h4 {
font-size: 18px; font-size: 17px;
} }
.plugin-details-content h1, .plugin-details-content h1,
.plugin-details-content h2 { .plugin-details-content h2 {
@ -23,12 +23,12 @@
} }
.plugin-details-content ul, .plugin-details-content ul,
.plugin-details-content ol { .plugin-details-content ol {
padding-left: 25px; padding-left: 20px;
} }
.plugin-details-content pre { .plugin-details-content pre {
display: block; display: block;
border: none; border: none;
padding: 10px 10px 10px 25px; padding: 10px 10px 10px 20px;
font-size: 13px; font-size: 13px;
word-break: break-all; word-break: break-all;
word-wrap: break-word; word-wrap: break-word;
@ -36,8 +36,8 @@
background-color: #333; background-color: #333;
margin-top: 10px; margin-top: 10px;
margin-bottom: 20px; margin-bottom: 20px;
margin-left: -25px; margin-left: -20px;
margin-right: -25px; margin-right: -20px;
} }
.plugin-details-content pre code { .plugin-details-content pre code {
padding: 0; padding: 0;
@ -49,21 +49,36 @@
} }
.plugin-details-content ul pre, .plugin-details-content ul pre,
.plugin-details-content ol pre { .plugin-details-content ol pre {
margin-left: -50px; margin-left: -40px;
padding-left: 50px; padding-left: 40px;
} }
.plugin-details-content table th { .plugin-details-content table th {
font-weight: bold font-weight: bold;
} }
.plugin-details-content table th, .plugin-details-content table th,
.plugin-details-content table td { .plugin-details-content table td {
padding: 6px 13px; padding: 6px 13px;
border: 1px solid #ddd border: 1px solid #ddd;
} }
.plugin-details-content table tr { .plugin-details-content table tr {
background-color: #fff; background-color: #fff;
border-top: 1px solid #ccc border-top: 1px solid #ccc;
} }
.plugin-details-content table tr:nth-child(2n) { .plugin-details-content table tr:nth-child(2n) {
background-color: #f8f8f8 background-color: #f8f8f8;
} }
.plugin-details-content dl dt,
.plugin-details-content dl dd {
margin-bottom: 10px;
}
.plugin-details-content dl dt {
width: 75px;
float: left;
text-align: right;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
.plugin-details-content dl dd {
margin-left: 85px;
}

View File

@ -70,6 +70,8 @@
border: 1px solid #E6E9E9; border: 1px solid #E6E9E9;
background: #fff; background: #fff;
position: relative; position: relative;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px; border-radius: 3px;
-webkit-transition: border .2s linear; -webkit-transition: border .2s linear;
-moz-transition: border .2s linear; -moz-transition: border .2s linear;

View File

@ -3,7 +3,7 @@
} }
.control-updatelist { .control-updatelist {
border: 1px solid #ccc; border: 1px solid #ccc;
margin-bottom: 21px; margin-bottom: 20px;
} }
.control-updatelist .update-item { .control-updatelist .update-item {
border-bottom: 1px solid #ccc; border-bottom: 1px solid #ccc;
@ -80,7 +80,9 @@
text-align: center; text-align: center;
white-space: nowrap; white-space: nowrap;
vertical-align: baseline; vertical-align: baseline;
border-radius: .25em; -webkit-border-radius: 0.25em;
-moz-border-radius: 0.25em;
border-radius: 0.25em;
} }
.control-updatelist .update-item:last-child { .control-updatelist .update-item:last-child {
border-bottom: none; border-bottom: none;

View File

@ -68,4 +68,21 @@
} }
} }
} }
}
dl {
dt, dd {
margin-bottom: (@padding-standard / 2);
}
dt {
width: 75px;
float: left;
text-align: right;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
dd {
margin-left: 85px;
}
}
}

View File

@ -3,6 +3,7 @@
use Str; use Str;
use Lang; use Lang;
use Html; use Html;
use Yaml;
use File; use File;
use Flash; use Flash;
use Config; use Config;
@ -125,7 +126,7 @@ class Updates extends Controller
if ($path && $plugin) { if ($path && $plugin) {
$details = $plugin->pluginDetails(); $details = $plugin->pluginDetails();
$readme = $this->getPluginMarkdownFile($path, $readmeFiles); $readme = $this->getPluginMarkdownFile($path, $readmeFiles);
$changelog = File::get($path.'/updates/version.yaml'); $changelog = $this->getPluginVersionFile($path, 'updates/version.yaml');
$upgrades = $this->getPluginMarkdownFile($path, $upgradeFiles); $upgrades = $this->getPluginMarkdownFile($path, $upgradeFiles);
$licence = $this->getPluginMarkdownFile($path, $licenceFiles); $licence = $this->getPluginMarkdownFile($path, $licenceFiles);
@ -151,7 +152,7 @@ class Updates extends Controller
$this->vars['activeTab'] = $tab ?: 'readme'; $this->vars['activeTab'] = $tab ?: 'readme';
$this->vars['urlCode'] = $urlCode; $this->vars['urlCode'] = $urlCode;
$this->vars['readme'] = $readme; $this->vars['readme'] = $readme;
$this->vars['changelog'] = nl2br(str_replace('- ', '&nbsp; &nbsp; - ', '<p>'.$changelog.'</p>')); $this->vars['changelog'] = $changelog;
$this->vars['upgrades'] = $upgrades; $this->vars['upgrades'] = $upgrades;
$this->vars['licence'] = $licence; $this->vars['licence'] = $licence;
} }
@ -160,6 +161,25 @@ class Updates extends Controller
} }
} }
protected function getPluginVersionFile($path, $filename)
{
$contents = [];
try {
$updates = Yaml::parseFile($path.'/'.$filename);
$updates = is_array($updates) ? array_reverse($updates) : [];
foreach ($updates as $version => $details) {
$contents[$version] = is_array($details)
? array_shift($details)
: $details;
}
}
catch (Exception $ex) {}
return $contents;
}
protected function getPluginMarkdownFile($path, $filenames) protected function getPluginMarkdownFile($path, $filenames)
{ {
$contents = null; $contents = null;

View File

@ -75,7 +75,12 @@
<div class="tab-pane <?= $activeTab == 'changelog' ? 'active' : '' ?>"> <div class="tab-pane <?= $activeTab == 'changelog' ? 'active' : '' ?>">
<div class="plugin-details-content"> <div class="plugin-details-content">
<?php if ($changelog): ?> <?php if ($changelog): ?>
<?= $changelog ?> <dl>
<?php foreach ($changelog as $version => $comment): ?>
<dt><?= e($version) ?></dt>
<dd><?= e($comment) ?></dd>
<?php endforeach ?>
</dl>
<?php else: ?> <?php else: ?>
<p><?= e(trans('system::lang.updates.details_changelog_missing')) ?></p> <p><?= e(trans('system::lang.updates.details_changelog_missing')) ?></p>
<?php endif ?> <?php endif ?>