Skip to content

Commit 91c770b

Browse files
authored
feat: [LAR-106] add github repositories on the homepage (#262)
1 parent 7efd57d commit 91c770b

File tree

11 files changed

+142
-4
lines changed

11 files changed

+142
-4
lines changed

.env.example

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ MEDIA_DISK=media
7474
FILAMENT_FILESYSTEM_DISK=${MEDIA_DISK}
7575

7676
SENTRY_LARAVEL_DSN=
77-
SENTRY_TRACES_SAMPLE_RATE=
77+
SENTRY_TRACES_SAMPLE_RATE=1.0
7878

7979
NOTCHPAY_PUBLIC_KEY=
8080

@@ -85,3 +85,5 @@ TWITTER_ACCESS_SECRET=your-access-token-secret
8585

8686
GOOGLE_RECAPTCHA_SITE_KEY=your-recaptcha-site-key
8787
GOOGLE_RECAPTCHA_SECRET_KEY=your-secret-key
88+
89+
GITHUB_FINE_GRAINED_TOKEN=
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Actions;
6+
7+
use App\Data\RepositoryData;
8+
use Illuminate\Support\Collection;
9+
use Illuminate\Support\Facades\Cache;
10+
use Illuminate\Support\Facades\Http;
11+
12+
final class GetGithubRepositoriesAction
13+
{
14+
public function __invoke(): Collection
15+
{
16+
$response = Http::withToken(config('services.github.token'))
17+
->get('https://api.github.com/orgs/laravelcm/repos');
18+
19+
if (Cache::has('github-repositories')) {
20+
return Cache::get('github-repositories');
21+
}
22+
23+
$only = [
24+
'laravel-subscriptions',
25+
'livewire-slide-overs',
26+
'abstract-ip-geolocation',
27+
'angular-admin-panel',
28+
];
29+
30+
return Cache::remember(
31+
key: 'github-repositories',
32+
ttl: now()->addWeek(),
33+
callback: fn () => collect($response->json())
34+
->reject(fn (array $value) => $value['fork'] === true || ! in_array($value['name'], $only))
35+
->map(fn (array $data) => RepositoryData::from($data))
36+
);
37+
}
38+
}

app/Data/RepositoryData.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Data;
6+
7+
use Spatie\LaravelData\Data;
8+
9+
final class RepositoryData extends Data
10+
{
11+
public function __construct(
12+
public string $name,
13+
public string $html_url,
14+
public int $stargazers_count = 0,
15+
public int $download = 0,
16+
public ?string $description = null,
17+
) {}
18+
}

config/services.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
'client_id' => env('GITHUB_CLIENT_ID'),
3737
'client_secret' => env('GITHUB_CLIENT_SECRET'),
3838
'redirect' => env('GITHUB_REDIRECT'),
39+
'token' => env('GITHUB_FINE_GRAINED_TOKEN'),
3940
'scopes' => [],
4041
'with' => [],
4142
],

lang/en/global.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,6 @@
103103
'characters' => ':number characters',
104104
'like' => ':count like',
105105
'locale_help' => 'The language in which your content will be available on the site.',
106+
'community_oss_description' => 'The community is also developing open source packages to contribute to the Laravel ecosystem.',
106107

107108
];

lang/fr/global.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,6 @@
103103
'characters' => ':number caractères',
104104
'like' => ':count j\'aime',
105105
'locale_help' => 'La langue dans laquelle votre contenu sera accessible sur le site.',
106+
'community_oss_description' => 'La communauté développe aussi des packages open source pour contribuer à l\'ecosystème de Laravel.',
106107

