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
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.17.0] - 2026-10-01

- [#157](https://github.com/itk-dev/devops_itksites/pull/157)
Highlight detection result data with MicroLighter
- [#156](https://github.com/itk-dev/devops_itksites/pull/156)
Theme Swagger UI for dark mode

## [1.16.0] - 2026-09-30

- [#154](https://github.com/itk-dev/devops_itksites/pull/154)
Expand Down Expand Up @@ -416,7 +423,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [1.0.0] - 2022-09-15

[Unreleased]: https://github.com/itk-dev/devops_itksites/compare/1.16.0...HEAD
[Unreleased]: https://github.com/itk-dev/devops_itksites/compare/1.17.0...HEAD
[1.17.0]: https://github.com/itk-dev/devops_itksites/compare/1.16.0...1.17.0
[1.16.0]: https://github.com/itk-dev/devops_itksites/compare/1.15.1...1.16.0
[1.15.1]: https://github.com/itk-dev/devops_itksites/compare/1.15.0...1.15.1
[1.15.0]: https://github.com/itk-dev/devops_itksites/compare/1.14.0...1.15.0
Expand Down
2 changes: 2 additions & 0 deletions assets/admin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import "microlighter/themes/github.css";
import "./styles/admin.css";
import "microlighter/micro-lighter-element.js";
import TomSelect from "tom-select";

const tomSelectHandler = () => {
Expand Down
10 changes: 10 additions & 0 deletions assets/styles/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,13 @@
background: var(--button-invisible-danger-hover-hover-bg);
}
}

/* Code highlighted with <micro-lighter> follows the EasyAdmin light/dark
switch rather than the OS setting its theme uses. */
.ea-light-scheme [data-syntax-theme] {
color-scheme: light;
}

.ea-dark-scheme [data-syntax-theme] {
color-scheme: dark;
}
26 changes: 26 additions & 0 deletions assets/styles/api-docs.css
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,32 @@ header #logo img {
outline-color: var(--itk-blue);
}

/* Swagger UI dark mode (html.dark-mode, set from prefers-color-scheme): a dark
header and light title instead of the fixed light ones above, and cyan for
blue text, as in the Scalar dark theme below. */
html.dark-mode header:before {
background-color: var(--apip-page-background);
border-bottom-color: var(--apip-block-border);
}

html.dark-mode #swagger-ui.api-platform .info .title {
color: #fff;
}

html.dark-mode .swagger-ui .info a,
html.dark-mode #formats a {
color: var(--itk-cyan);
}

html.dark-mode .swagger-ui .scheme-container .btn.authorize {
color: var(--itk-cyan);
border-color: var(--itk-cyan);
}

html.dark-mode .swagger-ui .scheme-container .btn.authorize svg {
fill: var(--itk-cyan);
}

/* Scalar (?ui=scalar). Its themes live in cascade layers, so these unlayered
rules win without !important. */
.light-mode,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"type": "module",
"devDependencies": {
"@symfony/reprise": "^1.3.0",
"microlighter": "^2.2.0",
"prettier": "^2.8.3",
"tom-select": "^2.2.2",
"vite": "^8.3.1"
Expand Down
6 changes: 4 additions & 2 deletions src/Controller/Admin/DetectionResultCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
use EasyCorp\Bundle\EasyAdminBundle\Config\Filters;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\CodeEditorField;
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
use EasyCorp\Bundle\EasyAdminBundle\Field\Field;

/**
* @extends AbstractCrudController<DetectionResult>
Expand Down Expand Up @@ -54,7 +54,9 @@ public function configureFields(string $pageName): iterable
yield DateTimeField::new('createdAt')->hideOnIndex();
yield DateTimeField::new('modifiedAt')->hideOnIndex();
yield DateTimeField::new('lastContact');
yield CodeEditorField::new('prettyData')->hideOnIndex()->setLabel('Data');
yield Field::new('prettyData')->onlyOnDetail()->setLabel('Data')
->setTemplatePath('EasyAdminBundle/Fields/code_highlight.html.twig')
->setCustomOption('language', 'json');
}

#[\Override]
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/DetectionResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public function getPrettyData(): string
return $this->data;
}

return json_encode($json, JSON_PRETTY_PRINT);
return json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
}

public function setData(string $data): self
Expand Down
8 changes: 8 additions & 0 deletions templates/EasyAdminBundle/Fields/code_highlight.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{# @var field \EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto #}
{# Highlighted with <micro-lighter> from assets/admin.js; the language is the
field's "language" custom option. #}
<div data-syntax-theme="github">
<micro-lighter language="{{ field.customOptions.get('language') }}" controls="copy" line-numbers>
<pre><code>{{ field.value }}</code></pre>
</micro-lighter>
</div>
32 changes: 32 additions & 0 deletions tests/Entity/DetectionResultTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace App\Tests\Entity;

use App\Entity\DetectionResult;
use PHPUnit\Framework\TestCase;

class DetectionResultTest extends TestCase
{
public function testPrettyDataIndentsJsonWithoutEscapingSlashesOrUnicode(): void
{
$result = new DetectionResult()->setData('{"remotes":["https:\/\/github.com\/itk-dev\/sites"],"name":"Ærø"}');

$this->assertSame(<<<'JSON'
{
"remotes": [
"https://github.com/itk-dev/sites"
],
"name": "Ærø"
}
JSON, $result->getPrettyData());
}

public function testPrettyDataReturnsDataThatIsNotJsonAsIs(): void
{
$result = new DetectionResult()->setData('not json');

$this->assertSame('not json', $result->getPrettyData());
}
}
16 changes: 15 additions & 1 deletion vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,19 @@ export default defineConfig({
},
},
},
plugins: [Symfony()],
plugins: [
Symfony({
copy: [
// <micro-lighter> loads grammars with import(`./grammars/${language}.js`)
// relative to the bundle, which Vite leaves as is, so ship them next to
// it under their own names.
{
from: "node_modules/microlighter/dist/grammars",
to: "grammars",
pattern: /\.js$/,
hash: false,
},
],
}),
],
});
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@ lightningcss@^1.33.0:
lightningcss-win32-arm64-msvc "1.33.0"
lightningcss-win32-x64-msvc "1.33.0"

microlighter@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/microlighter/-/microlighter-2.2.0.tgz#c40f99cd420c26bb39bb5797c2e4e90e2f3b73c2"
integrity sha512-XFUHmKclX4taKWVpYkqJ/GlfUS27FzQTCph1u3v9OwkmQJGXry3Pk1e7SivLz6xGOCxRVyi3DSrztF3e460jrg==

nanoid@^3.3.18:
version "3.3.19"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.19.tgz#336d4aa4bcd4fb24d2cddede7ffeae40bec03f0a"
Expand Down
Loading