fix(gallery): fill tall portrait cards to full block width with object-cover crop
- ArtworkCard: add w-full to nova-card-media, use absolute inset-0 on img so object-cover fills the max-height capped box instead of collapsing the width - MasonryGallery.css: add width:100% to media container, position img absolutely so top/bottom is cropped rather than leaving dark gaps - Add React MasonryGallery + ArtworkCard components and entry point - Add recommendation system: UserRecoProfile model/DTO/migration, SuggestedCreatorsController, SuggestedTagsController, Recommendation services, config/recommendations.php - SimilarArtworksController, DiscoverController, HomepageService updates - Update routes (api + web) and discover/for-you views - Refresh favicon assets, update vite.config.js
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
|
||||
use App\Models\Artwork;
|
||||
use App\Services\ArtworkSearchService;
|
||||
use App\Services\ArtworkService;
|
||||
use App\Services\Recommendation\RecommendationService;
|
||||
use App\Services\ThumbnailPresenter;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
@@ -21,12 +22,14 @@ use Illuminate\Support\Facades\Schema;
|
||||
* - /discover/top-rated → highest favourite count
|
||||
* - /discover/most-downloaded → most downloaded all-time
|
||||
* - /discover/on-this-day → published on this calendar day in previous years
|
||||
* - /discover/for-you → personalised feed (auth required)
|
||||
*/
|
||||
final class DiscoverController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ArtworkService $artworkService,
|
||||
private readonly ArtworkService $artworkService,
|
||||
private readonly ArtworkSearchService $searchService,
|
||||
private readonly RecommendationService $recoService,
|
||||
) {}
|
||||
|
||||
// ─── /discover/trending ──────────────────────────────────────────────────
|
||||
@@ -178,6 +181,56 @@ final class DiscoverController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
// ─── /discover/for-you ───────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Personalised "For You" feed page.
|
||||
*
|
||||
* Uses RecommendationService (Phase 1 tag-affinity + creator-affinity pipeline)
|
||||
* and renders the standard discover grid view. Guest users are redirected
|
||||
* to the trending page per spec.
|
||||
*/
|
||||
public function forYou(Request $request)
|
||||
{
|
||||
$user = $request->user();
|
||||
$limit = 40;
|
||||
$cursor = $request->query('cursor') ?: null;
|
||||
|
||||
// Retrieve the paginated feed (service handles Meilisearch + reranking + cache)
|
||||
$feedResult = $this->recoService->forYouFeed(
|
||||
user: $user,
|
||||
limit: $limit,
|
||||
cursor: is_string($cursor) ? $cursor : null,
|
||||
);
|
||||
|
||||
$artworkItems = $feedResult['data'] ?? [];
|
||||
|
||||
// Build a simple presentable collection
|
||||
$artworks = collect($artworkItems)->map(fn (array $item) => (object) [
|
||||
'id' => $item['id'] ?? 0,
|
||||
'name' => $item['title'] ?? 'Untitled',
|
||||
'category_name' => '',
|
||||
'thumb_url' => $item['thumbnail_url'] ?? null,
|
||||
'thumb_srcset' => $item['thumbnail_url'] ?? null,
|
||||
'uname' => $item['author'] ?? 'Artist',
|
||||
'published_at' => null,
|
||||
'slug' => $item['slug'] ?? '',
|
||||
]);
|
||||
|
||||
$meta = $feedResult['meta'] ?? [];
|
||||
$nextCursor = $meta['next_cursor'] ?? null;
|
||||
|
||||
return view('web.discover.for-you', [
|
||||
'artworks' => $artworks,
|
||||
'page_title' => 'For You',
|
||||
'section' => 'for-you',
|
||||
'description' => 'Artworks picked for you based on your taste.',
|
||||
'icon' => 'fa-wand-magic-sparkles',
|
||||
'next_cursor' => $nextCursor,
|
||||
'cache_status' => $meta['cache_status'] ?? null,
|
||||
]);
|
||||
}
|
||||
|
||||
// ─── /discover/following ─────────────────────────────────────────────────
|
||||
|
||||
public function following(Request $request)
|
||||
@@ -264,11 +317,14 @@ final class DiscoverController extends Controller
|
||||
'id' => $artwork->id,
|
||||
'name' => $artwork->title,
|
||||
'category_name' => $primaryCategory->name ?? '',
|
||||
'category_slug' => $primaryCategory->slug ?? '',
|
||||
'gid_num' => $primaryCategory ? ((int) $primaryCategory->id % 5) * 5 : 0,
|
||||
'thumb_url' => $present['url'],
|
||||
'thumb_srcset' => $present['srcset'] ?? $present['url'],
|
||||
'uname' => $artwork->user->name ?? 'Skinbase',
|
||||
'published_at' => $artwork->published_at,
|
||||
'width' => $artwork->width ?? null,
|
||||
'height' => $artwork->height ?? null,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user