Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
f146d73
Add GitHub Retrieved Release Notes Page
Mar 24, 2025
164d159
Add GitHub Release Object with formatting for release notes
Mar 24, 2025
c167104
Take 10 latest
Mar 25, 2025
2cca960
Appease pint
Mar 25, 2025
7f76946
Update docs
simonhamp Mar 25, 2025
81baf6b
✨ Add lazy loading to images and improve text formatting in welcome view
HassanZahirnia Mar 25, 2025
866ddeb
✨ Enhance welcome view with animated SVG and update image dimensions
HassanZahirnia Mar 25, 2025
bc0350d
✨ Revamp video section with animated play button and improved layout
HassanZahirnia Mar 25, 2025
6507fe9
✨ Update image dimensions and improve layout in welcome view
HassanZahirnia Mar 25, 2025
f2c8005
✨ Update contributor images scaling and enhance layout in welcome view
HassanZahirnia Mar 25, 2025
ca2e074
✨ Replace SVG play button with reusable component and improve layout …
HassanZahirnia Mar 25, 2025
91e9b8a
✨ Refactor footer and welcome views for improved layout and responsiv…
HassanZahirnia Mar 25, 2025
92a2973
✨ Update primary color for DocSearch and add rounded corners to the form
HassanZahirnia Mar 25, 2025
3e18722
✨ Adjust gap spacing in navigation bar for improved layout consistency
HassanZahirnia Mar 25, 2025
c5aa15f
✨ Update theme toggle component styles for improved consistency and r…
HassanZahirnia Mar 25, 2025
34945aa
✨ Improve pricing warning gap with its text
HassanZahirnia Mar 25, 2025
4c39dec
✨ Refactor EAP banner for improved text animation and layout
HassanZahirnia Mar 25, 2025
9345e64
✨ Add new color palette and update components for dark mode consistency
HassanZahirnia Mar 25, 2025
251a200
✨ Update electronGitHubVersion sharing logic for production and devel…
HassanZahirnia Mar 25, 2025
07fc93d
✨ Update alert-beta component background opacity for improved visibility
HassanZahirnia Mar 25, 2025
a06385d
✨ Update sidebar navigation styles for improved responsiveness and da…
HassanZahirnia Mar 25, 2025
6037ed6
✨ Add custom scrollbar styles for light and dark themes
HassanZahirnia Mar 25, 2025
4c5d221
✨ Update spacing and styling for sponsors section in TOC component
HassanZahirnia Mar 25, 2025
ec14cbf
✨ Update dark mode styles across various components for improved cons…
HassanZahirnia Mar 25, 2025
834a067
✨ Update sidebar-left-navigation component styles for improved layout…
HassanZahirnia Mar 25, 2025
7fddbaf
✨ Update layout and styling for various components to enhance respons…
HassanZahirnia Mar 25, 2025
0c5b16a
✨ Refactor shared view variable registration for cleaner code and imp…
HassanZahirnia Mar 25, 2025
e009b40
✨ Update alignment of text in welcome view for improved layout consis…
HassanZahirnia Mar 25, 2025
11d8dd7
Update support-policy.md
olivsinz Mar 26, 2025
62a7711
✨ Update navigation bar version badge styles for improved visibility …
HassanZahirnia Mar 25, 2025
be87d83
✨ Update layout classes for improved responsiveness and consistency a…
HassanZahirnia Mar 25, 2025
079178d
✨ Update sponsor link styles for improved consistency and layout
HassanZahirnia Mar 26, 2025
c1ec5f4
✨ Update footer links to reflect new X.com URLs for improved accuracy
HassanZahirnia Mar 26, 2025
c46a4de
✨ Update Borah logo dimensions for improved display and adjust styles…
HassanZahirnia Mar 26, 2025
9579b62
✨ Update featured sponsor images with specified dimensions for improv…
HassanZahirnia Mar 26, 2025
0c1b6e9
✨ Improve sponsor images
HassanZahirnia Mar 26, 2025
bc0a312
✨ Integrate DocSearch for improved site search functionality
HassanZahirnia Mar 26, 2025
807bc14
✨ Update responsive breakpoints for improved layout on larger screens
HassanZahirnia Mar 26, 2025
bad6cc6
✨ Adjust padding and text alignment for improved layout in documentat…
HassanZahirnia Mar 26, 2025
97c1e7b
✨ Refactor DocSearch button styles for improved responsiveness and ad…
HassanZahirnia Mar 26, 2025
e88e587
Fix config
simonhamp Mar 26, 2025
d690571
Update Release Note Markdown processing to reduce PR link sizes.
PeteBishwhip Mar 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ public function boot(): void

