Skip to content

Commit 4c69127

Browse files
committed
NativePHP for iOS
commit 98a6168ff79a5ac85027775bfd274b2e34199ebc Merge: 115fd50 9838f1d Author: Simon Hamp <[email protected]> Date: Sun Feb 2 10:55:16 2025 +0100 Merge branch 'mobile-documentation' into mobile-documentation-simon commit 115fd50819f5583046709f6f355f75978324da27 Author: Simon Hamp <[email protected]> Date: Sat Feb 1 21:31:11 2025 +0000 Notifications commit 912081696dac908ed686b45075704448b6efa562 Author: Simon Hamp <[email protected]> Date: Sat Feb 1 21:28:31 2025 +0000 Dialogs commit 1a62132db923e3671e71f933b08c59d7d1b24949 Author: Simon Hamp <[email protected]> Date: Sat Feb 1 21:20:10 2025 +0000 Update desktop docs commit 21b83f3a77ebf7c80f3e527b5d135b7843265536 Author: Simon Hamp <[email protected]> Date: Sat Feb 1 21:19:54 2025 +0000 Add mobile docs commit 9838f1d Author: Eser DENIZ <[email protected]> Date: Sat Feb 1 13:35:54 2025 +0100 fix: bug very large screen commit e4154c6 Author: Eser DENIZ <[email protected]> Date: Mon Jan 27 17:06:08 2025 +0100 refactor: linting commit 4e55fa4 Author: Eser DENIZ <[email protected]> Date: Mon Jan 27 17:05:43 2025 +0100 feat: seo title commit ddcbbfa Author: Eser DENIZ <[email protected]> Date: Mon Jan 27 17:00:21 2025 +0100 feat: separating platforms into two distinct folders commit 33d61ff Author: Eser DENIZ <[email protected]> Date: Sun Jan 26 23:48:35 2025 +0100 feat: mobile/desktop docs
1 parent 58beb37 commit 4c69127

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+578
-53
lines changed

app/Http/Controllers/ShowDocumentationController.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,42 +20,42 @@
2020

