feat: add changelog view and navigation link

This commit introduces a new changelog view that fetches and displays the git commit history. It also adds a navigation link to this changelog in the application layout.
This commit is contained in:
fsociety
2024-09-29 19:44:40 +02:00
parent a4052b1ed5
commit 5ba881dd60
2 changed files with 140 additions and 9 deletions

View File

@@ -100,18 +100,22 @@
Information Information
</div> </div>
<ul> <ul>
{{--<li> <li>
<a class="font-medium text-sm text-amber-500 hover:text-amber-600 dark:hover:text-amber-400 flex items-center py-1 px-3" <a class="font-medium text-sm text-amber-500 hover:text-amber-600 dark:hover:text-amber-400 flex items-center py-1 px-3"
href="#0" @click="open = false" @focus="open = true" href="{{ route('changelog') }}" @click="open = false" @focus="open = true"
@focusout="open = false"> @focusout="open = false">
<svg class="w-3 h-3 fill-current text-amber-500 shrink-0 mr-2" <i class="fa-sharp-duotone fa-solid fa-code w-3 h-3 fill-current text-amber-500 shrink-0 mr-2"></i>
viewBox="0 0 12 12"> <span>Changelog</span>
<rect y="3" width="12" height="9" rx="1"/>
<path d="M2 0h8v2H2z"/>
</svg>
<span>Documentation</span>
</a> </a>
</li>--}} </li>
<li>
<a class="font-medium text-sm text-amber-500 hover:text-amber-600 dark:hover:text-amber-400 flex items-center py-1 px-3"
href="https://github.com/HolgerHatGarKeineNode/einundzwanzig-nostr" target="_blank" @click="open = false" @focus="open = true"
@focusout="open = false">
<i class="fa-brands fa-github w-3 h-3 fill-current text-amber-500 shrink-0 mr-2"></i>
<span>Github</span>
</a>
</li>
</ul> </ul>
</div> </div>
</div> </div>

View File

@@ -0,0 +1,127 @@
<?php
use Livewire\Volt\Component;
use function Livewire\Volt\computed;
use function Livewire\Volt\mount;
use function Livewire\Volt\state;
use function Laravel\Folio\{middleware};
use function Laravel\Folio\name;
use function Livewire\Volt\{on};
name('changelog');
state(['entries' => []]);
mount(function () {
// Führen Sie den Git-Befehl aus, um die Commit-Historie zu erhalten
$gitLog = shell_exec('git log --pretty=format:"%h|%an|%ad%n%s%n%b" --date=iso --no-merges');
// Parsen Sie die Ausgabe des Git-Befehls
$rawEntries = explode("\n\n", $gitLog);
$entries = [];
$uniqueMessages = [];
foreach ($rawEntries as $entry) {
$lines = explode("\n", $entry);
if (count($lines) < 3) {
continue;
}
$header = explode('|', array_shift($lines));
if (count($header) !== 3) {
continue;
}
[$hash, $author, $date] = $header;
$message = implode("\n", $lines);
// Format the date to a human-readable format
$dateTime = new DateTime($date);
$formattedDate = $dateTime->format('F j, Y, g:i a');
// Überprüfen, ob die Nachricht bereits existiert
if (!in_array($message, $uniqueMessages, true)) {
$uniqueMessages[] = $message;
$entries[] = [
'hash' => $hash,
'message' => $message,
'author' => $author,
'date' => $formattedDate,
];
}
}
$this->entries = $entries;
});
?>
<x-layouts.app title="{{ __('Changelog') }}">
@volt
<div>
<div
class="sm:flex sm:justify-between sm:items-center px-4 sm:px-6 py-8 border-b border-gray-200 dark:border-gray-700/60">
<!-- Left: Title -->
<div class="mb-4 sm:mb-0">
<h1 class="text-2xl md:text-3xl text-gray-800 dark:text-gray-100 font-bold">Changelog</h1>
</div>
<!-- Right: Actions -->
<div class="grid grid-flow-col sm:auto-cols-max justify-start sm:justify-end gap-2">
{{--<!-- Add entry button -->
<button
class="btn bg-gray-900 text-gray-100 hover:bg-gray-800 dark:bg-gray-100 dark:text-gray-800 dark:hover:bg-white">
Add Entry
</button>--}}
</div>
</div>
<div class="px-4 sm:px-6 lg:px-8 py-8 w-full max-w-9xl mx-auto">
<div class="max-w-3xl m-auto">
<!-- Posts -->
<div class="xl:-translate-x-16">
@foreach($entries as $entry)
<article class="pt-6">
<div class="xl:flex">
<div class="w-32 shrink-0">
<div
class="text-xs font-semibold uppercase text-gray-400 dark:text-gray-500 xl:leading-8">
{{ $entry['date'] }}
</div>
</div>
<div class="grow pb-6 border-b border-gray-200 dark:border-gray-700/60">
<header>
<div class="flex flex-nowrap items-center space-x-2 mb-4">
<div class="flex items-center">
<a class="block text-sm font-semibold text-gray-800 dark:text-gray-100"
href="#0">
{{ $entry['author'] }}
</a>
</div>
<div class="text-gray-400 dark:text-gray-600">·</div>
<div>
<div
class="text-xs inline-flex font-medium bg-green-500/20 text-green-700 rounded-full text-center px-2.5 py-1">
{{ $entry['hash'] }}
</div>
</div>
</div>
</header>
<div class="space-y-3 font-mono">
{!! $entry['message'] !!}
</div>
</div>
</div>
</article>
@endforeach
</div>
</div>
</div>
</div>
@endvolt
</x-layouts.app>