private function registerSharedViewVariables(): void
{
View::share('electronGitHubVersion', GitHub::electron()->latestVersion());
View::share('electronGitHubVersion', app()->environment('production')
? GitHub::electron()->latestVersion()
: 'dev'
);
View::share('discordLink', 'https://discord.gg/X62tWNStZK');
View::share('bskyLink', 'https://bsky.app/profile/nativephp.bsky.social');
View::share('openCollectiveLink', 'https://opencollective.com/nativephp');
Expand Down
36 changes: 29 additions & 7 deletions app/Support/GitHub.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace App\Support;

use App\Support\GitHub\Release;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Http;

Expand All @@ -27,18 +29,25 @@ public static function laravel(): static

public function latestVersion()
{
$version = Cache::remember(
$release = Cache::remember(
$this->getCacheKey('latest-version'),
now()->addHour(),
function () {
return $this->fetchLatestVersion();
}
fn () => $this->fetchLatestVersion()
);

return $version['name'] ?? 'Unknown';
return $release?->name ?? 'Unknown';
}

private function fetchLatestVersion()
public function releases(): Collection
{
return Cache::remember(
$this->getCacheKey('releases'),
now()->addHour(),
fn () => $this->fetchReleases()
) ?? collect();
}

private function fetchLatestVersion(): ?Release
{
// Make a request to GitHub
$response = Http::get('https://api.github.com/repos/'.$this->package.'/releases/latest');
Expand All @@ -48,11 +57,24 @@ private function fetchLatestVersion()
return null;
}

return $response->json();
return new Release($response->json());
}

private function getCacheKey(string $string): string
{
return sprintf('%s-%s', $this->package, $string);
}

private function fetchReleases(): ?Collection
{
// Make a request to GitHub
$response = Http::get('https://api.github.com/repos/'.$this->package.'/releases');

// Check if the request was successful
if ($response->failed()) {
return collect();
}

return collect($response->json())->map(fn (array $release) => new Release($release));
}
}
92 changes: 92 additions & 0 deletions app/Support/GitHub/Release.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php

namespace App\Support\GitHub;

/**
* @property string $url
* @property string $assets_url
* @property string $upload_url
* @property string $html_url
* @property int $id
* @property array $author
* @property string $node_id
* @property string $tag_name
* @property string $target_commitish
* @property string $name
* @property bool $draft
* @property bool $prerelease
* @property string $created_at
* @property string $published_at
* @property array $assets
* @property string $tarball_url
* @property string $zipball_url
* @property string $body
* @property int $mentions_count
*/
class Release
{
private bool $withUserLinks = true;

private bool $convertLinks = true;

public function __construct(
private array $data
) {
//
}

public function __get(string $name)
{
return $this->data[$name] ?? null;
}

public function __isset(string $name): bool
{
return isset($this->data[$name]);
}

public function getBodyForMarkdown(): string
{
$body = $this->body;

// Convert any URLs to Markdown links
if ($this->convertLinks) {
$body = preg_replace(
'/https?:\/\/[^\s]+\/pull\/(\d+)/',
'[#$1]($0)',
$body
);

$body = preg_replace(
'/(https?:\/\/(?![^\s]+\/pull\/\d+)[^\s]+)/',
'[$1]($1)',
$body
);
}

// Change any @ tags to markdown links to GitHub
if ($this->withUserLinks) {
$body = preg_replace(
'/@([a-zA-Z0-9_]+)/',
'[@$1](https://github.com/$1)',
$body
);
}

return preg_replace('/^#/m', '##', $body);
}

public function withoutUserLinks(bool $withoutUserLinks = true): static
{
$this->withUserLinks = ! $withoutUserLinks;

return $this;
}

public function withoutLinkConversion(bool $convertLinks = true): static
{
$this->convertLinks = ! $convertLinks;

return $this;
}
}
Loading