SEO Time
This commit is contained in:
71
app/Console/Commands/GenerateSitemap.php
Normal file
71
app/Console/Commands/GenerateSitemap.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Entry;
|
||||
use App\Models\News;
|
||||
use Illuminate\Console\Attributes\Signature;
|
||||
use Illuminate\Console\Command;
|
||||
use Spatie\Sitemap\Sitemap;
|
||||
use Spatie\Sitemap\Tags\Url;
|
||||
|
||||
#[Signature('sitemap:generate')]
|
||||
class GenerateSitemap extends Command
|
||||
{
|
||||
public function handle()
|
||||
{
|
||||
$sitemap = Sitemap::create()
|
||||
->add(Url::create('/')->setPriority(1.0)->setChangeFrequency(Url::CHANGE_FREQUENCY_DAILY))
|
||||
->add(Url::create('/database')->setPriority(0.8)->setChangeFrequency(Url::CHANGE_FREQUENCY_DAILY))
|
||||
->add(Url::create('/news')->setPriority(0.7)->setChangeFrequency(Url::CHANGE_FREQUENCY_DAILY))
|
||||
->add(Url::create(route('tools.patcher'))->setPriority(0.2)->setChangeFrequency(Url::CHANGE_FREQUENCY_MONTHLY) )
|
||||
->add(Url::create(route('tools.hash'))->setPriority(0.2)->setChangeFrequency(Url::CHANGE_FREQUENCY_MONTHLY) )
|
||||
;
|
||||
|
||||
Entry::cursor()->each(function (Entry $entry) use ($sitemap) {
|
||||
|
||||
if (empty($entry->type) || empty($entry->slug)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$url = route('entries.show', [
|
||||
'section' => $entry->type,
|
||||
'entry' => $entry->slug
|
||||
]);
|
||||
|
||||
$sitemap->add(
|
||||
Url::create($url)
|
||||
->setLastModificationDate($entry->updated_at)
|
||||
->setChangeFrequency(Url::CHANGE_FREQUENCY_WEEKLY)
|
||||
->setPriority(0.8)
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
logger()->error("Sitemap error for entry : {$entry->id}: " . $e->getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
News::cursor()->each(function (News $entry) use ($sitemap) {
|
||||
|
||||
if (empty($entry->type) || empty($entry->slug)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$url = route('news.show', ['news' => $entry]);
|
||||
|
||||
$sitemap->add(
|
||||
Url::create($url)
|
||||
->setLastModificationDate($entry->updated_at)
|
||||
->setChangeFrequency(Url::CHANGE_FREQUENCY_WEEKLY)
|
||||
->setPriority(0.8)
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
logger()->error("Sitemap error for news : {$entry->id}: " . $e->getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
$sitemap->writeToFile(public_path('sitemap.xml'));
|
||||
$this->info('Generated sitemap');
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,13 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Artesaos\SEOTools\Facades\SEOTools;
|
||||
|
||||
abstract class Controller
|
||||
{
|
||||
//
|
||||
protected function seoNoIndex(): void
|
||||
{
|
||||
SEOTools::metatags()->setRobots('noindex, nofollow');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,8 +5,11 @@ namespace App\Http\Controllers;
|
||||
use App\Helpers\EntryHelpers;
|
||||
use App\Models\Entry;
|
||||
use App\Models\News;
|
||||
use Artesaos\SEOTools\Facades\SEOTools;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class EntryController extends Controller
|
||||
@@ -16,6 +19,7 @@ class EntryController extends Controller
|
||||
|
||||
public function index(): View
|
||||
{
|
||||
SEOTools::setTitle('Database');
|
||||
return view('entries.index');
|
||||
}
|
||||
|
||||
@@ -26,6 +30,7 @@ class EntryController extends Controller
|
||||
|
||||
public function show(string $section, Entry $entry): View
|
||||
{
|
||||
|
||||
if (!in_array($section, self::SECTION_TYPES))
|
||||
abort(404);
|
||||
|
||||
@@ -52,6 +57,13 @@ class EntryController extends Controller
|
||||
$comments = EntryHelpers::getLatestComments($entry);
|
||||
$reviews = $entry->reviews()->orderBy('created_at', 'desc')->limit(10)->get();
|
||||
|
||||
SEOTools::setTitle($entry->complete_title ?? $entry->title);
|
||||
SEOTools::setDescription( Str::limit( $entry->description, 150) );
|
||||
SEOTools::opengraph()->addProperty('type', 'article');
|
||||
if( $entry->main_image ){
|
||||
SEOTools::opengraph()->addImage( url( Storage::url( $entry->main_image ) ) );
|
||||
}
|
||||
|
||||
return view('entries.show', compact('entry', 'section', 'comments', 'reviews'));
|
||||
|
||||
}
|
||||
@@ -69,6 +81,7 @@ class EntryController extends Controller
|
||||
->orderBy('updated_at', 'desc')
|
||||
->paginate(20);
|
||||
|
||||
SEOTools::setTitle('My Drafts');
|
||||
return view('entries.drafts', compact('drafts', 'newsDrafts'));
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Entry;
|
||||
use App\Services\ActivityService;
|
||||
use Artesaos\SEOTools\Facades\SEOTools;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
use App\Models\News;
|
||||
@@ -15,6 +16,8 @@ class HomeController extends Controller
|
||||
|
||||
public function index( Request $request ): View {
|
||||
|
||||
SEOTools::setTitle('A Romhack community where you can share your creations with the world.');
|
||||
|
||||
$filters = [ 'entries', 'news', 'messages', 'threads', 'clubs', 'reviews' ];
|
||||
|
||||
$cookie = $request->cookie('activity_filters');
|
||||
|
||||
@@ -4,10 +4,16 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Jobs\RestoreXenForoCommentsThread;
|
||||
use App\Models\Entry;
|
||||
use Artesaos\SEOTools\Facades\SEOTools;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ModCPController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
SEOTools::setTitle('ModCP');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$stats = [
|
||||
|
||||
@@ -11,14 +11,18 @@ use App\Http\Requests\StoreNewsRequest;
|
||||
use App\Jobs\DeleteXenForoCommentsThread;
|
||||
use App\Models\News;
|
||||
use App\Services\NewsService;
|
||||
use Artesaos\SEOTools\Facades\SEOTools;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class NewsController extends Controller
|
||||
{
|
||||
|
||||
public function index()
|
||||
{
|
||||
SEOTools::setTitle('News');
|
||||
return view('news.index');
|
||||
}
|
||||
|
||||
@@ -43,6 +47,13 @@ class NewsController extends Controller
|
||||
|
||||
$comments = EntryHelpers::getLatestComments($news);
|
||||
|
||||
SEOTools::setTitle($news->title);
|
||||
SEOTools::setDescription( Str::limit( $news->description , 150 ) );
|
||||
SEOTools::opengraph()->addProperty('type', 'article');
|
||||
if( $news->gallery->first() ){
|
||||
SEOTools::opengraph()->addImage( url( Storage::url( $news->gallery->first()->image ) ) );
|
||||
}
|
||||
|
||||
return view('news.show', compact('news', 'comments'));
|
||||
}
|
||||
|
||||
@@ -54,6 +65,7 @@ class NewsController extends Controller
|
||||
'oldCategory' => old('category') ? [ old('category') ] : []
|
||||
];
|
||||
|
||||
SEOTools::setTitle('Submit News');
|
||||
return view ('news.create', $data);
|
||||
}
|
||||
|
||||
@@ -65,6 +77,7 @@ class NewsController extends Controller
|
||||
'oldCategory' => old('category', $news->category_id) ? [ old('category', $news->category_id) ] : []
|
||||
];
|
||||
|
||||
SEOTools::setTitle('Edit News');
|
||||
return view ('news.edit', $data);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Helpers\XenForoHelpers;
|
||||
use App\Models\Entry;
|
||||
use App\Models\News;
|
||||
use App\Services\XenforoService;
|
||||
use Artesaos\SEOTools\Facades\SEOTools;
|
||||
use Illuminate\Http\Request;
|
||||
class QueueController extends Controller
|
||||
{
|
||||
@@ -35,6 +36,7 @@ class QueueController extends Controller
|
||||
return $a->created_at <=> $b->created_at;
|
||||
})->values();
|
||||
|
||||
SEOTools::setTitle('Submissions Queue');
|
||||
return view('queue.index', compact('entries'));
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Exceptions\SubmissionException;
|
||||
use App\Http\Requests\StoreReviewRequest;
|
||||
use App\Models\Entry;
|
||||
use App\Services\ReviewsService;
|
||||
use Artesaos\SEOTools\SEOTools;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ReviewController extends Controller
|
||||
@@ -15,6 +16,7 @@ class ReviewController extends Controller
|
||||
|
||||
public function index(){
|
||||
|
||||
SEOTools::setTitle('Reviews');
|
||||
return view('reviews.index');
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ use App\Models\Status;
|
||||
use App\Models\System;
|
||||
use App\Services\SubmissionsService;
|
||||
use App\Services\XenforoApiService;
|
||||
use Artesaos\SEOTools\Facades\SEOTools;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
@@ -86,6 +87,7 @@ class SubmissionController extends Controller
|
||||
'border' => '#eed6c540',
|
||||
] ];
|
||||
|
||||
SEOTools::setTitle('Submit');
|
||||
return view('submissions.index', compact('entryTypes'));
|
||||
}
|
||||
|
||||
@@ -119,6 +121,7 @@ class SubmissionController extends Controller
|
||||
$data['levels'] = Level::orderBy('id')->get();
|
||||
}
|
||||
|
||||
SEOTools::setTitle( $data['words']['page_title'] );
|
||||
return view('submissions.create', $data);
|
||||
}
|
||||
|
||||
@@ -156,6 +159,7 @@ class SubmissionController extends Controller
|
||||
$data['levels'] = Level::orderBy('id')->get();
|
||||
}
|
||||
|
||||
SEOTools::setTitle( $data['words']['page_title'] );
|
||||
return view('submissions.edit', $data);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
||||
use App\Models\Entry;
|
||||
use App\Models\EntryFile;
|
||||
use App\Services\FileServersService;
|
||||
use Artesaos\SEOTools\Facades\SEOTools;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ToolsController extends Controller
|
||||
@@ -31,7 +32,7 @@ class ToolsController extends Controller
|
||||
];
|
||||
|
||||
|
||||
|
||||
SEOTools::setTitle('ROM Patcher');
|
||||
return view('tools.patcher', compact('patches'));
|
||||
}
|
||||
|
||||
@@ -59,11 +60,13 @@ class ToolsController extends Controller
|
||||
'outputName' => $file->filename
|
||||
];
|
||||
|
||||
SEOTools::setTitle('Play online');
|
||||
return view('tools.play', compact('patches', 'emuConfig'));
|
||||
}
|
||||
|
||||
public function hasher( Request $request )
|
||||
{
|
||||
SEOTools::setTitle('Play online');
|
||||
return view('tools.hasher');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user