Skip to content

Commit

Permalink
👍 Test Disabled frontend support
Browse files Browse the repository at this point in the history
  • Loading branch information
juzaweb committed Aug 5, 2023
1 parent 734de2f commit e3f93e5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ public function index(Request $request, string $theme = null): View
$themes = $this->themeRepository->all();
$directories = $this->getThemeTree("{$themePath}/views", convert_linux_path($themePath));

$file = $this->getCurrentFile($request);
$path = Crypt::decryptString($file);
if (!file_exists("{$themePath}/{$path}")) {
return abort(404);
}
$file = $this->getCurrentFile($request, $themePath);
//$path = Crypt::decryptString($file);

/*if (!file_exists("{$themePath}/{$path}")) {
abort(404, "Cannot find file {$path}");
}*/

return view(
'cms::backend.appearance.editor.index',
Expand Down Expand Up @@ -178,11 +179,27 @@ protected function getLanguageFile(string $file): string
};
}

protected function getCurrentFile(Request $request): string
protected function getCurrentFile(Request $request, string $themePath): string
{
return $request->get(
'file',
Crypt::encryptString('views/index.twig')
Crypt::encryptString($this->findIndexFile($themePath))
);
}

protected function findIndexFile(string $themePath): ?string
{
// Twig theme
if (File::exists("{$themePath}/views/index.twig")) {
return 'views/index.twig';
}

// Blade theme
if (File::exists("{$themePath}/views/index.blade.php")) {
return 'views/index.blade.php';
}

// Inertia theme
return 'views/index.tsx';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@

<select id="change-theme" class="form-control mt-2">
@foreach($themes as $name => $info)
<option value="{{ $name }}" @if($name == $theme) selected @endif>{{ $info->get('title') }}</option>
<option value="{{ $name }}" @if($name == $theme) selected @endif>
{{ $info->get('title') }}
</option>
@endforeach
</select>

Expand Down

0 comments on commit e3f93e5

Please sign in to comment.