Răsfoiți Sursa

Merge pull request #6001 from pixelfed/staging

Staging
(dan)iel (sup)ernault 1 lună în urmă
părinte
comite
18d1c1a938

+ 9 - 0
CHANGELOG.md

@@ -32,6 +32,15 @@
 - Update ComposeController, fix cache invalidation order ([ae47ba73d](https://github.com/pixelfed/pixelfed/commit/ae47ba73d))
 - Update ApiV1Controller, fix cache invalidation order ([4747266b0](https://github.com/pixelfed/pixelfed/commit/4747266b0))
 - Update CreateNote, improve media attachement handling by leveraging the MediaService cache ([7ae61a74a](https://github.com/pixelfed/pixelfed/commit/7ae61a74a))
+- Update ActivityPub attachements, use Document type by default ([51ce7e1f0](https://github.com/pixelfed/pixelfed/commit/51ce7e1f0))
+- Update MediaService, improve activitypub format ([837014e06](https://github.com/pixelfed/pixelfed/commit/837014e06))
+- Update StatusController, fix mimeTypeCheck ([7f7387ee4](https://github.com/pixelfed/pixelfed/commit/7f7387ee4))
+- Update MediaTransformer, return proper image type ([0dff48adb](https://github.com/pixelfed/pixelfed/commit/0dff48adb))
+- Update StoryComposeController, fix intervention/image v3 support ([86fbeeec3](https://github.com/pixelfed/pixelfed/commit/86fbeeec3))
+- Update StoryController, fix intervention/image v3 support ([9d89425e6](https://github.com/pixelfed/pixelfed/commit/9d89425e6))
+- Update Groups ImageResizePipeline with intervention/image v3 support ([616e37066](https://github.com/pixelfed/pixelfed/commit/616e37066))
+- Update app config, add Str alias ([5539dd0e1](https://github.com/pixelfed/pixelfed/commit/5539dd0e1))
+- Update PlaceController, fix show method ([f81a4acdc](https://github.com/pixelfed/pixelfed/commit/f81a4acdc))
 -  ([](https://github.com/pixelfed/pixelfed/commit/))
 
 ## [v0.12.5 (2025-03-23)](https://github.com/pixelfed/pixelfed/compare/v0.12.5...dev)

+ 29 - 20
app/Http/Controllers/PlaceController.php

@@ -2,33 +2,42 @@
 
 namespace App\Http\Controllers;
 
+use App\Place;
+use App\Services\StatusService;
+use App\Status;
+use Cache;
 use Illuminate\Http\Request;
-use App\{
-	Place,
-	Status
-};
 
 class PlaceController extends Controller
 {
-	public function __construct()
-	{
-		$this->middleware('auth');
-	}
+    const PLACES_CACHE_KEY = 'pf:places:sid-cache:by:placeid:';
+
+    public function __construct()
+    {
+        $this->middleware('auth');
+    }
 
     public function show(Request $request, $id, $slug)
     {
-        $this->validate($request, [
-            'page' => 'sometimes|max:10'
-        ]);
-
-    	$place = Place::whereSlug($slug)->findOrFail($id);
-    	$posts = Status::wherePlaceId($place->id)
-            ->whereNull('uri')
-    		->whereScope('public')
-    		->orderByDesc('created_at')
-    		->simplePaginate(10);
-
-    	return view('discover.places.show', compact('place', 'posts'));
+        $place = Place::whereSlug($slug)->findOrFail($id);
+
+        $statusIds = Cache::remember(self::PLACES_CACHE_KEY.$place->id, now()->addMinutes(40), function () use ($place) {
+            return Status::select('id')
+                ->wherePlaceId($place->id)
+                ->whereScope('public')
+                ->whereIn('type', ['photo', 'photo:album', 'video'])
+                ->orderByDesc('id')
+                ->limit(50)
+                ->get();
+        });
+
+        $posts = $statusIds->map(function ($item) {
+            return StatusService::get($item->id);
+        })->filter(function ($item) {
+            return $item && count($item['media_attachments'][0]);
+        })->take(18)->values();
+
+        return view('discover.places.show', compact('place', 'posts'));
     }
 
     public function directoryHome(Request $request)

+ 1 - 0
config/app.php

@@ -210,6 +210,7 @@ return [
         'URL'          => Illuminate\Support\Facades\URL::class,
         'Validator'    => Illuminate\Support\Facades\Validator::class,
         'View'         => Illuminate\Support\Facades\View::class,
+        'Str'         => Illuminate\Support\Str::class,
 
         'PrettyNumber' => App\Util\Lexer\PrettyNumber::class,
         'Purify'       => Stevebauman\Purify\Facades\Purify::class,

+ 49 - 38
resources/views/discover/places/show.blade.php

@@ -2,47 +2,58 @@
 
 @section('content')
 <div class="container">	
-
-	<div class="profile-header row my-5">	
-		<div class="col-12 col-md-2">	
-			<div class="profile-avatar">
-				<div class="bg-pixelfed mb-3 d-flex align-items-center justify-content-center display-4 font-weight-bold text-white" style="width: 132px; height: 132px; border-radius: 100%"><i class="fas fa-map-pin"></i></div>
-			</div>	
-		</div>	
-		<div class="col-12 col-md-9 d-flex align-items-center">	
-			<div class="profile-details">	
-				<div class="username-bar pb-2 d-flex align-items-center">
-					<div class="ml-4">
-						<p class="h3 font-weight-lighter">{{$place->name}}, {{$place->country}}</p>
-						<p class="small text-muted">({{$place->lat}}, {{$place->long}})</p>	
-					</div>	
-				</div>	
-			</div>	
-		</div>	
-	</div>	
-	<div class="tag-timeline">	
-		<div class="row">
-			@if($posts->count() > 0)	
-			@foreach($posts as $status)	
-			<div class="col-4 p-0 p-sm-2 p-md-3">	
-				<a class="card info-overlay card-md-border-0" href="{{$status->url()}}">	
-					<div class="square {{$status->firstMedia()->filter_class}}">	
-						<div class="square-content" style="background-image: url('{{$status->thumb()}}')"></div>	
-					</div>	
-				</a>	
-			</div>	
-			@endforeach	
-			@else
-			<div class="col-12 bg-white p-5 border">
-				<p class="lead text-center text-dark mb-0">No results for this location</p>
-			</div>
-			@endif
-		</div>	
-	</div>	
+    <div class="profile-header row mt-4">
+        <div class="col-12 col-md-2">
+            <div class="profile-avatar">
+                <div class="bg-pixelfed mb-3 d-flex align-items-center justify-content-center display-4 font-weight-bold text-white" style="width: 132px; height: 132px; border-radius: 100%"><i class="fal fa-map-pin"></i></div>
+            </div>
+        </div>
+        <div class="col-12 col-md-9 d-flex align-items-center">
+            <div class="profile-details">
+                <div class="username-bar pb-2 d-flex align-items-center">
+                    <div class="ml-4">
+                        <p class="h3 font-weight-lighter">{{$place->name}}, {{$place->country}}</p>
+                        <p class="small text-muted">({{$place->lat}}, {{$place->long}})</p>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+    <div class="tag-timeline">
+        <div class="row">
+            @if($posts->count() > 0)
+                @foreach($posts as $status)
+                <div class="col-4 p-1 p-lg-2">
+                    <a class="card info-overlay card-md-border-0" href="{{$status['url']}}">
+                        <picture class="square bg-muted">
+                            @if(!Str::endsWith($status['media_attachments'][0]['preview_url'], 'no-preview.png'))
+                            <source class="square-content" srcset="{{ $status['media_attachments'][0]['preview_url'] }}" />
+                            @endif
+                            <img class="square-content" src="{{ $status['media_attachments'][0]['url'] }}" alt="{{ $status['media_attachments'][0]['description'] ?? 'Photo was not tagged with any alt text' }}" onerror="this.src='/storage/no-preview.png';this.onerror=null;" />
+                        </picture>
+                    </a>
+                </div>
+                @endforeach
+            @else
+             <div class="col-12">
+                    <div class="card shadow-sm border text-center py-5">
+                        <div class="card-body">
+                            <i class="far fa-images fa-4x text-muted mb-3"></i>
+                            <h4>No Posts Yet</h4>
+                            <p class="text-muted">There are no posts tagged at this location yet.</p>
+                            <a href="/discover/places" class="btn btn-primary mt-2">
+                                Explore Other Places
+                            </a>
+                        </div>
+                    </div>
+                </div>
+            @endif
+        </div>
+    </div>
 </div>
 @endsection
 
 @push('scripts')
 <script type="text/javascript" src="{{ mix('js/compose.js') }}"></script>
 <script type="text/javascript">App.boot();</script>
-@endpush
+@endpush