blob: e66a6eb5fd9b408e9399fbe79fe619102834a04a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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>•</td>
<td>{{ formatRelativeTime($date) }}</td>
<td><a href="{{ $commit->url }}">{{ $commit->message }}</a></td>
</tr>
@php $count++ @endphp
@endforeach
|