Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,5 @@
<ForbiddenCode occurrences="1">
<code>shell_exec($command)</code>
</ForbiddenCode>
<PossiblyNullReference occurrences="4">
<code>getChangeLogMd</code>
<code>getInstallationMd</code>
<code>getReadmeMd</code>
<code>getUsageMd</code>
</PossiblyNullReference>
</file>
</files>
8 changes: 8 additions & 0 deletions src/Classes/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,12 @@ public function invokeLazyModuleInfo()
$moduleLoader = ModuleLoader::create(Config::getDependenyMode());
$module = $moduleLoader->loadByArchiveNameAndVersion($archiveName, $version);

if (!$module) {
return ['content' => ''];
}

$description = $module->getDescriptionMd() !== '' ? $module->getDescriptionMd() : $module->getDescription();

if ($data == 'installationMd') {
return ['content' => $module->getInstallationMd()];
} elseif ($data == 'usageMd') {
Expand All @@ -316,6 +322,8 @@ public function invokeLazyModuleInfo()
return ['content' => $module->getChangeLogMd()];
} elseif ($data == 'readmeMd') {
return ['content' => $module->getReadmeMd()];
} elseif ($data == 'descriptionMd') {
return ['content' => $description];
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/Classes/LazyLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ public static function loadModuleReadme($module, $target, $default = '')
return self::createScript($target, $url, $default);
}

public static function loadModuleDescription($module, $target, $default = '')
{
$url = self::createUrl($module, 'descriptionMd');
return self::createScript($target, $url, $default);
}

public static function loadModuleInstallation($module, $target, $default = '')
{
$url = self::createUrl($module, 'installationMd');
Expand Down
13 changes: 13 additions & 0 deletions src/Classes/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,19 @@ public function getReadmeMd(): string
return FileHelper::readMarkdown($path);
}

/**
* Liefert die description.md als HTML.
*/
public function getDescriptionMd(): string
{
$docFilePath = $this->getDocFilePath('description.md');
if (!$docFilePath) {
return '';
}
$path = $this->getUrlOrLocalRootPath() . $docFilePath;
return FileHelper::readMarkdown($path);
}

/**
* Liefert den absoluten Pfad zur modulehash.json
*
Expand Down
19 changes: 10 additions & 9 deletions src/Templates/ModuleInfo.tmpl.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

/**
* @phpcs:disable Generic.Files.LineLength.TooLong
*/

defined('LOADED_FROM_INDEX') && LOADED_FROM_INDEX ?? die('Access denied.');

use RobinTheHood\ModifiedModuleLoaderClient\LazyLoader;
Expand Down Expand Up @@ -209,14 +213,10 @@
</div>

<h2>Beschreibung</h2>
<div class="markdown-body">
<p>
<?php if ($module->getDescription()) { ?>
<?= $module->getDescription() ?>
<?php } else { ?>
Keine Beschreibung vorhanden.
<?php } ?>
</p>
<div id="description">
<div class="markdown-body" style="padding-bottom: 30px">
Beschreibung wird geladen. Bitte warten...
</div>
</div>
</div>

Expand Down Expand Up @@ -379,7 +379,7 @@
<div class="markdown-body">
README.md Wird geladen. Bitte warten...
</div>
</div>
</div>
</div>
</div>

Expand All @@ -403,6 +403,7 @@
</div>
</div>

<?= LazyLoader::loadModuleDescription($module, '#description .markdown-body', 'Es ist keine Beschreibung vorhanden.'); ?>
<?= LazyLoader::loadModuleReadme($module, '#readme .markdown-body', 'Es ist keine README.md vorhanden.'); ?>
<?= LazyLoader::loadModuleInstallation($module, '#v-pills-install .markdown-body', 'Es ist keine manuelle Installationanleitung vorhanden.'); ?>
<?= LazyLoader::loadModuleUsage($module, '#v-pills-usage .markdown-body', 'Es ist keine Bedienungsanleitung vorhanden.'); ?>
Expand Down