19 Commits
Author SHA1 Message Date
Mark Gregory 976f161550 fix: preserve empty Laravel views directory for deployment 2026-10-20 10:57:19 +01:00
Mark Gregory 1424133b0a added theme support 2026-10-20 10:55:54 +01:00
Mark Gregory 835008e99d added theme support 2026-10-20 10:53:10 +01:00
Mark Gregory e926301c12 added theme support 2026-10-20 10:46:10 +01:00
Mark Gregory 1f17a98158 added theme support 2026-10-20 10:44:42 +01:00
Mark Gregory a0dc4787ab added theme support 2026-10-20 10:41:40 +01:00
Mark Gregory 8854604593 added theme support 2026-10-20 10:40:24 +01:00
Mark Gregory b159b2e16c added theme support 2026-10-20 10:38:03 +01:00
Mark Gregory c198374d49 added theme support 2026-10-20 10:37:13 +01:00
Mark Gregory 63582531e3 added theme support 2026-10-20 10:29:35 +01:00
Mark Gregory c5353d0351 added theme support 2026-10-20 10:27:30 +01:00
Mark Gregory f0e31aad6b added theme support 2026-10-20 10:23:23 +01:00
Mark Gregory 1d70a9c8cf added theme support 2026-10-20 10:22:21 +01:00
Mark Gregory 42c074d966 added theme support 2026-10-20 10:19:18 +01:00
Mark Gregory c5f6871e8d download fixes 2026-10-20 10:17:23 +01:00
Mark Gregory b02d4259c3 download fixes 2026-10-20 10:16:48 +01:00
Mark Gregory 3f54289a9d download fixes 2026-10-20 10:10:34 +01:00
Mark Gregory 5d0faef236 download fixes 2026-10-20 10:10:06 +01:00
Mark Gregory f8e1170d5f download fixes 2026-10-20 10:06:04 +01:00
74 changed files with 1674 additions and 101 deletions
-4
View File
@@ -9,9 +9,5 @@ class AppServiceProvider extends ServiceProvider
{ {
public function boot(): void public function boot(): void
{ {
Blade::anonymousComponentPath(
resource_path('views/components/layouts'),
'layouts'
);
} }
} }
+1 -1
View File
@@ -13,7 +13,7 @@ return Application::configure(basePath: dirname(__DIR__))
health: '/up', health: '/up',
) )
->withMiddleware(function (Middleware $middleware): void { ->withMiddleware(function (Middleware $middleware): void {
// $middleware->web(append: [\Modules\Stylist\Http\Middleware\ApplyActiveTheme::class]);
}) })
->withExceptions(function (Exceptions $exceptions): void { ->withExceptions(function (Exceptions $exceptions): void {
$exceptions->shouldRenderJsonWhen( $exceptions->shouldRenderJsonWhen(
@@ -41,6 +41,12 @@ class LicensingServiceProvider extends ServiceProvider
*/ */
public function boot() : void public function boot() : void
{ {
\Illuminate\Support\Facades\Blade::anonymousComponentPath(
base_path('modules/Licensing/Resources/views/components/layouts'),
'layouts'
);
RateLimiter::for('login', fn (Request $request) => Limit::perMinute(5) RateLimiter::for('login', fn (Request $request) => Limit::perMinute(5)
->by(strtolower((string) $request->input('email')).'|'.$request->ip())); ->by(strtolower((string) $request->input('email')).'|'.$request->ip()));
@@ -41,7 +41,7 @@ final class LicenseDeliveryService
'downloadUrl' => route('release'), 'downloadUrl' => route('release'),
]; ];
Mail::send(['html' => 'emails.license-key', 'text' => 'emails.license-key-text'], $data, function ($message) use ($recipient): void { Mail::send(['html' => 'licensing::emails.license-key', 'text' => 'licensing::emails.license-key-text'], $data, function ($message) use ($recipient): void {
$message->to($recipient)->subject('Your SonarDesk licence key'); $message->to($recipient)->subject('Your SonarDesk licence key');
}); });
@@ -0,0 +1,86 @@
@extends('layouts.app', ['title' => 'Stylist — SonarDesk Administration'])
@section('content')
<div class="mb-6">
<p class="text-sm font-medium text-gray-500">Administration</p>
<h1 class="text-3xl font-bold">Stylist</h1>
<p class="mt-2 text-gray-600">
Install, configure, validate and export self-contained themes.
</p>
</div>
@if (session('status'))
<div class="mb-6 rounded-xl border border-emerald-200 bg-emerald-50 px-4 py-3 text-emerald-800">{{ session('status') }}</div>
@endif
@if ($errors->any())
<div class="mb-6 rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-red-800">{{ $errors->first() }}</div>
@endif
<form method="POST" action="{{ route('stylist.install') }}" enctype="multipart/form-data" class="mb-8 flex flex-wrap items-end gap-3 rounded-xl border border-slate-200 bg-white p-5 shadow-sm">
@csrf
<label class="min-w-64 flex-1"><span class="mb-2 block text-sm font-medium text-slate-700">Install theme ZIP</span><input type="file" name="theme" accept=".zip" required class="block w-full rounded-lg border border-slate-300 p-2"></label>
<button class="rounded-lg bg-slate-900 px-4 py-2.5 font-semibold text-white">Install theme</button>
</form>
<div class="grid gap-6 xl:grid-cols-2">
@foreach ($themes as $item)
@php($saved = $settingsService->get($item))
@php($variant = $settingsService->variant($item))
@php($issues = $accessibility->validate($item))
@php($appearance = $settingsService->appearance($item))
@php($accent = $settingsService->accent($item))
<article class="overflow-hidden rounded-2xl border {{ (($item->type() === 'frontend' && $item->key() === $activeFrontendTheme) || ($item->type() === 'backend' && $item->key() === $activeBackendTheme)) ? 'border-blue-400 ring-2 ring-blue-100' : 'border-slate-200' }} bg-white shadow-sm">
<div class="aspect-[16/7] bg-slate-100">
@if ($item->preview() && $item->has($item->preview()))
<img src="{{ $urls->forTheme($item, $item->preview()) }}" alt="{{ $item->name() }} theme preview" class="h-full w-full object-cover">
@else
<div class="flex h-full items-center justify-center text-sm text-slate-500">Add preview.webp to this theme</div>
@endif
</div>
<div class="p-5">
<div class="flex items-start justify-between gap-4"><div><h2 class="text-xl font-bold text-slate-950">{{ $item->name() }}</h2><p class="text-sm text-slate-500">v{{ $item->version() }}@if($item->author()) · {{ $item->author() }}@endif</p></div>@if(($item->type() === 'frontend' && $item->key() === $activeFrontendTheme) || ($item->type() === 'backend' && $item->key() === $activeBackendTheme))<span class="rounded-full bg-blue-100 px-3 py-1 text-xs font-semibold text-blue-700">Active {{ ucfirst($item->type()) }}</span>@endif</div>
@if($item->description())<p class="mt-3 text-sm text-slate-600">{{ $item->description() }}</p>@endif
@if($item->parent())<p class="mt-2 text-xs font-medium text-violet-700">Child of {{ $item->parent() }}</p>@endif
<div class="mt-4 flex flex-wrap gap-2">
@if(in_array($item->type(), ['frontend', 'backend'], true))
<form method="POST" action="{{ route('stylist.activate', $item->key()) }}">@csrf<button class="rounded-lg bg-blue-600 px-3 py-2 text-sm font-semibold text-white">Activate {{ ucfirst($item->type()) }}</button></form>
<a href="{{ route('stylist.preview', $item->key()) }}" target="_blank" rel="noopener" class="rounded-lg border border-blue-300 px-3 py-2 text-sm font-medium text-blue-700">Preview</a>
@endif
<a href="{{ route('stylist.export', $item->key()) }}" class="rounded-lg border border-slate-300 px-3 py-2 text-sm font-medium">Export ZIP</a>
<form method="POST" action="{{ route('stylist.optimize', $item->key()) }}">@csrf<button class="rounded-lg border border-slate-300 px-3 py-2 text-sm font-medium">Optimise assets</button></form>
@if(str_starts_with(realpath($item->path()) ?: '', realpath(config('stylist.themes_path')) ?: '/__never__'))
<form method="POST" action="{{ route('stylist.uninstall', $item->key()) }}" onsubmit="return confirm('Uninstall this theme?')">@csrf @method('DELETE')<button class="rounded-lg border border-red-300 px-3 py-2 text-sm font-medium text-red-700">Uninstall</button></form>
@endif
</div>
<details class="mt-5 rounded-xl border border-slate-200 p-4">
<summary class="cursor-pointer font-semibold">Theme settings</summary>
<form method="POST" action="{{ route('stylist.settings', $item->key()) }}" class="mt-4 space-y-4">@csrf @method('PUT')
@if($item->variants())
<label class="block"><span class="mb-1 block text-sm font-medium">Variant</span><select name="variant" class="w-full rounded-lg border-slate-300">@foreach(array_keys($item->variants()) as $name)<option value="{{ $name }}" @selected($variant === $name)>{{ ucfirst($name) }}</option>@endforeach</select></label>
@endif
@if($item->supports('dark_mode') || $item->appearances())
<label class="block"><span class="mb-1 block text-sm font-medium">Appearance</span><select name="appearance" class="w-full rounded-lg border-slate-300">@foreach(array_keys($item->appearances()) ?: ['light', 'dark', 'auto'] as $name)<option value="{{ $name }}" @selected($appearance === $name)>{{ ucfirst($name) }}</option>@endforeach</select></label>
@endif
@if($item->accents())
<div><span class="mb-2 block text-sm font-medium">Accent colour</span><div class="flex flex-wrap gap-2">@foreach($item->accents() as $name => $definition)<label class="cursor-pointer"><input type="radio" name="accent" value="{{ $name }}" class="peer sr-only" @checked($accent === $name)><span class="inline-flex items-center gap-2 rounded-lg border border-slate-300 px-3 py-2 text-sm peer-checked:border-blue-500 peer-checked:ring-2 peer-checked:ring-blue-100"><span class="h-4 w-4 rounded-full border border-black/10" style="background: {{ data_get($definition, 'swatch', data_get($definition, 'variables.primary', '#64748b')) }}"></span>{{ data_get($definition, 'label', ucfirst($name)) }}</span></label>@endforeach</div></div>
@endif
@foreach($item->settingsSchema() as $key => $definition)
@php($definition = is_array($definition) ? $definition : ['default' => $definition])
<label class="block"><span class="mb-1 block text-sm font-medium">{{ $definition['label'] ?? str($key)->headline() }}</span>
@switch($definition['type'] ?? 'text')
@case('color')<input type="color" name="settings[{{ $key }}]" value="{{ $saved[$key] ?? ($definition['default'] ?? '#000000') }}" class="h-10 w-full rounded-lg border-slate-300">@break
@case('textarea')<textarea name="settings[{{ $key }}]" rows="4" class="w-full rounded-lg border-slate-300">{{ $saved[$key] ?? ($definition['default'] ?? '') }}</textarea>@break
@case('checkbox')<input type="hidden" name="settings[{{ $key }}]" value="0"><label class="inline-flex items-center gap-2"><input type="checkbox" name="settings[{{ $key }}]" value="1" @checked((bool)($saved[$key] ?? ($definition['default'] ?? false))) class="rounded border-slate-300"><span>Enabled</span></label>@break
@default<input type="{{ ($definition['type'] ?? 'text') === 'url' ? 'url' : 'text' }}" name="settings[{{ $key }}]" value="{{ $saved[$key] ?? ($definition['default'] ?? '') }}" class="w-full rounded-lg border-slate-300">
@endswitch
</label>
@endforeach
<button class="rounded-lg bg-blue-600 px-4 py-2 font-semibold text-white">Save settings</button>
</form>
</details>
<div class="mt-4 text-sm {{ collect($issues)->contains('severity', 'error') ? 'text-red-700' : 'text-emerald-700' }}">Accessibility: {{ count($issues) ? count($issues).' issue(s)' : 'passed static checks' }}</div>
</div>
</article>
@endforeach
</div>
@endsection
+3 -3
View File
@@ -1,9 +1,9 @@
<?php <?php
return [ return [
'default_theme' => env('STYLIST_DEFAULT_THEME', 'admin'), 'default_theme' => env('STYLIST_DEFAULT_THEME', 'sonardesk-admin'),
'default_backend_theme' => env('STYLIST_BACKEND_THEME', 'admin'), 'default_backend_theme' => env('STYLIST_BACKEND_THEME', 'sonardesk-admin'),
'default_frontend_theme' => env('STYLIST_FRONTEND_THEME', 'saasland'), 'default_frontend_theme' => env('STYLIST_FRONTEND_THEME', 'sonardesk'),
/* /*
| Themes are application resources, never module resources. | Themes are application resources, never module resources.
@@ -7,17 +7,17 @@ use Modules\Stylist\Services\ThemeAccessibilityValidator;
use Modules\Stylist\Services\ThemeSettings; use Modules\Stylist\Services\ThemeSettings;
use Modules\Stylist\Theme\Stylist; use Modules\Stylist\Theme\Stylist;
use Modules\Stylist\Theme\UrlGenerator; use Modules\Stylist\Theme\UrlGenerator;
use Modules\Settings\Services\SettingsRepository; use Modules\Stylist\Services\SiteSettingsRepository;
final class StylistController extends Controller final class StylistController extends Controller
{ {
public function __invoke(Stylist $stylist, ThemeSettings $settings, ThemeAccessibilityValidator $accessibility, UrlGenerator $urls, SettingsRepository $siteSettings) public function __invoke(Stylist $stylist, ThemeSettings $settings, ThemeAccessibilityValidator $accessibility, UrlGenerator $urls, SiteSettingsRepository $siteSettings)
{ {
return view('stylist::index', [ return view('stylist::index', [
'theme' => $stylist->current(), 'themes' => $stylist->all(), 'variables' => $stylist->variables(), 'theme' => $stylist->current(), 'themes' => $stylist->all(), 'variables' => $stylist->variables(),
'settingsService' => $settings, 'accessibility' => $accessibility, 'urls' => $urls, 'settingsService' => $settings, 'accessibility' => $accessibility, 'urls' => $urls,
'activeFrontendTheme' => $siteSettings->get('frontend_theme', config('stylist.default_frontend_theme', 'saasland'), 'site'), 'activeFrontendTheme' => $siteSettings->get('frontend_theme', config('stylist.default_frontend_theme', 'sonardesk'), 'site'),
'activeBackendTheme' => $siteSettings->get('backend_theme', config('stylist.default_backend_theme', 'admin'), 'site'), 'activeBackendTheme' => $siteSettings->get('backend_theme', config('stylist.default_backend_theme', 'sonardesk-admin'), 'site'),
]); ]);
} }
} }
@@ -4,7 +4,7 @@ namespace Modules\Stylist\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Routing\Controller; use Illuminate\Routing\Controller;
use Modules\Settings\Services\SettingsRepository; use Modules\Stylist\Services\SiteSettingsRepository;
use Modules\Stylist\Services\ThemeAccessibilityValidator; use Modules\Stylist\Services\ThemeAccessibilityValidator;
use Modules\Stylist\Services\ThemeOptimizer; use Modules\Stylist\Services\ThemeOptimizer;
use Modules\Stylist\Services\ThemePackageManager; use Modules\Stylist\Services\ThemePackageManager;
@@ -14,7 +14,7 @@ use Modules\Stylist\View\ThemeViewResolver;
final class ThemeManagementController extends Controller final class ThemeManagementController extends Controller
{ {
public function activate(string $theme, Loader $loader, SettingsRepository $settings) public function activate(string $theme, Loader $loader, SiteSettingsRepository $settings)
{ {
$item = $loader->find($theme); $item = $loader->find($theme);
abort_unless(in_array($item->type(), ['frontend', 'backend'], true), 422, 'Only frontend and backend themes can be activated.'); abort_unless(in_array($item->type(), ['frontend', 'backend'], true), 422, 'Only frontend and backend themes can be activated.');
@@ -28,7 +28,13 @@ final class ThemeManagementController extends Controller
{ {
$item = $loader->find($theme); $item = $loader->find($theme);
return $views->makeForTheme($item->key(), $item->entryView(), [ abort_unless(
in_array($item->type(), ['frontend', 'backend'], true),
422,
'Only frontend and backend themes can be previewed.'
);
return view('stylist::preview', [
'themePreview' => true, 'themePreview' => true,
'previewTheme' => $item, 'previewTheme' => $item,
]); ]);
@@ -59,6 +65,9 @@ final class ThemeManagementController extends Controller
public function uninstall(string $theme, Loader $loader, ThemePackageManager $packages) public function uninstall(string $theme, Loader $loader, ThemePackageManager $packages)
{ {
$item = $loader->find($theme); $item = $loader->find($theme);
abort_if(in_array($item->key(), ['sonardesk', 'sonardesk-admin'], true), 403, 'Bundled themes cannot be removed.');
$settings = app(SiteSettingsRepository::class);
abort_if($settings->get($item->type().'_theme', null, 'site') === $item->key(), 409, 'Deactivate this theme before uninstalling.');
$packages->uninstall($item); $packages->uninstall($item);
return back()->with('status', $item->name().' uninstalled.'); return back()->with('status', $item->name().' uninstalled.');
@@ -0,0 +1,50 @@
<?php
namespace Modules\Stylist\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\View;
use Modules\Stylist\Theme\Loader;
use Modules\Stylist\Theme\Stylist;
use Throwable;
final class ApplyActiveTheme
{
public function handle(Request $request, Closure $next)
{
$context = $request->is('admin', 'admin/*', 'stylist', 'stylist/*')
|| $request->routeIs('admin.*', 'stylist.*') ? 'backend' : 'frontend';
try {
$loader = app(Loader::class);
$theme = app(Stylist::class)->current($context);
if ($theme->type() !== $context) {
$theme = $loader->find($context === 'backend' ? 'sonardesk-admin' : 'sonardesk');
}
$paths = [];
$seen = [];
while ($theme && ! isset($seen[$theme->key()])) {
$seen[$theme->key()] = true;
$path = $theme->path().'/views';
if (is_dir($path)) {
$paths[] = $path;
}
$theme = $theme->parent() ? $loader->find($theme->parent()) : null;
}
$baseline = $loader->find($context === 'backend' ? 'sonardesk-admin' : 'sonardesk');
$paths[] = $baseline->path().'/views';
// Finder uses first match. Prepend in reverse order to preserve precedence.
foreach (array_reverse(array_unique($paths)) as $path) {
View::getFinder()->prependLocation($path);
}
} catch (Throwable $exception) {
report($exception);
// Original Laravel views remain available for recovery.
}
return $next($request);
}
}
@@ -20,7 +20,7 @@ use Modules\Stylist\Services\ThemeSettings;
use Modules\Stylist\Theme\Loader; use Modules\Stylist\Theme\Loader;
use Modules\Stylist\Theme\Stylist; use Modules\Stylist\Theme\Stylist;
use Modules\Settings\Services\SettingsRepository; use Modules\Stylist\Services\SiteSettingsRepository;
final class StylistServiceProvider extends ServiceProvider final class StylistServiceProvider extends ServiceProvider
{ {
@@ -41,6 +41,11 @@ final class StylistServiceProvider extends ServiceProvider
public function boot(): void public function boot(): void
{ {
\Illuminate\Support\Facades\View::addNamespace(
'sonardesk-base',
resource_path('views')
);
$this->registerViews(); $this->registerViews();
$this->registerThemeViews(); $this->registerThemeViews();
$this->registerTranslations(); $this->registerTranslations();
@@ -73,7 +78,7 @@ final class StylistServiceProvider extends ServiceProvider
View::composer('stylist-theme-saasland::*', function ($view): void { View::composer('stylist-theme-saasland::*', function ($view): void {
$theme = $this->app->make(Loader::class)->find('saasland'); $theme = $this->app->make(Loader::class)->find('saasland');
$settings = $this->app->make(ThemeSettings::class)->get($theme); $settings = $this->app->make(ThemeSettings::class)->get($theme);
$siteSettings = $this->app->make(SettingsRepository::class)->site(); $siteSettings = $this->app->make(SiteSettingsRepository::class)->site();
$navigation = $this->app->make(FrontendNavigation::class); $navigation = $this->app->make(FrontendNavigation::class);
$homepage = $this->app->make(FrontendContent::class)->homepage($settings); $homepage = $this->app->make(FrontendContent::class)->homepage($settings);
+462 -67
View File
@@ -1,78 +1,473 @@
<x-app-layout> @extends('layouts.app', ['title' => 'Stylist — SonarDesk Administration'])
<x-wms.page-hero eyebrow="Administration" title="Stylist" subtitle="Install, configure, validate and export self-contained themes." />
@if (session('status')) @section('content')
<div class="mb-6 rounded-xl border border-emerald-200 bg-emerald-50 px-4 py-3 text-emerald-800">{{ session('status') }}</div>
@endif <div class="stylist-admin">
@if ($errors->any())
<div class="mb-6 rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-red-800">{{ $errors->first() }}</div> <section class="portal-header stylist-header">
<div>
<span class="eyebrow">Administration / Appearance</span>
<h1>Stylist</h1>
<p class="lead compact">
Manage frontend and administration themes independently.
Install, configure, preview and export complete themes.
</p>
</div>
<a href="{{ route('admin.index') }}" class="btn btn-secondary">
Back to administration
</a>
</section>
@if(session('status'))
<div class="alert">{{ session('status') }}</div>
@endif @endif
<form method="POST" action="{{ route('stylist.install') }}" enctype="multipart/form-data" class="mb-8 flex flex-wrap items-end gap-3 rounded-xl border border-slate-200 bg-white p-5 shadow-sm"> @if($errors->any())
<div class="error">{{ $errors->first() }}</div>
@endif
<section class="stylist-summary">
<div class="stylist-summary-card">
<span>Installed themes</span>
<strong>{{ count($themes) }}</strong>
<small>Available designs</small>
</div>
<div class="stylist-summary-card">
<span>Frontend theme</span>
<strong>{{ $activeFrontendTheme }}</strong>
<small>Public website</small>
</div>
<div class="stylist-summary-card">
<span>Backend theme</span>
<strong>{{ $activeBackendTheme }}</strong>
<small>Administration interface</small>
</div>
</section>
<section class="stylist-install-panel">
<div class="stylist-section-heading">
<div>
<span class="eyebrow">Theme library</span>
<h2>Install a theme</h2>
<p>Upload a self-contained theme package in ZIP format.</p>
</div>
</div>
<form method="POST"
action="{{ route('stylist.install') }}"
enctype="multipart/form-data"
class="stylist-install-form">
@csrf @csrf
<label class="min-w-64 flex-1"><span class="mb-2 block text-sm font-medium text-slate-700">Install theme ZIP</span><input type="file" name="theme" accept=".zip" required class="block w-full rounded-lg border border-slate-300 p-2"></label>
<button class="rounded-lg bg-slate-900 px-4 py-2.5 font-semibold text-white">Install theme</button> <label class="stylist-upload-field">
<span>Theme package</span>
<input type="file"
name="theme"
accept=".zip"
required>
<small>Maximum upload size: 50 MB</small>
</label>
<button type="submit" class="btn btn-primary">
Install theme
</button>
</form>
</section>
<section class="stylist-library">
<div class="stylist-section-heading">
<div>
<span class="eyebrow">Appearance</span>
<h2>Installed themes</h2>
<p>Frontend and backend themes can be activated independently.</p>
</div>
</div>
<div class="stylist-theme-grid">
@foreach($themes as $item)
@php
$saved = $settingsService->get($item);
$variant = $settingsService->variant($item);
$appearance = $settingsService->appearance($item);
$accent = $settingsService->accent($item);
$issues = $accessibility->validate($item);
$isActive =
($item->type() === 'frontend' && $item->key() === $activeFrontendTheme)
|| ($item->type() === 'backend' && $item->key() === $activeBackendTheme);
$isBundled = in_array(
$item->key(),
['sonardesk', 'sonardesk-admin'],
true
);
$themeRoot = realpath(config('stylist.themes_path'));
$themePath = realpath($item->path());
$isInstalled = $themeRoot
&& $themePath
&& str_starts_with(
$themePath,
rtrim($themeRoot, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR
);
@endphp
<article class="stylist-theme-card {{ $isActive ? 'stylist-theme-active' : '' }}">
<div class="stylist-preview">
@if($item->preview() && $item->has($item->preview()))
<img
src="{{ $urls->forTheme($item, $item->preview()) }}"
alt="{{ $item->name() }} preview">
@else
<div class="stylist-preview-placeholder">
<span class="stylist-preview-symbol">◈</span>
<strong>{{ $item->name() }}</strong>
<small>No preview image available</small>
</div>
@endif
</div>
<div class="stylist-theme-body">
<div class="stylist-theme-heading">
<div>
<span class="stylist-theme-type">
{{ ucfirst($item->type()) }} theme
</span>
<h3>{{ $item->name() }}</h3>
<p class="stylist-version">
Version {{ $item->version() }}
@if($item->author())
· {{ $item->author() }}
@endif
</p>
</div>
@if($isActive)
<span class="status-chip success">
Active
</span>
@endif
</div>
@if($item->description())
<p class="stylist-description">
{{ $item->description() }}
</p>
@endif
@if($item->parent())
<p class="stylist-parent">
Based on {{ $item->parent() }}
</p>
@endif
<div class="stylist-actions">
@if(in_array($item->type(), ['frontend', 'backend'], true))
@unless($isActive)
<form method="POST"
action="{{ route('stylist.activate', $item->key()) }}">
@csrf
<button type="submit" class="btn btn-primary">
Activate {{ ucfirst($item->type()) }}
</button>
</form> </form>
<div class="grid gap-6 xl:grid-cols-2"> @endunless
@foreach ($themes as $item)
@php($saved = $settingsService->get($item)) <a class="btn btn-secondary"
@php($variant = $settingsService->variant($item)) href="{{ route('stylist.preview', $item->key()) }}"
@php($issues = $accessibility->validate($item)) target="_blank"
@php($appearance = $settingsService->appearance($item)) rel="noopener">
@php($accent = $settingsService->accent($item)) Preview
<article class="overflow-hidden rounded-2xl border {{ (($item->type() === 'frontend' && $item->key() === $activeFrontendTheme) || ($item->type() === 'backend' && $item->key() === $activeBackendTheme)) ? 'border-blue-400 ring-2 ring-blue-100' : 'border-slate-200' }} bg-white shadow-sm"> </a>
<div class="aspect-[16/7] bg-slate-100">
@if ($item->preview() && $item->has($item->preview()))
<img src="{{ $urls->forTheme($item, $item->preview()) }}" alt="{{ $item->name() }} theme preview" class="h-full w-full object-cover">
@else
<div class="flex h-full items-center justify-center text-sm text-slate-500">Add preview.webp to this theme</div>
@endif @endif
</div>
<div class="p-5"> <a class="btn btn-secondary"
<div class="flex items-start justify-between gap-4"><div><h2 class="text-xl font-bold text-slate-950">{{ $item->name() }}</h2><p class="text-sm text-slate-500">v{{ $item->version() }}@if($item->author()) · {{ $item->author() }}@endif</p></div>@if(($item->type() === 'frontend' && $item->key() === $activeFrontendTheme) || ($item->type() === 'backend' && $item->key() === $activeBackendTheme))<span class="rounded-full bg-blue-100 px-3 py-1 text-xs font-semibold text-blue-700">Active {{ ucfirst($item->type()) }}</span>@endif</div> href="{{ route('stylist.export', $item->key()) }}">
@if($item->description())<p class="mt-3 text-sm text-slate-600">{{ $item->description() }}</p>@endif Export ZIP
@if($item->parent())<p class="mt-2 text-xs font-medium text-violet-700">Child of {{ $item->parent() }}</p>@endif </a>
<div class="mt-4 flex flex-wrap gap-2">
@if(in_array($item->type(), ['frontend', 'backend'], true)) <form method="POST"
<form method="POST" action="{{ route('stylist.activate', $item->key()) }}">@csrf<button class="rounded-lg bg-blue-600 px-3 py-2 text-sm font-semibold text-white">Activate {{ ucfirst($item->type()) }}</button></form> action="{{ route('stylist.optimize', $item->key()) }}">
<a href="{{ route('stylist.preview', $item->key()) }}" target="_blank" rel="noopener" class="rounded-lg border border-blue-300 px-3 py-2 text-sm font-medium text-blue-700">Preview</a> @csrf
@endif
<a href="{{ route('stylist.export', $item->key()) }}" class="rounded-lg border border-slate-300 px-3 py-2 text-sm font-medium">Export ZIP</a> <button type="submit" class="btn btn-secondary">
<form method="POST" action="{{ route('stylist.optimize', $item->key()) }}">@csrf<button class="rounded-lg border border-slate-300 px-3 py-2 text-sm font-medium">Optimise assets</button></form> Optimise assets
@if(str_starts_with(realpath($item->path()) ?: '', realpath(config('stylist.themes_path')) ?: '/__never__')) </button>
<form method="POST" action="{{ route('stylist.uninstall', $item->key()) }}" onsubmit="return confirm('Uninstall this theme?')">@csrf @method('DELETE')<button class="rounded-lg border border-red-300 px-3 py-2 text-sm font-medium text-red-700">Uninstall</button></form>
@endif
</div>
<details class="mt-5 rounded-xl border border-slate-200 p-4">
<summary class="cursor-pointer font-semibold">Theme settings</summary>
<form method="POST" action="{{ route('stylist.settings', $item->key()) }}" class="mt-4 space-y-4">@csrf @method('PUT')
@if($item->variants())
<label class="block"><span class="mb-1 block text-sm font-medium">Variant</span><select name="variant" class="w-full rounded-lg border-slate-300">@foreach(array_keys($item->variants()) as $name)<option value="{{ $name }}" @selected($variant === $name)>{{ ucfirst($name) }}</option>@endforeach</select></label>
@endif
@if($item->supports('dark_mode') || $item->appearances())
<label class="block"><span class="mb-1 block text-sm font-medium">Appearance</span><select name="appearance" class="w-full rounded-lg border-slate-300">@foreach(array_keys($item->appearances()) ?: ['light', 'dark', 'auto'] as $name)<option value="{{ $name }}" @selected($appearance === $name)>{{ ucfirst($name) }}</option>@endforeach</select></label>
@endif
@if($item->accents())
<div><span class="mb-2 block text-sm font-medium">Accent colour</span><div class="flex flex-wrap gap-2">@foreach($item->accents() as $name => $definition)<label class="cursor-pointer"><input type="radio" name="accent" value="{{ $name }}" class="peer sr-only" @checked($accent === $name)><span class="inline-flex items-center gap-2 rounded-lg border border-slate-300 px-3 py-2 text-sm peer-checked:border-blue-500 peer-checked:ring-2 peer-checked:ring-blue-100"><span class="h-4 w-4 rounded-full border border-black/10" style="background: {{ data_get($definition, 'swatch', data_get($definition, 'variables.primary', '#64748b')) }}"></span>{{ data_get($definition, 'label', ucfirst($name)) }}</span></label>@endforeach</div></div>
@endif
@foreach($item->settingsSchema() as $key => $definition)
@php($definition = is_array($definition) ? $definition : ['default' => $definition])
<label class="block"><span class="mb-1 block text-sm font-medium">{{ $definition['label'] ?? str($key)->headline() }}</span>
@switch($definition['type'] ?? 'text')
@case('color')<input type="color" name="settings[{{ $key }}]" value="{{ $saved[$key] ?? ($definition['default'] ?? '#000000') }}" class="h-10 w-full rounded-lg border-slate-300">@break
@case('textarea')<textarea name="settings[{{ $key }}]" rows="4" class="w-full rounded-lg border-slate-300">{{ $saved[$key] ?? ($definition['default'] ?? '') }}</textarea>@break
@case('checkbox')<input type="hidden" name="settings[{{ $key }}]" value="0"><label class="inline-flex items-center gap-2"><input type="checkbox" name="settings[{{ $key }}]" value="1" @checked((bool)($saved[$key] ?? ($definition['default'] ?? false))) class="rounded border-slate-300"><span>Enabled</span></label>@break
@default<input type="{{ ($definition['type'] ?? 'text') === 'url' ? 'url' : 'text' }}" name="settings[{{ $key }}]" value="{{ $saved[$key] ?? ($definition['default'] ?? '') }}" class="w-full rounded-lg border-slate-300">
@endswitch
</label>
@endforeach
<button class="rounded-lg bg-blue-600 px-4 py-2 font-semibold text-white">Save settings</button>
</form> </form>
</details>
<div class="mt-4 text-sm {{ collect($issues)->contains('severity', 'error') ? 'text-red-700' : 'text-emerald-700' }}">Accessibility: {{ count($issues) ? count($issues).' issue(s)' : 'passed static checks' }}</div>
</div> </div>
</article>
<details class="stylist-settings">
<summary>
<span>Theme configuration</span>
<span class="stylist-chevron">⌄</span>
</summary>
<form method="POST"
action="{{ route('stylist.settings', $item->key()) }}"
class="stylist-settings-form">
@csrf
@method('PUT')
@if($item->variants())
<label>
Variant
<select name="variant">
@foreach(array_keys($item->variants()) as $name)
<option value="{{ $name }}"
@selected($variant === $name)>
{{ ucfirst($name) }}
</option>
@endforeach @endforeach
</select>
</label>
@endif
@if($item->supports('dark_mode') || $item->appearances())
<label>
Appearance
<select name="appearance">
@foreach(array_keys($item->appearances()) ?: ['light', 'dark', 'auto'] as $name)
<option value="{{ $name }}"
@selected($appearance === $name)>
{{ ucfirst($name) }}
</option>
@endforeach
</select>
</label>
@endif
@if($item->accents())
<fieldset class="stylist-accent-options">
<legend>Accent colour</legend>
@foreach($item->accents() as $name => $definition)
<label class="stylist-accent-option">
<input type="radio"
name="accent"
value="{{ $name }}"
@checked($accent === $name)>
<span class="stylist-colour-swatch"
style="background: {{ data_get($definition, 'swatch', data_get($definition, 'variables.primary', '#64748b')) }}">
</span>
{{ data_get($definition, 'label', ucfirst($name)) }}
</label>
@endforeach
</fieldset>
@endif
@foreach($item->settingsSchema() as $key => $definition)
@php
$definition = is_array($definition)
? $definition
: ['default' => $definition];
$fieldType = $definition['type'] ?? 'text';
$fieldLabel = $definition['label'] ?? str($key)->headline();
$fieldValue = $saved[$key] ?? ($definition['default'] ?? '');
@endphp
<div class="stylist-setting-field">
<label for="stylist-{{ $item->key() }}-{{ $key }}">
{{ $fieldLabel }}
</label>
@switch($fieldType)
@case('color')
<input
id="stylist-{{ $item->key() }}-{{ $key }}"
type="color"
name="settings[{{ $key }}]"
value="{{ $fieldValue }}">
@break
@case('textarea')
<textarea
id="stylist-{{ $item->key() }}-{{ $key }}"
name="settings[{{ $key }}]"
rows="4">{{ $fieldValue }}</textarea>
@break
@case('checkbox')
<input type="hidden"
name="settings[{{ $key }}]"
value="0">
<label class="stylist-checkbox">
<input
id="stylist-{{ $item->key() }}-{{ $key }}"
type="checkbox"
name="settings[{{ $key }}]"
value="1"
@checked((bool)$fieldValue)>
Enabled
</label>
@break
@default
<input
id="stylist-{{ $item->key() }}-{{ $key }}"
type="{{ $fieldType === 'url' ? 'url' : 'text' }}"
name="settings[{{ $key }}]"
value="{{ $fieldValue }}">
@endswitch
</div> </div>
</x-app-layout>
@endforeach
<button type="submit" class="btn btn-primary">
Save configuration
</button>
</form>
</details>
<div class="stylist-theme-footer">
<span class="{{ collect($issues)->contains('severity', 'error') ? 'bad' : 'ok' }}">
Accessibility:
{{ count($issues) ? count($issues).' issue(s)' : 'passed static checks' }}
</span>
@if($isInstalled && !$isBundled && !$isActive)
<form method="POST"
action="{{ route('stylist.uninstall', $item->key()) }}"
onsubmit="return confirm('Permanently uninstall this theme?')">
@csrf
@method('DELETE')
<button type="submit" class="stylist-remove">
Uninstall
</button>
</form>
@endif
</div>
</div>
</article>
@endforeach
</div>
</section>
</div>
<style>
.stylist-admin{max-width:1220px;margin:auto;padding-bottom:60px}
.stylist-header{margin-bottom:30px}
.stylist-header .lead{max-width:740px}
.stylist-summary{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px;margin-bottom:28px}
.stylist-summary-card{background:#fff;border:1px solid #e4e7ec;border-radius:15px;padding:22px;box-shadow:0 2px 6px rgba(15,23,42,.04)}
.stylist-summary-card span,.stylist-summary-card small{display:block;color:#667085;font-size:12px}
.stylist-summary-card strong{display:block;margin:8px 0;font-size:24px;color:#101828;overflow-wrap:anywhere}
.stylist-install-panel{background:#fff;border:1px solid #e4e7ec;border-radius:16px;padding:26px;margin-bottom:35px;box-shadow:0 2px 8px rgba(15,23,42,.04)}
.stylist-section-heading{display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:22px}
.stylist-section-heading h2{font-size:23px;margin:5px 0}
.stylist-section-heading p{margin:0;color:#667085}
.stylist-install-form{display:flex;gap:20px;align-items:end}
.stylist-upload-field{display:block;flex:1;font-size:13px;font-weight:750}
.stylist-upload-field span,.stylist-upload-field small{display:block}
.stylist-upload-field small{color:#667085;font-weight:400}
.stylist-upload-field input{margin:8px 0}
.stylist-install-form button{margin-bottom:25px}
.stylist-theme-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:22px}
.stylist-theme-card{background:#fff;border:1px solid #e4e7ec;border-radius:18px;overflow:hidden;box-shadow:0 5px 22px rgba(15,23,42,.05);min-width:0}
.stylist-theme-active{border-color:#93c5fd;box-shadow:0 0 0 3px #dbeafe}
.stylist-preview{height:210px;background:#f1f5f9;border-bottom:1px solid #e4e7ec;overflow:hidden}
.stylist-preview img{width:100%;height:100%;object-fit:cover}
.stylist-preview-placeholder{height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;background:linear-gradient(135deg,#101828,#1d3557);color:#fff;gap:5px}
.stylist-preview-symbol{font-size:40px;color:#93c5fd}
.stylist-preview-placeholder strong{font-size:18px}
.stylist-preview-placeholder small{font-size:12px;color:#94a3b8}
.stylist-theme-body{padding:25px}
.stylist-theme-heading{display:flex;justify-content:space-between;align-items:flex-start;gap:12px}
.stylist-theme-type{text-transform:uppercase;letter-spacing:.1em;color:#2563eb;font-size:10px;font-weight:850}
.stylist-theme-heading h3{font-size:22px;letter-spacing:-.025em;margin:5px 0}
.stylist-version{color:#667085;font-size:12px;margin:0}
.stylist-description{color:#475467;font-size:14px;line-height:1.6;margin:18px 0}
.stylist-parent{color:#7c3aed;font-size:12px}
.stylist-actions{display:flex;gap:9px;flex-wrap:wrap;margin:22px 0}
.stylist-actions form{margin:0}
.stylist-actions .btn{font-size:12px;padding:9px 12px}
.stylist-settings{border:1px solid #e4e7ec;border-radius:12px;margin-top:20px;overflow:hidden}
.stylist-settings summary{display:flex;justify-content:space-between;align-items:center;padding:15px 17px;cursor:pointer;font-weight:750;list-style:none}
.stylist-settings summary::-webkit-details-marker{display:none}
.stylist-settings[open] summary{border-bottom:1px solid #e4e7ec}
.stylist-chevron{font-size:20px;color:#667085}
.stylist-settings-form{padding:20px;display:grid;gap:14px}
.stylist-settings-form label{font-size:13px}
.stylist-settings-form input:not([type=radio]):not([type=checkbox]),.stylist-settings-form select,.stylist-settings-form textarea{width:100%;margin:6px 0 0}
.stylist-settings-form input[type=checkbox],.stylist-settings-form input[type=radio]{width:auto;margin:0}
.stylist-accent-options{border:1px solid #e4e7ec;border-radius:10px;padding:14px;display:flex;flex-wrap:wrap;gap:12px}
.stylist-accent-options legend{font-size:13px;font-weight:750}
.stylist-accent-option{display:inline-flex;align-items:center;gap:7px;cursor:pointer}
.stylist-colour-swatch{width:17px;height:17px;border-radius:50%;border:1px solid rgba(0,0,0,.12)}
.stylist-checkbox{display:flex;align-items:center;gap:9px}
.stylist-theme-footer{display:flex;justify-content:space-between;align-items:center;gap:12px;border-top:1px solid #eef2f6;padding-top:17px;margin-top:20px;font-size:12px}
.stylist-remove{background:transparent!important;color:#b42318!important;padding:5px 0!important;font-size:12px!important;box-shadow:none!important}
.stylist-remove:hover{text-decoration:underline}
@media(max-width:850px){.stylist-theme-grid{grid-template-columns:1fr}.stylist-summary{grid-template-columns:1fr}.stylist-install-form{flex-direction:column;align-items:stretch}.stylist-install-form button{margin:0}}
</style>
@endsection
@@ -0,0 +1,93 @@
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>@yield('title', 'Stylist — Theme Management')</title>
<style>
:root {
color-scheme: light;
--stylist-bg: #f8fafc;
--stylist-surface: #ffffff;
--stylist-text: #0f172a;
--stylist-muted: #64748b;
--stylist-border: #e2e8f0;
--stylist-primary: #2563eb;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
background: var(--stylist-bg);
color: var(--stylist-text);
font-family: -apple-system, BlinkMacSystemFont,
"Segoe UI", sans-serif;
line-height: 1.5;
}
.stylist-shell {
width: min(1600px, 100%);
margin: 0 auto;
padding: 32px;
}
.stylist-page-header {
margin-bottom: 28px;
}
.stylist-page-header h1 {
margin: 8px 0;
font-size: 32px;
font-weight: 750;
letter-spacing: -0.03em;
}
.stylist-page-header p {
margin: 0;
color: var(--stylist-muted);
}
.stylist-eyebrow {
color: var(--stylist-primary);
font-size: 12px;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.08em;
}
button, input, select, textarea {
font: inherit;
}
button {
cursor: pointer;
}
a {
color: inherit;
}
@media (max-width: 768px) {
.stylist-shell {
padding: 20px 16px;
}
}
</style>
@stack('styles')
</head>
<body>
<main class="stylist-shell">
@yield('content')
</main>
@stack('scripts')
</body>
</html>
@@ -0,0 +1,181 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ $previewTheme->name() }} — Theme Preview</title>
<style>
:root {
color-scheme: light;
--background: #f3f6fa;
--surface: #fff;
--text: #17243b;
--muted: #64748b;
--accent: #2563eb;
--border: #dce4ee;
}
* { box-sizing: border-box; }
body {
margin: 0;
background: var(--background);
color: var(--text);
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: inherit; text-decoration: none; }
.toolbar {
display: flex;
justify-content: space-between;
align-items: center;
gap: 20px;
padding: 14px 28px;
background: #142238;
color: white;
}
.toolbar strong { font-size: 14px; }
.toolbar small { display: block; color: #aebbd0; margin-top: 4px; }
.toolbar a {
background: white;
color: #142238;
border-radius: 7px;
padding: 10px 16px;
font-size: 13px;
font-weight: 600;
}
.site-nav {
display: flex;
justify-content: space-between;
align-items: center;
padding: 22px 6%;
background: white;
border-bottom: 1px solid var(--border);
}
.site-nav strong { font-size: 21px; }
.site-nav span { color: var(--muted); font-size: 13px; }
.container { max-width: 1200px; margin: 0 auto; padding: 55px 25px; }
.eyebrow {
text-transform: uppercase;
letter-spacing: 2px;
font-size: 12px;
font-weight: 700;
color: var(--accent);
}
h1 { font-size: clamp(32px, 5vw, 54px); margin: 15px 0; }
.lead { color: var(--muted); font-size: 18px; max-width: 680px; }
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
gap: 20px;
margin-top: 35px;
}
.card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 12px;
padding: 28px;
box-shadow: 0 8px 30px rgba(15,23,42,.035);
}
.card h3 { margin-top: 0; }
.card p { color: var(--muted); line-height: 1.6; }
.button {
display: inline-block;
padding: 13px 20px;
border-radius: 8px;
background: var(--accent);
color: white;
font-weight: 600;
margin-top: 15px;
}
.footer {
text-align: center;
padding: 35px;
color: var(--muted);
font-size: 13px;
}
@media (max-width: 650px) {
.toolbar, .site-nav { flex-wrap: wrap; }
}
</style>
</head>
<body>
<header class="toolbar">
<div>
<strong>Stylist — Theme Preview</strong>
<small>
{{ $previewTheme->name() }}
· Version {{ $previewTheme->version() }}
· {{ ucfirst($previewTheme->type()) }}
</small>
</div>
<a href="{{ route('stylist.index') }}">← Back to Stylist</a>
</header>
<nav class="site-nav">
<strong>SonarDesk</strong>
<span>
{{ $previewTheme->type() === 'backend'
? 'Administration interface'
: 'Public website' }}
</span>
</nav>
<main class="container">
@if($previewTheme->type() === 'backend')
<span class="eyebrow">Administration / Dashboard</span>
<h1>Administration overview</h1>
<p class="lead">
Preview the administration interface using representative data.
</p>
<div class="grid">
<div class="card"><h3>128</h3><p>Licences</p></div>
<div class="card"><h3>116</h3><p>Active licences</p></div>
<div class="card"><h3>184</h3><p>Installations</p></div>
<div class="card"><h3>92</h3><p>Portal users</p></div>
</div>
<div class="grid">
<div class="card">
<h3>Release management</h3>
<p>Manage published software releases.</p>
<span class="button">Manage releases</span>
</div>
<div class="card">
<h3>Theme management</h3>
<p>Configure the appearance of SonarDesk.</p>
<span class="button">Manage themes</span>
</div>
</div>
@else
<span class="eyebrow">SonarDesk for macOS</span>
<h1>Code quality at a glance.</h1>
<p class="lead">
A native macOS dashboard for monitoring SonarQube projects,
quality gates, vulnerabilities and technical debt.
</p>
<span class="button">Explore SonarDesk</span>
<div class="grid">
<div class="card">
<h3>Quality gates</h3>
<p>Monitor project quality and identify failing checks.</p>
</div>
<div class="card">
<h3>Issues</h3>
<p>Review bugs, vulnerabilities and code smells.</p>
</div>
<div class="card">
<h3>Reports</h3>
<p>Export project reports for further analysis.</p>
</div>
</div>
@endif
</main>
<footer class="footer">
Theme preview only — no changes have been applied.
</footer>
</body>
</html>
+2 -1
View File
@@ -1,10 +1,11 @@
<?php <?php
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
use App\Http\Middleware\AdminOnly;
use Modules\Stylist\Http\Controllers\StylistController; use Modules\Stylist\Http\Controllers\StylistController;
use Modules\Stylist\Http\Controllers\ThemeManagementController; use Modules\Stylist\Http\Controllers\ThemeManagementController;
Route::middleware(['auth', 'verified'])->group(function (): void { Route::middleware(['auth', 'verified', AdminOnly::class])->group(function (): void {
Route::get('/', StylistController::class)->name('index'); Route::get('/', StylistController::class)->name('index');
Route::post('/install', [ThemeManagementController::class, 'install'])->name('install'); Route::post('/install', [ThemeManagementController::class, 'install'])->name('install');
Route::put('/{theme}/settings', [ThemeManagementController::class, 'settings'])->name('settings'); Route::put('/{theme}/settings', [ThemeManagementController::class, 'settings'])->name('settings');
+19
View File
@@ -0,0 +1,19 @@
# SonarDesk — Stylist theme integration
Stylist is the primary resolver for ordinary frontend and backend Laravel views. The active theme, its parents, the bundled baseline and finally `resources/views` are searched in that order.
- Frontend: `resources/themes/sonardesk/views`.
- Backend: `resources/themes/sonardesk-admin/views`.
- The bundled themes preserve existing markup, CSS, JavaScript, routes and business logic.
- `/admin` and `/stylist` use backend; other web pages (including authenticated customer pages) use frontend.
- AdminOnly middleware protects Stylist operations.
- Bundled and active themes cannot be uninstalled.
- Keep `resources/views`: email templates, fallback and compatibility views are required.
- New theme ZIPs must include all needed templates, layouts, assets and a valid theme.json. Missing views fall back to baseline.
- The middleware does not change asset URLs. Replacement themes must supply their own asset references and use the existing Stylist asset serving facilities.
## Local validation
Run `php artisan optimize:clear`, `php artisan migrate`, `php artisan stylist:doctor` (if registered) and `php artisan view:cache` using your configured PHP binary. Test public pages, authentication, checkout, admin, Stylist, and transactional email before deployment.
This package has not been executed against your ServBay environment. Do not deploy to production without smoke testing.
@@ -0,0 +1,65 @@
<?php
namespace Modules\Stylist\Services;
use App\Models\SiteSetting;
final class SiteSettingsRepository
{
/**
* Retrieve a SonarDesk site setting.
*
* The scope argument is retained for compatibility with Stylist.
*/
public function get(
string $key,
mixed $default = null,
string $scope = 'site'
): mixed {
$this->validateScope($scope);
$value = SiteSetting::valueFor($key);
return $value ?? $default;
}
/**
* Persist a SonarDesk site setting.
*
* The type and public arguments are retained for compatibility
* with Stylist's existing theme management API.
*/
public function put(
string $key,
mixed $value,
string $scope = 'site',
string $type = 'string',
bool $public = true
): void {
$this->validateScope($scope);
SiteSetting::put(
$key,
$value === null ? null : (string) $value
);
}
/**
* Return all site settings as an associative array.
*/
public function site(): array
{
return SiteSetting::query()
->pluck('value', 'key')
->all();
}
private function validateScope(string $scope): void
{
if ($scope !== 'site') {
throw new \InvalidArgumentException(
"Unsupported settings scope: {$scope}"
);
}
}
}
@@ -3,11 +3,11 @@
namespace Modules\Stylist\Services; namespace Modules\Stylist\Services;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Modules\Settings\Services\SettingsRepository; use Modules\Stylist\Services\SiteSettingsRepository;
final class TenantThemeResolver final class TenantThemeResolver
{ {
public function __construct(private readonly SettingsRepository $settings) {} public function __construct(private readonly SiteSettingsRepository $settings) {}
public function resolve(?string $context = null): string public function resolve(?string $context = null): string
{ {
@@ -29,8 +29,8 @@ final class TenantThemeResolver
$settingKey = $context === 'frontend' ? 'frontend_theme' : 'backend_theme'; $settingKey = $context === 'frontend' ? 'frontend_theme' : 'backend_theme';
$default = $context === 'frontend' $default = $context === 'frontend'
? config('stylist.default_frontend_theme', 'saasland') ? config('stylist.default_frontend_theme', 'sonardesk')
: config('stylist.default_backend_theme', config('stylist.default_theme', 'admin')); : config('stylist.default_backend_theme', config('stylist.default_theme', 'sonardesk-admin'));
return (string) $this->settings->get($settingKey, $default, 'site'); return (string) $this->settings->get($settingKey, $default, 'site');
} }
@@ -43,10 +43,10 @@ final class TenantThemeResolver
$request = request(); $request = request();
return $request->routeIs('home', 'blog.public.*', 'news.public.*', 'pages.public.*') return $request->is('admin', 'admin/*', 'stylist', 'stylist/*')
|| ! $request->user() || $request->routeIs('admin.*', 'stylist.*')
? 'frontend' ? 'backend'
: 'backend'; : 'frontend';
} }
public function variables(): array public function variables(): array
@@ -6,13 +6,13 @@ use Illuminate\Filesystem\Filesystem;
use Illuminate\Http\UploadedFile; use Illuminate\Http\UploadedFile;
use Modules\Stylist\Theme\Loader; use Modules\Stylist\Theme\Loader;
use Modules\Stylist\Theme\Theme; use Modules\Stylist\Theme\Theme;
use Modules\Settings\Services\SettingsRepository; use Modules\Stylist\Services\SiteSettingsRepository;
use RuntimeException; use RuntimeException;
use ZipArchive; use ZipArchive;
final class ThemePackageManager final class ThemePackageManager
{ {
public function __construct(private readonly Filesystem $files, private readonly Loader $loader, private readonly ThemeValidator $validator, private readonly SettingsRepository $settings) {} public function __construct(private readonly Filesystem $files, private readonly Loader $loader, private readonly ThemeValidator $validator, private readonly SiteSettingsRepository $settings) {}
public function install(UploadedFile $upload): Theme public function install(UploadedFile $upload): Theme
{ {
@@ -61,6 +61,9 @@ final class ThemePackageManager
public function uninstall(Theme $theme): void public function uninstall(Theme $theme): void
{ {
if (in_array($theme->key(), ['sonardesk', 'sonardesk-admin'], true)) {
throw new RuntimeException('Bundled SonarDesk themes cannot be uninstalled.');
}
$active = $theme->type() === 'frontend' $active = $theme->type() === 'frontend'
? $this->settings->get('frontend_theme', config('stylist.default_frontend_theme'), 'site') ? $this->settings->get('frontend_theme', config('stylist.default_frontend_theme'), 'site')
: $this->settings->get('backend_theme', config('stylist.default_backend_theme'), 'site'); : $this->settings->get('backend_theme', config('stylist.default_backend_theme'), 'site');
+7 -3
View File
@@ -14,11 +14,15 @@ final class Stylist
{ {
$requested = $this->resolver->resolve($context); $requested = $this->resolver->resolve($context);
try { try {
return $this->loader->find($requested); $theme = $this->loader->find($requested);
if ($context !== null && $theme->type() !== $context) {
throw ThemeNotFoundException::forKey($requested);
}
return $theme;
} catch (ThemeNotFoundException) { } catch (ThemeNotFoundException) {
$fallback = $context === 'frontend' $fallback = $context === 'frontend'
? (string) config('stylist.default_frontend_theme', 'saasland') ? (string) config('stylist.default_frontend_theme', 'sonardesk')
: (string) config('stylist.default_backend_theme', config('stylist.default_theme', 'admin')); : (string) config('stylist.default_backend_theme', config('stylist.default_theme', 'sonardesk-admin'));
if ($requested !== $fallback) { if ($requested !== $fallback) {
return $this->loader->find($fallback); return $this->loader->find($fallback);
} }
@@ -0,0 +1,14 @@
{
"manifest_version": 1,
"key": "sonardesk-admin",
"name": "SonarDesk Administration",
"version": "1.0.0",
"type": "backend",
"description": "Original SonarDesk design, independently replaceable through Stylist.",
"entry_view": "admin.index",
"variants": {
"light": {
"variables": {}
}
}
}
@@ -0,0 +1,6 @@
@extends('layouts.app')
@section('content')
<section class="portal-header"><div><span class="eyebrow">Admin</span><h1>Licensing administration</h1><p class="lead compact">Manage licences, activations and customer support.</p></div></section>
<div class="grid"><div class="card"><strong>{{ $licenseCount ?? '—' }}</strong><p>Licences</p></div><div class="card"><strong>{{ $activeCount ?? '—' }}</strong><p>Not revoked</p></div><div class="card"><strong>{{ $activationCount ?? '—' }}</strong><p>Active installations</p></div><div class="card"><strong>{{ $userCount ?? '—' }}</strong><p>Portal users</p></div></div>
<div style="display:flex;gap:10px;flex-wrap:wrap;margin-top:18px"><a class="btn btn-primary" href="{{ route('admin.releases.index') }}">Manage releases</a><a class="btn" href="{{ route('admin.licenses') }}">Manage licences</a><a class="btn" href="{{ route('admin.users.index') }}">Manage users</a><a class="btn btn-secondary" href="{{ route('admin.cms.index') }}">Manage content</a><a class="btn btn-secondary" href="{{ route('stylist.index') }}">Manage themes</a><a class="btn btn-secondary" href="{{ route('admin.seo.edit') }}">SEO & search</a><a class="btn btn-secondary" href="{{ route('admin.support.index') }}">Support inbox</a></div>
@endsection
@@ -0,0 +1,6 @@
@extends('layouts.app')
@section('content')
<section class="portal-header"><div><span class="eyebrow">Admin</span><h1>Licensing administration</h1><p class="lead compact">Manage licences, activations and customer support.</p></div></section>
<div class="grid"><div class="card"><strong>{{ $licenseCount }}</strong><p>Licences</p></div><div class="card"><strong>{{ $activeCount }}</strong><p>Not revoked</p></div><div class="card"><strong>{{ $activationCount }}</strong><p>Active installations</p></div><div class="card"><strong>{{ $userCount }}</strong><p>Portal users</p></div></div>
<div style="display:flex;gap:10px;flex-wrap:wrap;margin-top:18px"><a class="btn btn-primary" href="{{ route('admin.releases.index') }}">Manage releases</a><a class="btn" href="{{ route('admin.licenses') }}">Manage licences</a><a class="btn" href="{{ route('admin.users.index') }}">Manage users</a><a class="btn btn-secondary" href="{{ route('admin.cms.index') }}">Manage content</a><a class="btn btn-secondary" href="{{ route('stylist.index') }}">Manage themes</a><a class="btn btn-secondary" href="{{ route('admin.seo.edit') }}">SEO & search</a><a class="btn btn-secondary" href="{{ route('admin.support.index') }}">Support inbox</a></div>
@endsection
+14
View File
@@ -0,0 +1,14 @@
{
"manifest_version": 1,
"key": "sonardesk",
"name": "SonarDesk Classic",
"version": "1.0.0",
"type": "frontend",
"description": "Original SonarDesk design, independently replaceable through Stylist.",
"entry_view": "portal.welcome",
"variants": {
"light": {
"variables": {}
}
}
}
@@ -0,0 +1 @@
@extends('layouts.app') @section('content')<div class="card"><h1>Reset password</h1><form method="post" action="{{ route('password.email') }}">@csrf<label>Email</label><input name="email" type="email" required><button>Send reset link</button></form></div>@endsection
+1
View File
@@ -0,0 +1 @@
@extends('layouts.app') @section('content')<div class="card"><h1>Sign in</h1><form method="post" action="{{ route('login') }}">@csrf<label>Email</label><input name="email" type="email" value="{{ old('email') }}" required autofocus><label>Password</label><input name="password" type="password" required><label><input style="width:auto" type="checkbox" name="remember"> Remember me</label><br><button>Sign in</button> <a href="{{ route('password.request') }}">Forgot password?</a></form></div>@endsection
+1
View File
@@ -0,0 +1 @@
@extends('layouts.app') @section('content')<div class="card"><h1>Create account</h1><p class="muted">Use the same email address used to purchase SonarDesk.</p><form method="post" action="{{ route('register') }}">@csrf<label>Name</label><input name="name" value="{{ old('name') }}" required><label>Email</label><input name="email" type="email" value="{{ old('email') }}" required><label>Password</label><input name="password" type="password" required><label>Confirm password</label><input name="password_confirmation" type="password" required><button>Create account</button></form></div>@endsection
@@ -0,0 +1 @@
@extends('layouts.app') @section('content')<div class="card"><h1>Choose a new password</h1><form method="post" action="{{ route('password.update') }}">@csrf<input type="hidden" name="token" value="{{ $token }}"><label>Email</label><input name="email" type="email" value="{{ $email }}" required><label>New password</label><input name="password" type="password" required><label>Confirm password</label><input name="password_confirmation" type="password" required><button>Reset password</button></form></div>@endsection
@@ -0,0 +1 @@
@extends('layouts.app') @section('content')<div class="card"><h1>Verify your email</h1><p>For security, licence ownership is only shown after the account email has been verified.</p><form method="post" action="{{ route('verification.send') }}">@csrf<button>Send another verification email</button></form></div>@endsection
File diff suppressed because one or more lines are too long
+50
View File
@@ -0,0 +1,50 @@
@extends('layouts.app', [
'title' => 'SonarDesk — Native SonarQube monitoring for macOS',
'description' => 'SonarDesk is a native macOS companion for SonarQube: monitor quality gates, issues, measures and project health from one focused desktop workspace.'
])
@section('content')
<section class="hero-card marketing-hero">
<span class="eyebrow">SonarQube, without the browser tab sprawl</span>
<h1>Your code quality.<br>At home on the Mac.</h1>
<p class="lead">SonarDesk is a focused native macOS companion for developers and teams using SonarQube. See project health, quality gates, bugs, vulnerabilities, code smells and measures in one fast desktop workspace.</p>
<div class="support-actions marketing-actions">
<a class="btn btn-primary" href="{{ route('buy') }}">Start 7-day free trial</a>
<a class="btn btn-secondary" href="{{ route('features') }}">Explore features</a>
</div>
<p class="microcopy">Direct download for macOS · Secure licence activation · Cancel anytime</p>
</section>
<section class="trust-strip" aria-label="SonarDesk highlights">
<span>Native macOS app</span><span>Multiple SonarQube servers</span><span>Keychain token storage</span><span>Issue detail workflow</span>
</section>
<section class="section-block">
<div class="section-heading"><span class="eyebrow">Built for daily engineering work</span><h2>See the signal. Open the issue. Get back to code.</h2><p>SonarDesk keeps the information you check most often close at hand, without replacing SonarQube or changing your existing workflow.</p></div>
<div class="feature-grid">
<article class="feature-card"><div class="feature-icon">01</div><h3>Project health at a glance</h3><p>Review configured projects, quality gate state and important measures from a clean Mac dashboard.</p></article>
<article class="feature-card"><div class="feature-icon">02</div><h3>Issue details that are useful</h3><p>Open bugs, vulnerabilities and code smells to see the context you need before switching back to the codebase.</p></article>
<article class="feature-card"><div class="feature-icon">03</div><h3>Focused filtering</h3><p>Work through issue lists with practical filters and server-side pagination rather than fighting a giant browser view.</p></article>
<article class="feature-card"><div class="feature-icon">04</div><h3>Multiple servers</h3><p>Keep the SonarQube environments you work with available from one desktop application.</p></article>
<article class="feature-card"><div class="feature-icon">05</div><h3>macOS security</h3><p>SonarQube access tokens are stored in the macOS Keychain. SonarDesk respects the permissions of the token you provide.</p></article>
<article class="feature-card"><div class="feature-icon">06</div><h3>Native workflow</h3><p>A purpose-built macOS interface with familiar navigation, desktop behaviour and a focused experience for engineering teams.</p></article>
</div>
</section>
<section class="section-block split-panel">
<div><span class="eyebrow">Designed to complement SonarQube</span><h2>Keep SonarQube as the source of truth.</h2><p class="lead compact">SonarDesk is a desktop companion, not a replacement. It connects to your SonarQube server using your credentials and presents the project and issue information you need for everyday monitoring.</p></div>
<div class="check-panel"><div>Quality gates and measures</div><div>Bugs, vulnerabilities and code smells</div><div>Project and issue navigation</div><div>Secure token storage in Keychain</div><div>Customer portal for licences and activations</div></div>
</section>
<section class="section-block pricing-preview">
<div class="section-heading"><span class="eyebrow">Straightforward pricing</span><h2>Start small. Upgrade when you need more Macs.</h2><p>Every plan includes the full SonarDesk application. Professional increases the activation allowance for people working across multiple Macs.</p></div>
<div class="pricing-preview-grid">
<article class="price-card"><span class="eyebrow">Personal</span><h3>For one Mac</h3><div class="marketing-price">£24.99 <small>/ year</small></div><p>or £2.99 monthly</p><ul class="features"><li>Full SonarDesk feature set</li><li>1 active Mac</li><li>7-day free trial</li><li>Licence key delivered by email</li><li>Customer licence portal</li></ul></article>
<article class="price-card featured"><span class="pill">Most popular</span><span class="eyebrow">Professional</span><h3>For a multi-Mac workflow</h3><div class="marketing-price">£44.99 <small>/ year</small></div><p>or £4.99 monthly</p><ul class="features"><li>Full SonarDesk feature set</li><li>Up to 3 active Macs</li><li>7-day free trial</li><li>Licence key delivered by email</li><li>Customer licence portal</li></ul></article>
</div>
<div class="center-action"><a class="btn btn-primary" href="{{ route('buy') }}">See pricing and start trial</a></div>
</section>
<section class="home-download-showcase"><div class="home-download-copy"><span class="eyebrow">Desktop distribution</span><h2>Ready when you are.</h2><p>Download the latest signed SonarDesk release for macOS, review what changed, verify the package checksum and browse previous versions from one dedicated release centre.</p><div class="support-actions">@if($latestRelease ?? null)<a class="btn btn-primary" href="{{ route('download.latest') }}">Download SonarDesk {{ $latestRelease->version }}</a>@else<a class="btn btn-primary" href="{{ route('release') }}">Visit download centre</a>@endif<a class="btn btn-secondary" href="{{ route('release') }}">Release notes</a></div></div><div class="home-download-meta">@if($latestRelease ?? null)<span>Latest stable</span><strong>Version {{ $latestRelease->version }}</strong><small>Build {{ $latestRelease->build_number }} · {{ $latestRelease->formatted_size }} · macOS {{ $latestRelease->minimum_macos ?: 'supported versions' }}</small><div><b>SHA-256</b><code>{{ Str::limit($latestRelease->sha256, 34) }}</code></div>@else<span>SonarDesk releases</span><strong>Distribution centre</strong><small>Published builds will appear here automatically.</small>@endif</div></section>
<section class="cta-panel"><div><span class="eyebrow">SonarDesk for macOS</span><h2>Make SonarQube easier to keep an eye on.</h2><p>Try SonarDesk for seven days and connect it to your existing SonarQube environment.</p></div><a class="btn btn-primary" href="{{ route('buy') }}">Start free trial</a></section>
@endsection
View File
+36
View File
@@ -0,0 +1,36 @@
#!/bin/bash
set -euo pipefail
# Determine project directory automatically
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
PROJECT_NAME="$(basename "$PROJECT_DIR")"
PARENT_DIR="$(dirname "$PROJECT_DIR")"
OUTPUT="$HOME/Downloads/sonardesk-stylist-source.zip"
echo "Project: $PROJECT_DIR"
echo "Output: $OUTPUT"
mkdir -p "$HOME/Downloads"
# Remove previous archive
rm -f "$OUTPUT"
# Run from parent so the project directory is included
cd "$PARENT_DIR"
zip -r "$OUTPUT" "$PROJECT_NAME" \
-x '*/vendor/*' \
'*/node_modules/*' \
'*/.git/*' \
'*/.env' \
'*/.env.*' \
'*/storage/logs/*' \
'*/storage/framework/cache/*' \
'*/storage/framework/sessions/*' \
'*/storage/framework/views/*'
echo ""
echo "Export completed successfully."
ls -lh "$OUTPUT"