diff --git a/app/Http/Controllers/Gallery/DefaultController.php b/app/Http/Controllers/Gallery/DefaultController.php index b05b8e5..c1aed8d 100644 --- a/app/Http/Controllers/Gallery/DefaultController.php +++ b/app/Http/Controllers/Gallery/DefaultController.php @@ -7,6 +7,7 @@ use App\Facade\Theme; use App\Facade\UserConfig; use App\Helpers\DbHelper; use App\Http\Controllers\Controller; +use App\Label; use App\Photo; use App\VisitorHit; use Illuminate\Http\Request; @@ -54,6 +55,18 @@ class DefaultController extends Controller // Albums the current user is allowed to access $albumIDs = DbHelper::getAlbumIDsForCurrentUser(); + // Add each label + $labels = Label::orderBy('name'); + $labels->chunk(100, function($labelsChunk) use ($xml, $root) + { + /** @var Label $label */ + foreach ($labelsChunk as $label) + { + $lastModifiedPhoto = $label->photos()->orderBy('updated_at', 'desc')->first(); + $this->createSitemapNode($xml, $root, $label->url(), (is_null($lastModifiedPhoto) ? $label->updated_at : $lastModifiedPhoto->updated_at), '0.9'); + } + }); + // Add each album URL $albums = Album::whereIn('id', $albumIDs)->orderBy('name'); $albums->chunk(100, function($albumsChunk) use ($xml, $root) @@ -62,7 +75,7 @@ class DefaultController extends Controller foreach ($albumsChunk as $album) { $lastModifiedPhoto = Photo::where('album_id', $album->id)->orderBy('updated_at', 'desc')->first(); - $this->createSitemapNode($xml, $root, $album->url(), (is_null($lastModifiedPhoto) ? $album->updated_at : $lastModifiedPhoto->updated_at), '0.9'); + $this->createSitemapNode($xml, $root, $album->url(), (is_null($lastModifiedPhoto) ? $album->updated_at : $lastModifiedPhoto->updated_at), '0.8'); } }); @@ -84,7 +97,7 @@ class DefaultController extends Controller $root, $photo->url(), $photo->updated_at, - '0.8', + '0.7', $photo->thumbnailUrl('fullsize', false), join(' - ', $photoMeta) ); diff --git a/app/Label.php b/app/Label.php index c638d0a..dee259a 100644 --- a/app/Label.php +++ b/app/Label.php @@ -25,4 +25,9 @@ class Label extends Model { return $this->belongsToMany(Photo::class, 'photo_labels'); } + + public function url() + { + return route('viewLabel', $this->url_alias); + } } \ No newline at end of file