add no index
Checks / verify (push) Canceled after 0s

This commit is contained in:
Meghdad committed 2026-11-26 12:42:49 +03:30
1 parent 647c8a8cab
commit a8e79bd567
11 files changed
+204 -41

No files matched your search

+1
View File
@@ -68,6 +68,7 @@ GitHub Actions runs the tests, TypeScript checks, and the Vite build for pushes
## Deployment and redistribution
- Serve the `public/` directory over HTTPS. Set `APP_ENV=production`, `APP_DEBUG=false`, `APP_URL` to the canonical HTTPS origin, and `SESSION_SECURE_COOKIE=true` in the server environment.
- Permanently redirect HTTP and alternate hostnames to the canonical HTTPS origin. Route `/robots.txt` and `/sitemap.xml` through Laravel, including on Nginx deployments with an exact-match `/robots.txt` location. After deployment, verify both URLs on the public domain and submit `/sitemap.xml` in Google Search Console.
- Install the locked dependencies and build Vite assets. Run `php artisan filament:assets` to publish Filament's generated assets and `php artisan migrate --force` to apply the schema. Use `php artisan migrate --seed` for a local demo.
- Keep the SQLite database and `storage/app/private` outside the web root. Back them up with the application key. The staff panel uses authenticated sessions. Configure server and CDN access logs to follow the visitor-data policy.
- `public/porint` and `database/seeders/artwork` contain the imagery needed to run the demo. Review redistribution rights for the supplied collection sheets and their derivatives before publishing the repository. Keep working originals and generated concepts in local storage.
+85 -21
View File
@@ -9,6 +9,8 @@ use App\Models\GarmentTemplate;
use App\Models\LocalizedContent;
use App\Support\GarmentPreview;
use Filament\Facades\Filament;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Storage;
use XMLWriter;
@@ -29,15 +31,20 @@ class StudioController extends Controller
return $this->page('catalog', 'catalog', compact('collections'));
}
public function collection(string $slug)
public function collection(string $slug): View
{
$collection = $this->find(Collection::published(), $slug);
$designs = $collection->designs()->visible()->get();
return $this->page('collection', 'collection', compact('collection', 'designs'), $collection);
return $this->page('collection', 'collection', [
'collection' => $collection,
'designs' => $designs,
'shareImage' => $collection->coverUrl(),
'shareImageAlt' => $collection->text('name'),
], $collection);
}
public function design(string $slug, GarmentPreview $preview)
public function design(string $slug, GarmentPreview $preview): View
{
$design = $this->find(Design::visible()->with('collection'), $slug);
$templates = $preview->options($design);
@@ -48,14 +55,22 @@ class StudioController extends Controller
defer(fn () => DesignDailyView::recordView($designId, $date));
}
return $this->page('design', 'design', compact('design', 'templates'), $design);
return $this->page('design', 'design', [
'design' => $design,
'templates' => $templates,
'shareImage' => $this->canonicalRoute('artwork', ['id' => $design->id, 'file' => basename($design->artwork_path)]),
'shareImageAlt' => $design->text('name'),
], $design);
}
public function guides()
public function guides(): View
{
return $this->page('guide', 'guides', [
'title' => __('guide.title'),
'description' => __('guide.description'),
'shareType' => 'article',
'shareImage' => asset('porint/guide-workbench.webp'),
'shareImageAlt' => __('guide.hero_alt'),
]);
}
@@ -88,25 +103,22 @@ class StudioController extends Controller
return $this->serveWebp($template->photo, $file, GarmentTemplate::PHOTO_DIRECTORY);
}
public function draft(int $id, string $locale, GarmentPreview $preview)
public function draft(int $id, string $locale, GarmentPreview $preview): Response
{
abort_unless(request()->user()->canAccessPanel(Filament::getPanel('studio')), 403);
app()->setLocale($locale);
$design = Design::with('collection')->findOrFail($id);
$templates = $preview->options($design);
$draft = true;
$alternateLocale = $locale === 'fa' ? 'en' : 'fa';
return response()->view('studio.design', [
'design' => $design,
'templates' => $templates,
'draft' => $draft,
'draft' => true,
'locale' => $locale,
'alternateLocale' => $locale === 'fa' ? 'en' : 'fa',
'alternates' => [
'fa' => route('studio.preview', ['id' => $id, 'locale' => 'fa']),
'en' => route('studio.preview', ['id' => $id, 'locale' => 'en']),
],
'alternateLocale' => $alternateLocale,
'languageSwitchUrl' => route('studio.preview', ['id' => $id, 'locale' => $alternateLocale]),
'title' => $design->text('name'),
'description' => $design->text('description'),
])->header('Cache-Control', 'private, no-store');
@@ -134,12 +146,19 @@ class StudioController extends Controller
return $private ? $response->setPrivate() : $response;
}
public function sitemap()
public function robots(): Response
{
return response("User-agent: *\nDisallow:\n\nSitemap: ".$this->canonicalRoute('sitemap')."\n", 200, [
'Content-Type' => 'text/plain; charset=UTF-8',
]);
}
public function sitemap(): Response
{
$urls = [];
foreach (['fa', 'en'] as $locale) {
foreach (['home', 'catalog', 'guides'] as $page) {
$urls[] = route("$locale.$page");
$urls[] = $this->canonicalRoute("$locale.$page");
}
}
@@ -149,7 +168,7 @@ class StudioController extends Controller
] as $page => $query) {
foreach ($query->get() as $record) {
foreach (['fa', 'en'] as $locale) {
$urls[] = route("$locale.$page", ['slug' => $record->text('slug', $locale)]);
$urls[] = $this->canonicalRoute("$locale.$page", ['slug' => $record->text('slug', $locale)]);
}
}
}
@@ -173,21 +192,66 @@ class StudioController extends Controller
return $query->where('slug_'.app()->getLocale(), $slug)->firstOrFail();
}
private function page(string $view, string $page, array $data, ?LocalizedContent $record = null)
/** @param array<string, int|string> $parameters */
private function canonicalRoute(string $name, array $parameters = []): string
{
return rtrim(config('app.url'), '/').route($name, $parameters, absolute: false);
}
private function page(string $view, string $page, array $data, ?LocalizedContent $record = null): View
{
$locale = app()->getLocale();
$alternateLocale = $locale === 'fa' ? 'en' : 'fa';
$alternates = [];
foreach (['fa', 'en'] as $language) {
$alternates[$language] = route("$language.$page", $record ? ['slug' => $record->text('slug', $language)] : []);
$alternates[$language] = $this->canonicalRoute("$language.$page", $record ? ['slug' => $record->text('slug', $language)] : []);
}
$title = $record?->text('name') ?? $data['title'] ?? __("studio.titles.$page");
$switchParameters = $record ? ['slug' => $record->text('slug', $alternateLocale)] : [];
return view("studio.$view", [
...$data,
'locale' => $locale,
'alternateLocale' => $locale === 'fa' ? 'en' : 'fa',
'alternateLocale' => $alternateLocale,
'alternates' => $alternates,
'title' => $record?->text('name') ?? $data['title'] ?? __("studio.titles.$page"),
'description' => $record?->text('description') ?? $data['description'] ?? __('studio.description'),
'languageSwitchUrl' => route("$alternateLocale.$page", $switchParameters),
'title' => $title,
'description' => $record?->text('description') ?? $data['description'] ?? __("studio.descriptions.$page"),
'shareImage' => $data['shareImage'] ?? asset('porint/hero.webp'),
'shareImageAlt' => isset($data['shareImage']) ? $data['shareImageAlt'] : __('studio.hero_alt'),
'structuredData' => $this->structuredData($page, $locale, $title, $alternates[$locale], $record),
]);
}
private function structuredData(string $page, string $locale, string $title, string $url, ?LocalizedContent $record): ?array
{
if ($page === 'home') {
return $locale === 'fa' ? [
'@context' => 'https://schema.org',
'@type' => 'WebSite',
'name' => 'PORINT',
'alternateName' => 'پورینت',
'url' => $url,
] : null;
}
$trail = [[__('studio.home'), $this->canonicalRoute("$locale.home")]];
if ($record) {
$trail[] = [__('studio.catalog'), $this->canonicalRoute("$locale.catalog")];
}
if ($record instanceof Design) {
$trail[] = [
$record->collection->text('name'),
$this->canonicalRoute("$locale.collection", ['slug' => $record->collection->text('slug')]),
];
}
$trail[] = [$title, $url];
$items = [];
foreach ($trail as $index => [$name, $itemUrl]) {
$items[] = ['@type' => 'ListItem', 'position' => $index + 1, 'name' => $name, 'item' => $itemUrl];
}
return ['@context' => 'https://schema.org', '@type' => 'BreadcrumbList', 'itemListElement' => $items];
}
}
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class NoIndexStudio
{
/**
* Handle an incoming request.
*
* @param Closure(Request): (Response) $next
*/
public function handle(Request $request, Closure $next): Response
{
$response = $next($request);
if ($request->is('studio', 'studio/*', 'up')) {
$response->headers->set('X-Robots-Tag', 'noindex, nofollow');
}
return $response;
}
}
+2
View File
@@ -1,5 +1,6 @@
<?php
use App\Http\Middleware\NoIndexStudio;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
@@ -14,6 +15,7 @@ return Application::configure(basePath: dirname(__DIR__))
then: fn () => Route::group([], base_path('routes/studio.php')),
)
->withMiddleware(function (Middleware $middleware): void {
$middleware->append(NoIndexStudio::class);
$middleware->redirectGuestsTo(fn () => route('filament.studio.auth.login'));
})
->withExceptions(function (Exceptions $exceptions): void {
+4 -1
View File
@@ -2,7 +2,10 @@
return [
'titles' => ['home' => 'Heat-transfer designs for clothing', 'catalog' => 'Heat-transfer collections'],
'description' => 'Explore PORINT’s heat-transfer designs, see your favorite motifs on clothes, and learn how to apply and care for them.',
'descriptions' => [
'home' => 'Explore PORINT’s heat-transfer designs, see your favorite motifs on clothes, and learn how to apply and care for them.',
'catalog' => 'Browse PORINT’s heat-transfer collections, from Rose & Thorn to Sound Wave, and preview individual designs on T-shirts, hoodies, and more.',
],
'catalog' => 'Collections',
'guides' => 'Print guide',
'language' => 'فارسی',
+4 -1
View File
@@ -2,7 +2,10 @@
return [
'titles' => ['home' => 'طرح‌های چاپ حرارتی لباس', 'catalog' => 'مجموعه‌های چاپ حرارتی'],
'description' => 'طرح‌های چاپ حرارتی لباس از استودیو پورینت؛ مجموعه‌ها را ببینید، طرح‌ها را روی لباس امتحان کنید و راهنمای نصب را بخوانید.',
'descriptions' => [
'home' => 'طرح‌های چاپ حرارتی لباس از استودیو پورینت؛ مجموعه‌ها را ببینید، طرح‌ها را روی لباس امتحان کنید و راهنمای نصب را بخوانید.',
'catalog' => 'مجموعه‌های طرح چاپ حرارتی پورینت، از «رز و خار» تا «موج صدا»، را ببینید و طرح‌ها را روی تی‌شرت، هودی و لباس‌های دیگر امتحان کنید.',
],
'catalog' => 'مجموعه‌ها',
'guides' => 'راهنمای چاپ',
'language' => 'English',
-2
View File
@@ -1,2 +0,0 @@
User-agent: *
Disallow:
-9
View File
@@ -1,14 +1,5 @@
@extends('studio.layout')
@push('head')
<meta property="og:type" content="article">
<meta property="og:title" content="{{ $title }} · PORINT">
<meta property="og:description" content="{{ $description }}">
<meta property="og:url" content="{{ $alternates[$locale] }}">
<meta property="og:image" content="{{ asset('porint/guide-workbench.webp') }}">
<meta property="og:image:alt" content="{{ __('guide.hero_alt') }}">
@endpush
@section('content')
<article class="print-guide">
<header class="guide-hero">
+16 -2
View File
@@ -12,8 +12,22 @@
@foreach ($alternates as $language => $url)
<link rel="alternate" hreflang="{{ $language }}" href="{{ $url }}">
@endforeach
<link rel="alternate" hreflang="x-default" href="{{ $alternates['fa'] }}">
<meta name="robots" content="max-image-preview:large">
<meta property="og:type" content="{{ $shareType ?? 'website' }}">
<meta property="og:site_name" content="PORINT">
<meta property="og:title" content="{{ $title }} · PORINT">
<meta property="og:description" content="{{ $description }}">
<meta property="og:url" content="{{ $alternates[$locale] }}">
<meta property="og:locale" content="{{ $locale === 'fa' ? 'fa_IR' : 'en_US' }}">
<meta property="og:locale:alternate" content="{{ $locale === 'fa' ? 'en_US' : 'fa_IR' }}">
<meta property="og:image" content="{{ $shareImage }}">
<meta property="og:image:alt" content="{{ $shareImageAlt }}">
<meta name="twitter:card" content="summary">
@if ($structuredData)
<script type="application/ld+json">{!! \Illuminate\Support\Js::encode($structuredData, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) !!}</script>
@endif
@endif
@stack('head')
<link rel="preload" href="{{ asset('fonts/vazirmatn.woff2') }}" as="font" type="font/woff2" crossorigin>
<link rel="stylesheet" href="{{ asset('fonts/studio-font.css') }}">
<link rel="stylesheet" href="{{ asset('porint/wordmark.css') }}">
@@ -29,7 +43,7 @@
<a href="{{ route($locale.'.catalog') }}">{{ __('studio.catalog') }}</a>
<a href="{{ route($locale.'.guides') }}">{{ __('studio.guides') }}</a>
</nav>
<a class="language" lang="{{ $alternateLocale }}" hreflang="{{ $alternateLocale }}" href="{{ $alternates[$alternateLocale] }}">{{ __('studio.language') }}</a>
<a class="language" lang="{{ $alternateLocale }}" hreflang="{{ $alternateLocale }}" href="{{ $languageSwitchUrl }}">{{ __('studio.language') }}</a>
</div>
</header>
<main id="content">
+1
View File
@@ -25,4 +25,5 @@ Route::get('/collection-covers/{id}/{file}', [StudioController::class, 'collecti
->whereNumber('id')->name('collection.cover');
Route::get('/garment-photos/{id}/{file}', [StudioController::class, 'garmentPhoto'])
->whereNumber('id')->name('garment.photo');
Route::get('/robots.txt', [StudioController::class, 'robots'])->name('robots');
Route::get('/sitemap.xml', [StudioController::class, 'sitemap'])->name('sitemap');
+65 -5
View File
@@ -165,19 +165,79 @@ class PorintStudioTest extends TestCase
$this->get($previewArt)->assertForbidden();
$staff = User::factory()->create(['is_staff' => true]);
$this->actingAs($staff)->get($preview)->assertOk()->assertSee('noindex, nofollow');
$this->get($previewArt)->assertOk()->assertHeader('Content-Type', 'image/webp')->assertHeader('Cache-Control', 'no-store, private');
$this->actingAs($staff)->get($preview)->assertOk()
->assertHeader('X-Robots-Tag', 'noindex, nofollow')
->assertSee('name="robots" content="noindex, nofollow"', escape: false)
->assertDontSee('property="og:image"', escape: false)
->assertDontSee('rel="canonical"', escape: false);
$this->get($previewArt)->assertOk()
->assertHeader('X-Robots-Tag', 'noindex, nofollow')
->assertHeader('Content-Type', 'image/webp')
->assertHeader('Cache-Control', 'no-store, private');
}
public function test_robots_advertises_the_canonical_sitemap_without_starting_a_session(): void
{
config(['app.url' => 'https://porint.example/']);
$this->get('http://preview.example/robots.txt')
->assertOk()
->assertHeader('Content-Type', 'text/plain; charset=UTF-8')
->assertHeaderMissing('Set-Cookie')
->assertContent("User-agent: *\nDisallow:\n\nSitemap: https://porint.example/sitemap.xml\n");
}
public function test_login_and_health_check_tell_crawlers_to_exclude_them(): void
{
$this->get(route('filament.studio.auth.login'))->assertOk()->assertHeader('X-Robots-Tag', 'noindex, nofollow');
$this->get('/up')->assertOk()->assertHeader('X-Robots-Tag', 'noindex, nofollow');
$this->get('/')->assertOk()->assertHeaderMissing('X-Robots-Tag');
}
public function test_sitemap_is_valid_xml_with_each_published_locale(): void
{
config(['app.url' => 'https://porint.example']);
$design = Design::firstOrFail();
$response = $this->get('/sitemap.xml')->assertOk()->assertHeaderMissing('Set-Cookie');
$response = $this->get('http://preview.example/sitemap.xml')->assertOk()->assertHeaderMissing('Set-Cookie');
$xml = simplexml_load_string($response->getContent());
$this->assertNotFalse($xml);
$links = array_map('strval', $xml->xpath('//*[local-name()="loc"]'));
$this->assertContains(route('fa.design', $design->slug_fa), $links);
$this->assertContains(route('en.design', $design->slug_en), $links);
$this->assertContains('https://porint.example/designs/'.rawurlencode($design->slug_fa), $links);
$this->assertContains('https://porint.example/en/designs/'.$design->slug_en, $links);
$this->assertContains('https://porint.example/', $links);
$response->assertDontSee('preview.example');
}
public function test_design_metadata_uses_localized_canonical_urls_and_the_public_artwork(): void
{
config(['app.url' => 'https://porint.example']);
$design = Design::firstOrFail();
$english = 'https://porint.example/en/designs/'.$design->slug_en;
$persian = 'https://porint.example/designs/'.rawurlencode($design->slug_fa);
$artwork = 'https://porint.example/artwork/'.$design->id.'/'.basename($design->artwork_path);
$response = $this->get('http://preview.example/en/designs/'.$design->slug_en.'?ref=share')->assertOk();
$document = HTMLDocument::createFromString($response->getContent(), LIBXML_NOERROR);
$this->assertSame($english, $document->querySelector('link[rel="canonical"]')->getAttribute('href'));
$this->assertSame($english, $document->querySelector('link[hreflang="en"]')->getAttribute('href'));
$this->assertSame($persian, $document->querySelector('link[hreflang="fa"]')->getAttribute('href'));
$this->assertSame($persian, $document->querySelector('link[hreflang="x-default"]')->getAttribute('href'));
$this->assertSame('http://preview.example/designs/'.rawurlencode($design->slug_fa), $document->querySelector('a.language')->getAttribute('href'));
$this->assertSame($english, $document->querySelector('meta[property="og:url"]')->getAttribute('content'));
$this->assertSame($artwork, $document->querySelector('meta[property="og:image"]')->getAttribute('content'));
$this->assertSame($design->name_en, $document->querySelector('meta[property="og:image:alt"]')->getAttribute('content'));
$schema = json_decode($document->querySelector('script[type="application/ld+json"]')->textContent, true, flags: JSON_THROW_ON_ERROR);
$this->assertSame('BreadcrumbList', $schema['@type']);
$this->assertSame([
'https://porint.example/en',
'https://porint.example/en/collections',
'https://porint.example/en/collections/'.$design->collection->slug_en,
$english,
], array_column($schema['itemListElement'], 'item'));
}
public function test_the_static_guide_has_localized_metadata_and_redirects_legacy_links(): void