Add recent site updates (from git)

This commit is contained in:
floppydiskette 2023-07-12 01:16:52 +01:00
parent e0e179fa79
commit cb4a1f179b
No known key found for this signature in database
3 changed files with 56 additions and 0 deletions

View file

@ -318,3 +318,8 @@ div.footer {
text-align: center; text-align: center;
margin-bottom: 5px; margin-bottom: 5px;
} }
table.commits tr td {
border: none;
padding-right: 5px;
}

View file

@ -0,0 +1,48 @@
@php
$api_root = app('config')->get('app')['api_root'];
$commits = json_decode(file_get_contents($api_root.'/gitdata'));
$count = 0;
function formatRelativeTime(DateTime $dateTime) {
$currentTimestamp = time();
$dateTimeTimestamp = $dateTime->getTimestamp();
$difference = $currentTimestamp - $dateTimeTimestamp;
if ($difference < 60) {
return "just now";
} elseif ($difference < 3600) {
$minutes = floor($difference / 60);
$suffix = ($minutes > 1) ? "s" : "";
return $minutes . " minute" . $suffix . " ago";
} elseif ($difference < 86400) {
$hours = floor($difference / 3600);
$suffix = ($hours > 1) ? "s" : "";
return $hours . " hour" . $suffix . " ago";
} elseif ($difference < 604800) {
$days = floor($difference / 86400);
$suffix = ($days > 1) ? "s" : "";
return $days . " day" . $suffix . " ago";
} else {
return $dateTime->format('Y-m-d H:i:s'); // Fallback to a specific format if desired
}
}
@endphp
<h1>Recent Site Updates</h1>
<table class="commits">
@foreach ($commits as $commit)
@if ($count >= 5)
</table>
@break
@endif
@php
$date = DateTime::createFromFormat("Y-m-d\TH:i:s\Z", $commit->author->date)
@endphp
<tr>
<td>&bullet;</td>
<td>{{ formatRelativeTime($date) }}</td>
<td><a href="{{ $commit->url }}">{{ $commit->message }}</a></td>
</tr>
@php $count++ @endphp
@endforeach

View file

@ -19,6 +19,9 @@
<!-- WeatherData --> <!-- WeatherData -->
@include('components.weather') @include('components.weather')
<!-- Site Updates -->
@include('components.git')
<h1>Contact</h1> <h1>Contact</h1>
<p><strong>Mail</strong>:&nbsp;<a href="mailto:contact@diskfloppy.me">contact@diskfloppy.me</a><br/> <p><strong>Mail</strong>:&nbsp;<a href="mailto:contact@diskfloppy.me">contact@diskfloppy.me</a><br/>
<strong>IRC</strong>:&nbsp;&nbsp;<a href="https://r-type.ca/page.php?id=1034">floppydisk @ r-type</a><br/> <strong>IRC</strong>:&nbsp;&nbsp;<a href="https://r-type.ca/page.php?id=1034">floppydisk @ r-type</a><br/>