#29: Labels are now included in the sitemap.xml
This commit is contained in:
parent
693f0c6760
commit
0d0584086b
@ -7,6 +7,7 @@ use App\Facade\Theme;
|
|||||||
use App\Facade\UserConfig;
|
use App\Facade\UserConfig;
|
||||||
use App\Helpers\DbHelper;
|
use App\Helpers\DbHelper;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Label;
|
||||||
use App\Photo;
|
use App\Photo;
|
||||||
use App\VisitorHit;
|
use App\VisitorHit;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@ -54,6 +55,18 @@ class DefaultController extends Controller
|
|||||||
// Albums the current user is allowed to access
|
// Albums the current user is allowed to access
|
||||||
$albumIDs = DbHelper::getAlbumIDsForCurrentUser();
|
$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
|
// Add each album URL
|
||||||
$albums = Album::whereIn('id', $albumIDs)->orderBy('name');
|
$albums = Album::whereIn('id', $albumIDs)->orderBy('name');
|
||||||
$albums->chunk(100, function($albumsChunk) use ($xml, $root)
|
$albums->chunk(100, function($albumsChunk) use ($xml, $root)
|
||||||
@ -62,7 +75,7 @@ class DefaultController extends Controller
|
|||||||
foreach ($albumsChunk as $album)
|
foreach ($albumsChunk as $album)
|
||||||
{
|
{
|
||||||
$lastModifiedPhoto = Photo::where('album_id', $album->id)->orderBy('updated_at', 'desc')->first();
|
$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,
|
$root,
|
||||||
$photo->url(),
|
$photo->url(),
|
||||||
$photo->updated_at,
|
$photo->updated_at,
|
||||||
'0.8',
|
'0.7',
|
||||||
$photo->thumbnailUrl('fullsize', false),
|
$photo->thumbnailUrl('fullsize', false),
|
||||||
join(' - ', $photoMeta)
|
join(' - ', $photoMeta)
|
||||||
);
|
);
|
||||||
|
@ -25,4 +25,9 @@ class Label extends Model
|
|||||||
{
|
{
|
||||||
return $this->belongsToMany(Photo::class, 'photo_labels');
|
return $this->belongsToMany(Photo::class, 'photo_labels');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function url()
|
||||||
|
{
|
||||||
|
return route('viewLabel', $this->url_alias);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user