107108
];
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
@props([
2+
'repository',
3+
])
4+
5+
<li class="group relative flex flex-col items-start isolate">
6+
<div class="relative z-10 flex size-12 items-center justify-center rounded-full bg-white shadow-md shadow-gray-800/5 ring-1 ring-gray-900/5 dark:border dark:border-white/10 dark:bg-gray-800 dark:ring-0">
7+
<x-icon.github class="size-8" aria-hidden="true" />
8+
</div>
9+
<h2 class="mt-6 text-base font-semibold text-gray-800 dark:text-gray-100">
10+
<div class="absolute -inset-x-4 -inset-y-6 z-0 scale-95 bg-white opacity-0 transition group-hover:scale-100 group-hover:opacity-100 sm:-inset-x-6 rounded-2xl dark:bg-gray-800"
11+
></div>
12+
<a href="{{ $repository->html_url }}" target="_blank">
13+
<span class="absolute -inset-x-4 -inset-y-6 z-20 sm:-inset-x-6 rounded-2xl"></span>
14+
<span class="relative inline-flex items-center gap-2 z-10">
15+
{{ $repository->name }}
16+
<span class="inline-flex items-center pointer-events-none rounded-full bg-gray-50 p-1.5 text-gray-500 dark:bg-white/10 dark:text-gray-300">
17+
<svg
18+
class="size-3 transition duration-300 ease-in-out group-hover:rotate-45"
19+
fill="currentColor"
20+
viewBox="0 0 24 24"
21+
aria-hidden="true"
22+
>
23+
<path
24+
d="M20 4h1a1 1 0 00-1-1v1zm-1 12a1 1 0 102 0h-2zM8 3a1 1 0 000 2V3zM3.293 19.293a1 1 0 101.414 1.414l-1.414-1.414zM19 4v12h2V4h-2zm1-1H8v2h12V3zm-.707.293l-16 16 1.414 1.414 16-16-1.414-1.414z"
25+
/>
26+
</svg>
27+
</span>
28+
</span>
29+
</a>
30+
</h2>
31+
<p class="relative z-10 mt-2 text-sm text-gray-600 dark:text-gray-400">
32+
{{ $repository->description }}
33+
</p>
34+
<p class="relative z-10 mt-6 flex text-sm text-gray-400 transition group-hover:text-primary-500 dark:text-gray-200">
35+
<svg viewBox="0 0 24 24" aria-hidden="true" class="size-6 flex-none">
36+
<path
37+
d="M15.712 11.823a.75.75 0 1 0 1.06 1.06l-1.06-1.06Zm-4.95 1.768a.75.75 0 0 0 1.06-1.06l-1.06 1.06Zm-2.475-1.414a.75.75 0 1 0-1.06-1.06l1.06 1.06Zm4.95-1.768a.75.75 0 1 0-1.06 1.06l1.06-1.06Zm3.359.53-.884.884 1.06 1.06.885-.883-1.061-1.06Zm-4.95-2.12 1.414-1.415L12 6.344l-1.415 1.413 1.061 1.061Zm0 3.535a2.5 2.5 0 0 1 0-3.536l-1.06-1.06a4 4 0 0 0 0 5.656l1.06-1.06Zm4.95-4.95a2.5 2.5 0 0 1 0 3.535L17.656 12a4 4 0 0 0 0-5.657l-1.06 1.06Zm1.06-1.06a4 4 0 0 0-5.656 0l1.06 1.06a2.5 2.5 0 0 1 3.536 0l1.06-1.06Zm-7.07 7.07.176.177 1.06-1.06-.176-.177-1.06 1.06Zm-3.183-.353.884-.884-1.06-1.06-.884.883 1.06 1.06Zm4.95 2.121-1.414 1.414 1.06 1.06 1.415-1.413-1.06-1.061Zm0-3.536a2.5 2.5 0 0 1 0 3.536l1.06 1.06a4 4 0 0 0 0-5.656l-1.06 1.06Zm-4.95 4.95a2.5 2.5 0 0 1 0-3.535L6.344 12a4 4 0 0 0 0 5.656l1.06-1.06Zm-1.06 1.06a4 4 0 0 0 5.657 0l-1.061-1.06a2.5 2.5 0 0 1-3.535 0l-1.061 1.06Zm7.07-7.07-.176-.177-1.06 1.06.176.178 1.06-1.061Z"
38+
fill="currentColor"
39+
/>
40+
</svg>
41+
<span class="ml-2">github.com</span>
42+
</p>
43+
</li>

resources/views/home.blade.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class="inline-flex items-center rounded-full bg-green-700 p-1 pr-2 text-white sm
4646
</div>
4747

4848
<x-container>
49-
<div class="divide-y divide-skin-base">
49+
<div class="divide-y divide-gray-200 dark:divide-white/10">
5050
<div class="py-12 lg:py-20">
5151
<x-section-header
5252
:title="__('pages/home.popular_posts.title')"
@@ -251,4 +251,6 @@ class="absolute inset-x-0 top-0 h-32 bg-gradient-to-b from-black xl:inset-y-0 xl
251251
</div>
252252
</div>
253253
</div>
254+
255+
<livewire:components.github-repositories />
254256
</x-app-layout>

resources/views/livewire/components/discussion/comment.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class="text-xs capitalize leading-5 text-gray-500 dark:text-gray-400"
2828
@can('delete', $comment)
2929
<div class="mt-1 flex sm:mt-0">
3030
<span class="hidden font-medium text-gray-500 dark:text-gray-400 sm:inline-block">·</span>
31-
<div class="flex items-center space-x-2 divide-x divide-skin-base pl-2">
31+
<div class="flex items-center space-x-2 divide-x divide-gray-200 dark:divide-white/10 pl-2">
3232
<button
3333
type="button"
3434
wire:click="delete"
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use App\Actions\GetGithubRepositoriesAction;
6+
7+
use function Livewire\Volt\{computed};
8+
9+
$repositories = computed(fn () => app()->call(GetGithubRepositoriesAction::class));
10+
11+
?>
12+
13+
<x-container class="relative py-12 space-y-12 lg:py-20 lg:space-y-16">
14+
<div>
15+
<div class="shrink-0 flex items-center gap-2">
16+
<span
17+
class="inline-flex items-center justify-center rounded-full p-2 ring-1 ring-black/5 dark:ring-white/10"
18+
>
19+
<x-icon.tags.open-source class="size-6" aria-hidden="true" />
20+
</span>
21+
<h2 class="font-heading font-bold text-zinc-900 text-2xl dark:text-white lg:text-3xl">Open source</h2>
22+
</div>
23+
<p class="mt-4 max-w-2xl text-gray-500 dark:text-gray-400">
24+
{{ __('global.community_oss_description') }}
25+
</p>
26+
</div>
27+
<div class="grid grid-cols-1 gap-x-12 gap-y-16 sm:grid-cols-2 lg:grid-cols-3">
28+
@foreach($this->repositories->sortByDesc('stargazers_count') as $repository)
29+
<x-repository :repository="$repository" />
30+
@endforeach
31+
</div>
32+
</x-container>

resources/views/livewire/markdown-x.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1807,7 +1807,7 @@ function (e) {
18071807
window.addEventListener('markdown-x-peoples-results', (event) => {
18081808
let peoplesResults = event.detail.results
18091809
1810-
let peopleContents = `<ul role="list" class="divide-y divide-skin-base">`
1810+
let peopleContents = `<ul role="list" class="divide-y divide-gray-200 dark:divide-white/10">`
18111811
for (let i = 0; i < peoplesResults.length; i++) {
18121812
peopleContents += `<li class="p-3 group hover:bg-skin-primary">
18131813
<button type="button" onclick="addAdditionalContent('@${peoplesResults[i]['username']}', '${event.detail.key}')" class="flex items-center w-full">

0 commit comments

Comments
 (0)