mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-02 11:26:04 +01:00
Added YAML Linter reports section
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
# v1.9.2
|
||||
## mm/dd/2019
|
||||
|
||||
1. [](#new)
|
||||
* Added a new **YAML Linter** report to the `Tools - Reports` section
|
||||
|
||||
# v1.9.2
|
||||
## 04/15/2019
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ docs: https://github.com/getgrav/grav-plugin-admin/blob/develop/README.md
|
||||
license: MIT
|
||||
|
||||
dependencies:
|
||||
- { name: grav, version: '>=1.6.3' }
|
||||
- { name: grav, version: '>=1.6.7' }
|
||||
- { name: form, version: '>=3.0.0' }
|
||||
- { name: login, version: '>=3.0.0' }
|
||||
- { name: email, version: '>=3.0.0' }
|
||||
|
||||
@@ -9,6 +9,7 @@ use Grav\Common\GPM\GPM;
|
||||
use Grav\Common\GPM\Licenses;
|
||||
use Grav\Common\GPM\Response;
|
||||
use Grav\Common\Grav;
|
||||
use Grav\Common\Helpers\YamlLinter;
|
||||
use Grav\Common\Language\LanguageCodes;
|
||||
use Grav\Common\Page\Collection;
|
||||
use Grav\Common\Page\Interfaces\PageInterface;
|
||||
@@ -1671,6 +1672,14 @@ class Admin
|
||||
'result' => $result,
|
||||
]);
|
||||
|
||||
// Linting Issues
|
||||
|
||||
$result = YamlLinter::lint();
|
||||
|
||||
$reports['Yaml Linter'] = $this->grav['twig']->processTemplate('reports/yamllinter.html.twig', [
|
||||
'result' => $result,
|
||||
]);
|
||||
|
||||
// Fire new event to allow plugins to manipulate page frontmatter
|
||||
$this->grav->fireEvent('onAdminGenerateReports', new Event(['reports' => $reports]));
|
||||
|
||||
|
||||
@@ -18,23 +18,3 @@
|
||||
<div class="alert info">Security Scan complete: <strong>No issues found...</strong></div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
{#
|
||||
if (!empty($result)) {
|
||||
|
||||
$counter = 1;
|
||||
foreach ($result as $route => $results) {
|
||||
|
||||
$results_parts = array_map(function($value, $key) {
|
||||
return $key.': \''.$value . '\'';
|
||||
}, array_values($results), array_keys($results));
|
||||
|
||||
$io->writeln($counter++ .' - <cyan>' . $route . '</cyan> → <red>' . implode(', ', $results_parts) . '</red>');
|
||||
}
|
||||
|
||||
$io->error('Security Scan complete: ' . count($result) . ' potential XSS issues found...');
|
||||
|
||||
} else {
|
||||
$io->success('Security Scan complete: No issues found...');
|
||||
}
|
||||
#}
|
||||
|
||||
22
themes/grav/templates/reports/yamllinter.html.twig
Normal file
22
themes/grav/templates/reports/yamllinter.html.twig
Normal file
@@ -0,0 +1,22 @@
|
||||
{% if result %}
|
||||
<div class="alert warning"><strong>YAML Linting:</strong> Found <strong>{{ result|length }}</strong> linting errors</div>
|
||||
<table>
|
||||
{% for path, error in result %}
|
||||
{% set page_path = base_path ~ (path|pathinfo).dirname %}
|
||||
{% set page = grav.pages.get(page_path) %}
|
||||
<tr>
|
||||
<td><i class="fa fa-file-text-o"></i>
|
||||
{% if page.url %}
|
||||
<a href="{{ base_url ~ '/pages' ~ page.route }}/mode:expert">{{ page.route }}</a>
|
||||
{% else %}
|
||||
{{ path }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="double">{{ error }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% else %}
|
||||
<div class="alert info"><strong>YAML Linting:</strong> No errors found.</div>
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user