mirror of
https://github.com/ad-aures/castopod.git
synced 2026-04-12 03:06:43 +02:00
feat: add schema.org json-ld objects to podcasts, episodes, posts and comments pages
- refactor meta-tags by generating them in the controller and injecting them into the views - use `melbahja/seo` library to build opengraph and twitter meta-tags + schema.org objects
This commit is contained in:
parent
5c529a83aa
commit
902f959b30
45 changed files with 449 additions and 354 deletions
60
app/Controllers/MapController.php
Normal file
60
app/Controllers/MapController.php
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* @copyright 2020 Podlibre
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
||||
* @link https://castopod.org/
|
||||
*/
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\EpisodeModel;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
|
||||
class MapController extends BaseController
|
||||
{
|
||||
public function index(): string
|
||||
{
|
||||
$locale = service('request')
|
||||
->getLocale();
|
||||
$cacheName = "page_map_{$locale}";
|
||||
if (! ($found = cache($cacheName))) {
|
||||
$found = view('pages/map', [], [
|
||||
'cache' => DECADE,
|
||||
'cache_name' => $cacheName,
|
||||
]);
|
||||
}
|
||||
return $found;
|
||||
}
|
||||
|
||||
public function getEpisodesMarkers(): ResponseInterface
|
||||
{
|
||||
$cacheName = 'episodes_markers';
|
||||
if (! ($found = cache($cacheName))) {
|
||||
$episodes = (new EpisodeModel())
|
||||
->where('`published_at` <= NOW()', null, false)
|
||||
->where('location_geo is not', null)
|
||||
->findAll();
|
||||
$found = [];
|
||||
foreach ($episodes as $episode) {
|
||||
$found[] = [
|
||||
'latitude' => $episode->location->latitude,
|
||||
'longitude' => $episode->location->longitude,
|
||||
'location_name' => $episode->location->name,
|
||||
'location_url' => $episode->location->url,
|
||||
'episode_link' => $episode->link,
|
||||
'podcast_link' => $episode->podcast->link,
|
||||
'cover_path' => $episode->cover->thumbnail_url,
|
||||
'podcast_title' => $episode->podcast->title,
|
||||
'episode_title' => $episode->title,
|
||||
];
|
||||
}
|
||||
// The page cache is set to a decade so it is deleted manually upon episode update
|
||||
cache()
|
||||
->save($cacheName, $found, DECADE);
|
||||
}
|
||||
return $this->response->setJSON($found);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue