#24: Added a basic sitemap.xml with the root gallery URL
This commit is contained in:
parent
d0d96df17d
commit
61a76ac8a7
@ -34,4 +34,29 @@ class DefaultController extends Controller
|
|||||||
'success' => $resetStatus
|
'success' => $resetStatus
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function sitemapXml()
|
||||||
|
{
|
||||||
|
$xml = new \DOMDocument('1.0', 'UTF-8');
|
||||||
|
$xml->preserveWhiteSpace = true;
|
||||||
|
$xml->formatOutput = true;
|
||||||
|
|
||||||
|
$root = $xml->createElementNS('http://www.sitemaps.org/schemas/sitemap/0.9', 'urlset');
|
||||||
|
$xml->appendChild($root);
|
||||||
|
|
||||||
|
// Root URL
|
||||||
|
$this->createSitemapNode($xml, $root, route('home'));
|
||||||
|
|
||||||
|
return response($xml->saveXML(), 200, ['Content-Type' => 'text/xml']);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function createSitemapNode(\DOMDocument $document, \DOMElement $parentElement, $url)
|
||||||
|
{
|
||||||
|
$urlElement = $document->createElement('url');
|
||||||
|
$urlLocElement = $document->createElement('loc', $url);
|
||||||
|
$urlElement->appendChild($urlLocElement);
|
||||||
|
$parentElement->appendChild($urlElement);
|
||||||
|
|
||||||
|
return $urlElement;
|
||||||
|
}
|
||||||
}
|
}
|
@ -68,6 +68,7 @@ Route::get('/', 'Gallery\DefaultController@index')->name('home');
|
|||||||
Route::get('/activate/{token}', 'Auth\ActivateController@activate')->name('auth.activate');
|
Route::get('/activate/{token}', 'Auth\ActivateController@activate')->name('auth.activate');
|
||||||
Route::get('/password/change', 'Auth\ChangePasswordController@showChangePasswordForm')->name('auth.changePassword');
|
Route::get('/password/change', 'Auth\ChangePasswordController@showChangePasswordForm')->name('auth.changePassword');
|
||||||
Route::post('/password/change', 'Auth\ChangePasswordController@processChangePassword')->name('auth.processChangePassword');
|
Route::post('/password/change', 'Auth\ChangePasswordController@processChangePassword')->name('auth.processChangePassword');
|
||||||
|
Route::get('/sitemap.xml', 'Gallery\DefaultController@sitemapXml');
|
||||||
Route::get('a/{albumUrlAlias}', 'Gallery\AlbumController@index')
|
Route::get('a/{albumUrlAlias}', 'Gallery\AlbumController@index')
|
||||||
->name('viewAlbum')
|
->name('viewAlbum')
|
||||||
->where('albumUrlAlias', '.*');
|
->where('albumUrlAlias', '.*');
|
||||||
|
Loading…
Reference in New Issue
Block a user