Drops aternos/codex (and its codex-minecraft / codex-hytale satellites)
plus aternos/sherlock from composer.json. Adds indifferentketchup/codex
pinned to ^0.2.0, sourced via a Composer vcs repository pointing at the
Gitea-hosted ik-codex repo. composer.lock regenerated against the new
dep tree.
Re-points the seven Aternos\Codex\* import sites in src/ to their
IndifferentKetchup\Codex\* equivalents:
- src/Log.php (5 imports)
- src/Api/Response/CodexLogResponse.php (1 import)
- src/Printer/Printer.php (5 imports)
- src/Detective.php (rewritten — see below)
Stubs three sites that depend on Minecraft-specific code with no
analogue in IndifferentKetchup\Codex:
- src/Detective.php no longer extends the Aternos Detective with
Minecraft + Hytale satellites. Instead it extends our codex's
Detective and registers ProjectZomboidDetective, which itself
pre-registers all 11 PZ log subclasses.
- src/Data/Deobfuscator.php is reduced to a no-op shell. mclogs used
aternos/sherlock to fetch Mojang/Yarn obfuscation maps and
deobfuscate Vanilla / Fabric stack traces. Project Zomboid uses no
such mapping scheme; the deobfuscator returns null until iblogs
supports Minecraft logs again. Class signature preserved so callers
in src/Log.php and elsewhere don't break.
- src/Printer/FormatModification.php no longer extends the Minecraft
section-sign-code translator. It extends IndifferentKetchup\Codex's
Modification base class with a pass-through modify() implementation.
The format-* CSS color classes are retained for any future game's
own format-code scheme to reuse.
Updates composer.json metadata: description rewritten to drop the
"Minecraft" framing, authors entry replaced with indifferentketchup /
samkintop@gmail.com.
Verification:
composer update --ignore-platform-req=ext-frankenphp \
--ignore-platform-req=ext-mongodb
-> resolves cleanly: 1 install (indifferentketchup/codex 0.2.0),
4 removals (the aternos/* set).
php -l on every touched file -> no syntax errors.
Autoload smoke test -> Detective registers 11 PZ log classes;
Printer instantiates; FormatModification stub returns input
unchanged.
89 lines
2.5 KiB
PHP
89 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace IndifferentKetchup\Iblogs\Printer;
|
|
|
|
use IndifferentKetchup\Codex\Log\Entry;
|
|
use IndifferentKetchup\Codex\Log\EntryInterface;
|
|
use IndifferentKetchup\Codex\Log\Level;
|
|
use IndifferentKetchup\Codex\Log\LineInterface;
|
|
use IndifferentKetchup\Codex\Printer\ModifiableDefaultPrinter;
|
|
use IndifferentKetchup\Iblogs\Id;
|
|
|
|
/**
|
|
* Class Printer
|
|
*
|
|
* @package Printer
|
|
*/
|
|
class Printer extends ModifiableDefaultPrinter
|
|
{
|
|
public function __construct()
|
|
{
|
|
$this->addModification(new FormatModification());
|
|
}
|
|
|
|
/**
|
|
* @var Id
|
|
*/
|
|
protected Id $id;
|
|
|
|
/**
|
|
* @param Id $id
|
|
* @return Printer
|
|
*/
|
|
public function setId(Id $id): static
|
|
{
|
|
$this->id = $id;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
protected function printLog(): string
|
|
{
|
|
return '<div class="log-inner">' . parent::printLog() . '</div>';
|
|
}
|
|
|
|
/**
|
|
* @param EntryInterface|null $entry
|
|
* @return string
|
|
* @throws \Exception
|
|
*/
|
|
protected function printEntry(?EntryInterface $entry = null): string
|
|
{
|
|
$entry = $entry ?? $this->entry;
|
|
/** @var Entry $entry */
|
|
$return = '';
|
|
$first = true;
|
|
foreach ($entry as $line) {
|
|
$entryClass = "entry-no-error";
|
|
if ($entry->getLevel()->asInt() <= Level::ERROR->asInt()) {
|
|
$entryClass = "entry-error";
|
|
}
|
|
$return .= '<div class="entry ' . $entryClass . '">';
|
|
$return .= '<div class="line-number-container"><a href="/' . $this->id->get() . '#L' . $line->getNumber() . '" id="L' . $line->getNumber() . '" class="line-number">' . $line->getNumber() . '</a></div>';
|
|
$return .= '<div class="line-content"><span class="level level-' . $entry->getLevel()->asString() . ((!$first) ? " multiline" : "") . '">';
|
|
$lineString = $this->printLine($line);
|
|
if ($entry->getPrefix() !== null) {
|
|
$prefix = htmlentities($entry->getPrefix());
|
|
$lineString = str_replace($prefix, '<span class="level-prefix">' . $prefix . '</span>', $lineString);
|
|
}
|
|
$return .= $lineString;
|
|
$return .= '</span></div>';
|
|
$return .= '</div>';
|
|
$first = false;
|
|
}
|
|
|
|
return $return;
|
|
}
|
|
|
|
/**
|
|
* @param LineInterface $line
|
|
* @return string
|
|
*/
|
|
protected function printLine(LineInterface $line): string
|
|
{
|
|
return $this->runModifications(htmlentities($line->getText())) . PHP_EOL;
|
|
}
|
|
}
|