Skip to content

Commit e47e1a5

Browse files
author
Florian Strauß
committed
“wip”
1 parent 4a85dc4 commit e47e1a5

File tree

3 files changed

+116
-36
lines changed

3 files changed

+116
-36
lines changed

resources/views/index.blade.php

Lines changed: 92 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,48 +6,105 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<meta http-equiv="X-UA-Compatible" content="ie=edge">
88
<title>{{ env('APP_NAME') }} - Changelog</title>
9-
<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet">
10-
<link rel="stylesheet" href="https://unpkg.com/@tailwindcss/[email protected]/dist/typography.min.css" />
9+
<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">
10+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tailwindcss/[email protected]/dist/typography.min.css" />
1111
</head>
1212

1313
<body>
14-
<div id="__next">
15-
<div class="antialiased text-gray-900">
16-
<div class="px-4 py-10 max-w-3xl mx-auto sm:px-6 sm:py-12 lg:max-w-4xl lg:py-16 lg:px-8 xl:max-w-6xl">
17-
<article>
18-
<div class="space-y-10 sm:space-y-12 lg:space-y-20 xl:space-y-24">
19-
<div class="space-y-10 sm:space-y-0 sm:flex sm:items-center sm:justify-between">
20-
<h1 class="text-4xl font-bold">{{ env('APP_NAME') }} - Changelog</h1>
21-
</div>
22-
<div class="prose prose-lg mx-auto">
23-
@foreach($changelog as $date => $group)
24-
<h2>{{ $date }}</h2>
25-
@foreach($group as $groupName => $commits)
26-
<h3>{{ $groupName }}</h3>
27-
28-
<ul>
29-
@foreach($commits as $commit)
30-
<li><strong>{{ $commit['scope'] }}</strong>: {{ $commit['subject'] }}</li>
31-
@endforeach
32-
</ul>
33-
@endforeach
34-
@endforeach
35-
36-
37-
</div>
38-
@if($history)
39-
<div class="space-y-10 sm:space-y-0 sm:flex sm:items-center sm:justify-between">
40-
<h1 class="text-4xl font-bold">History</h1>
41-
</div>
42-
<div class="prose mx-auto">
43-
{!! $history !!}
44-
</div>
45-
@endif
14+
15+
<div class="min-h-screen bg-gray-100">
16+
<header class="bg-white shadow-sm">
17+
<div class="max-w-7xl mx-auto py-4 px-4 sm:px-6 lg:px-8">
18+
<h1 class="text-lg leading-6 font-semibold text-gray-900">
19+
<h1 class="text-4xl font-bold">{{ env('APP_NAME') }} - Changelog</h1>
20+
</h1>
21+
</div>
22+
</header>
23+
<div class="py-6">
24+
<div class="max-w-3xl mx-auto sm:px-6 lg:max-w-7xl lg:px-8 lg:grid lg:grid-cols-12 lg:gap-8">
25+
26+
<main class="lg:col-span-8">
27+
<div class="bg-white rounded-lg shadow px-5 py-6 sm:px-6">
28+
<article>
29+
<div class="space-y-10 sm:space-y-12 lg:space-y-20 xl:space-y-24">
30+
31+
<div class="prose prose-lg mx-auto">
32+
@foreach($changelog as $date => $group)
33+
<h2>{{ $date }}</h2>
34+
@foreach($group as $groupName => $commits)
35+
<h3>{{ $groupName }}</h3>
36+
37+
<ul>
38+
@foreach($commits as $commit)
39+
<li><strong>{{ $commit['scope'] }}</strong>: {{ $commit['subject'] }}</li>
40+
@endforeach
41+
</ul>
42+
@endforeach
43+
@endforeach
44+
45+
46+
</div>
47+
@if($history)
48+
<div class="space-y-10 sm:space-y-0 sm:flex sm:items-center sm:justify-between">
49+
<h1 class="text-4xl font-bold">History</h1>
50+
</div>
51+
<div class="prose mx-auto">
52+
{!! $history !!}
53+
</div>
54+
@endif
55+
</div>
56+
</article>
57+
</div>
58+
59+
</main>
60+
<aside class="hidden lg:block lg:col-span-4">
61+
<div class="sticky top-6 space-y-4">
62+
<section aria-labelledby="announcements-title">
63+
<div class="rounded-lg bg-white overflow-hidden shadow">
64+
<div class="p-6">
65+
<h2 class="text-lg font-medium text-gray-900" id="announcements-title">
66+
Releases
67+
</h2>
68+
<div class="mt-6">
69+
<ul class="-my-5 divide-y divide-gray-200">
70+
@foreach($releases as $release)
71+
<li class="py-5">
72+
<div class="relative ">
73+
<h3 class="text-sm font-semibold text-gray-800">
74+
75+
<!-- Extend touch target to entire panel -->
76+
77+
{{ $release['name'] }}
78+
79+
80+
</h3>
81+
<time datetime="2021-01-27T16:35"
82+
class="flex-shrink-0 whitespace-nowrap text-sm text-gray-500">{{ $release['created_at'] }}</time>
83+
<div class="mt-1 text-sm text-gray-600 prose">
84+
{!! $release['body'] !!}
85+
</div>
86+
</div>
87+
</li>
88+
@endforeach
89+
90+
91+
92+
93+
94+
</ul>
95+
</div>
96+
97+
</div>
98+
</div>
99+
</section>
100+
101+
46102
</div>
47-
</article>
103+
</aside>
48104
</div>
49105
</div>
50106
</div>
107+
51108
</body>
52109

53110
</html>

src/Http/Controllers/ChangelogController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ class ChangelogController
1010
public function __invoke(Request $request)
1111
{
1212
$changelog = \LaravelGithubChangelog::changelog();
13+
$releases = \LaravelGithubChangelog::releases();
1314
$history = null;
1415
if (file_exists(base_path('HISTORY.md'))) {
1516
$history = Markdown::parse(file_get_contents(base_path('HISTORY.md')))->toHtml();
1617
}
17-
return view('github-changelog::index', compact('changelog', 'history'));
18+
return view('github-changelog::index', compact('changelog', 'history', 'releases'));
1819
}
1920
}

src/LaravelGithubChangelog.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,32 @@
22

33
namespace Orlyapps\LaravelGithubChangelog;
44

5+
use Carbon\Carbon;
6+
use Illuminate\Mail\Markdown;
57
use Illuminate\Support\Facades\Http;
68

79
class LaravelGithubChangelog
810
{
11+
public function releases()
12+
{
13+
return collect(
14+
Http::withHeaders(['Authorization' => 'token ' . config('github-changelog.github.token')])
15+
->get(
16+
'https://api.github.com/repos/' .
17+
config('github-changelog.github.user') . '/' .
18+
config('github-changelog.github.repo') . '/releases'
19+
)
20+
->json()
21+
)->map(function ($release) {
22+
return [
23+
'name' => $release['name'],
24+
'created_at' => Carbon::parse($release['created_at'])->diffForHumans(),
25+
'body' => Markdown::parse($release['body'])->toHtml(),
26+
];
27+
})
28+
->filter(fn ($release) => !empty($release['name']));
29+
}
30+
931
public function changelog()
1032
{
1133
return collect(

0 commit comments

Comments
 (0)