2121
class ShowDocumentationController extends Controller
2222
{
23-
public function __invoke(Request $request, string $version, ?string $page = null)
23+
public function __invoke(Request $request, string $platform, string $version, ?string $page = null)
2424
{
2525
if (config('app.env') === 'local') {
2626
Cache::flush();
2727
}
2828

29-
abort_unless(is_dir(resource_path('views/docs/'.$version)), 404);
29+
abort_unless(is_dir(resource_path('views/docs/'.$platform.'/'.$version)), 404);
3030

3131
session(['viewing_docs_version' => $version]);
32+
session(['viewing_docs_platform' => $platform]);
3233

33-
$navigation = Cache::remember("docs_nav_{$version}", now()->addDay(), function () use ($version) {
34-
return $this->getNavigation($version);
35-
});
34+
$navigation = Cache::remember("docs_nav_{$platform}_{$version}", now()->addDay(),
35+
fn () => $this->getNavigation($platform, $version)
36+
);
3637

3738
if (is_null($page)) {
3839
return $this->redirectToFirstNavigationPage($navigation);
3940
}
4041

4142
try {
42-
$pageProperties = Cache::remember("docs_{$version}_{$page}", now()->addDay(),
43-
function () use ($version, $page) {
44-
return $this->getPageProperties($version, $page);
45-
});
43+
$pageProperties = Cache::remember("docs_{$platform}_{$version}_{$page}", now()->addDay(),
44+
fn () => $this->getPageProperties($platform, $version, $page)
45+
);
4646
} catch (InvalidArgumentException $e) {
4747
return $this->redirectToFirstNavigationPage($navigation, $page);
4848
}
4949

50-
SEOTools::setTitle($pageProperties['title']);
50+
SEOTools::setTitle($pageProperties['title'].' - NativePHP '.$platform.' v'.$version);
5151
SEOTools::setDescription(Arr::exists($pageProperties, 'description') ? $pageProperties['description'] : '');
5252

5353
return view('docs.index')->with($pageProperties);
5454
}
5555

56-
protected function getPageProperties($version, $page = null): array
56+
protected function getPageProperties($platform, $version, $page = null): array
5757
{
58-
$markdownFileName = $version.'.'.($page ?? 'index');
58+
$markdownFileName = $platform.'.'.$version.'.'.($page ?? 'index');
5959

6060
$content = $this->getMarkdownView("docs.{$markdownFileName}", [
6161
'user' => auth()->user(),
@@ -64,16 +64,17 @@ protected function getPageProperties($version, $page = null): array
6464
$document = YamlFrontMatter::parse($content);
6565
$pageProperties = $document->matter();
6666

67-
$versionProperties = YamlFrontMatter::parseFile(resource_path("views/docs/{$version}/_index.md"));
67+
$versionProperties = YamlFrontMatter::parseFile(resource_path("views/docs/{$platform}/{$version}/_index.md"));
6868
$pageProperties = array_merge($pageProperties, $versionProperties->matter());
6969

70+
$pageProperties['platform'] = $platform;
7071
$pageProperties['version'] = $version;
7172
$pageProperties['pagePath'] = request()->path();
7273

73-
$pageProperties['content'] = CommonMark::convertToHtml($document->body(), $version);
74+
$pageProperties['content'] = CommonMark::convertToHtml($document->body());
7475
$pageProperties['tableOfContents'] = $this->extractTableOfContents($document->body());
7576

76-
$navigation = $this->getNavigation($version);
77+
$navigation = $this->getNavigation($platform, $version);
7778
$pageProperties['navigation'] = Menu::build($navigation, function (Menu $menu, $nav) {
7879
if (array_key_exists('path', $nav)) {
7980
$menu->link($nav['path'], $nav['title']);
@@ -110,7 +111,7 @@ protected function getPageProperties($version, $page = null): array
110111
->setActive(\request()->path())
111112
->__toString();
112113

113-
$pageProperties['editUrl'] = "https://github.com/NativePHP/nativephp.com/tree/main/resources/views/docs/{$version}/{$page}.md";
114+
$pageProperties['editUrl'] = "https://github.com/NativePHP/nativephp.com/tree/main/resources/views/docs/{$platform}/{$version}/{$page}.md";
114115

115116
// Find the next & previous page in the navigation
116117
$pageProperties['nextPage'] = null;
@@ -149,10 +150,10 @@ protected function getPageProperties($version, $page = null): array
149150
return $pageProperties;
150151
}
151152

152-
protected function getNavigation(string $version): array
153+
protected function getNavigation(string $platform, string $version): array
153154
{
154155
$basePath = resource_path('views');
155-
$path = "$basePath/docs/$version";
156+
$path = "$basePath/docs/$platform/$version";
156157

157158
$mainNavigation = (new Finder)
158159
->files()
@@ -238,7 +239,6 @@ protected function extractTableOfContents(string $document): array
238239
// Only search for level 2 and 3 headings.
239240
return ! Str::startsWith($line, '## ') && ! Str::startsWith($line, '### ');
240241
})
241-
242242
->map(function (string $line) {
243243
return [
244244
'level' => strlen(trim(Str::before($line, '# '))) + 1,
@@ -259,9 +259,9 @@ protected function extractTitle(string $document): string
259259
return $matches[1] ?? '';
260260
}
261261

262-
protected function markdownViewExists($version, $page): bool
262+
protected function markdownViewExists($platform, $version, $page): bool
263263
{
264-
$markdownFileName = $version.'.'.($page ?? 'index');
264+
$markdownFileName = $platform.'.'.$version.'.'.($page ?? 'index');
265265

266266
try {
267267
$this->getMarkdownView("docs.{$markdownFileName}", [

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<svg {{$attributes}} xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
2+
<path stroke-linecap="round" stroke-linejoin="round" d="M9 17.25v1.007a3 3 0 0 1-.879 2.122L7.5 21h9l-.621-.621A3 3 0 0 1 15 18.257V17.25m6-12V15a2.25 2.25 0 0 1-2.25 2.25H5.25A2.25 2.25 0 0 1 3 15V5.25m18 0A2.25 2.25 0 0 0 18.75 3H5.25A2.25 2.25 0 0 0 3 5.25m18 0V12a2.25 2.25 0 0 1-2.25 2.25H5.25A2.25 2.25 0 0 1 3 12V5.25" />
3+
</svg>
4+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<svg {{$attributes}} xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-monitor-smartphone"><path d="M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8"/><path d="M10 19v-3.96 3.15"/><path d="M7 19h5"/><rect width="6" height="10" x="16" y="12" rx="2"/></svg>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<svg {{$attributes}} xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-tablet-smartphone"><rect width="10" height="14" x="3" y="8" rx="2"/><path d="M5 4a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2h-2.4"/><path d="M8 18h.01"/></svg>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@php
2+
$isMobile = request()->is('docs/mobile/*');
3+
$href= $isMobile ? '/docs/desktop/1' : '/docs/mobile/1';
4+
@endphp
5+
6+
<div {{ $attributes->class(['mb-6 p-3 text-sm space-y-2.5 rounded-md
7+
text-gray-600 bg-gray-50/85 border border-gray-200
8+
dark:text-gray-300 dark:bg-gray-800 dark:border-none
9+
']) }}>
10+
<div>You're reading the documentation of NativePHP for {{ $isMobile? 'mobile' : 'desktop' }}.</div>
11+
<x-link-subtle class="flex w-full gap-2 items-center" href="{{ $href }}">
12+
@if($isMobile)
13+
<x-icons.computer-desktop class="size-4"/>
14+
Switch to desktop
15+
@else
16+
<x-icons.device-mobile-phone class="size-4"/>
17+
Switch to mobile
18+
@endif
19+
20+
</x-link-subtle>
21+
</div>

resources/views/components/sidebar-left-navigation.blade.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
border-r border-[#00aaa6] border-opacity-10 dark:border-gray-800
1212
dark:text-gray-200
1313
">
14-
<nav class="flex flex-col flex-1">
14+
<nav class="flex flex-col flex-1 relative">
15+
<x-platform-switcher/>
16+
1517
{!! $slot !!}
1618
</nav>
1719
</div>
@@ -24,7 +26,10 @@
2426
x-transition:leave="transition ease-in duration-150"
2527
x-transition:leave-start="translate-y-0 opacity-100"
2628
x-transition:leave-end="translate-y-1 opacity-0"
27-
class="fixed top-12 left-0 z-40 w-full h-screen pt-10 pb-16 overflow-y-auto bg-white dark:bg-gray-700 mt-2 px-4 border-b border-[#00aaa6] border-opacity-50 dark:border-opacity-90">
29+
class="fixed top-12 left-0 z-40 w-full h-screen pt-10 pb-16 overflow-y-auto bg-white dark:bg-gray-700 mt-2 px-4 border-b border-[#00aaa6] border-opacity-50 dark:border-opacity-90"
30+
>
31+
32+
<x-platform-switcher/>
2833

2934

3035
{!! $slot !!}

0 commit comments

Comments
 (0)