From 3e0f3a54f9fcd3c9e9e7aa46fe9d37efca75d947 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 30 Nov 2022 17:50:22 +0100 Subject: [PATCH] More metadata, descriptions, refresh rate --- src/Controller/PodcastRorController.php | 37 +++++++++++++++++++++---- templates/podcast.html.twig | 25 +++++++++++++++-- 2 files changed, 54 insertions(+), 8 deletions(-) diff --git a/src/Controller/PodcastRorController.php b/src/Controller/PodcastRorController.php index 83dc8e5..ed61646 100644 --- a/src/Controller/PodcastRorController.php +++ b/src/Controller/PodcastRorController.php @@ -91,14 +91,18 @@ class PodcastRorController extends ControllerBase { } return $data; } - public function podcast($query, $description) { + public function podcast($query, $title, $description, $link, + $expected_episodes_per_week + ) { // TODO: add $title argument to the function $template = $this->twig->loadTemplate(drupal_get_path('module', 'podcast_ror') . '/templates/podcast.html.twig'); $query_results = $this->query($query); $tmpl_data = [ 'ror' => array('podcast' => $query_results, 'url' => \Drupal::service('path.current')->getPath(), 'description' => $description, - 'title' => 'Radio Onda Rossa', + 'title' => $title, + 'link' => $link, + 'expected_episodes_per_week' => $expected_episodes_per_week, )]; $headers = array( 'Content-Type' => 'application/rss+xml', @@ -126,19 +130,40 @@ class PodcastRorController extends ControllerBase { } public function podcastAll() { $query = \Drupal::entityQuery('node'); - return $this->podcast($query, 'Tutti gli aggiornamenti, i redazionali, le trasmissioni della radio di chi se la sente'); + return $this->podcast($query, 'Radio Onda Rossa', 'Tutti gli aggiornamenti, i redazionali, le trasmissioni della radio di chi se la sente', + 'http://www.ondarossa.info/', + 30 + ); } public function podcastByType($contentType) { $query = \Drupal::entityQuery('node') ->condition('type', $contentType); // TODO: get "nice name" for $contentType - return $this->podcast($query, str_replace('+', ', ', $contentType)); + $what = str_replace('+', ', ', $contentType); + return $this->podcast($query, + $what . ' (Radio Onda Rossa)', + $what, + 'http://www.ondarossa.info/', + 30 + ); } public function podcastByTrxID($trxID) { + $term = \Drupal\taxonomy\Entity\Term::load($trxID); + $trxName = $term->getName(); + $trxDescriptionHTML = $term->getDescription(); + $trxDescription = strip_tags($trxDescriptionHTML); + $trxURL = \Drupal\Core\Url::fromRoute('entity.taxonomy_term.canonical', + ['taxonomy_term' => $trxID], + ['absolute' => TRUE])->toString(); $query = \Drupal::entityQuery('node') ->condition('type', 'news_trasmissioni') ->condition('field_trasmissione', $trxID); - // TODO: discover Trx name, and pass it as podcast title - return $this->podcast($query, 'Trasmissione ' . $trxID); + + return $this->podcast($query, + $trxName . ' (Radio Onda Rossa)', + $trxDescription, + $trxURL, + 1, + ); } } diff --git a/templates/podcast.html.twig b/templates/podcast.html.twig index 26ffe29..b250c3b 100644 --- a/templates/podcast.html.twig +++ b/templates/podcast.html.twig @@ -3,12 +3,30 @@ xmlns:atom="http://www.w3.org/2005/Atom" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:podcast="https://podcastindex.org/namespace/1.0" + xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"> +{% if ror.expected_episodes_per_week > 1 %} +30 +hourly +6 +{% else %} +360 +daily +3 +{% endif %} + + 1 + 2 + 3 + 4 + 5 + 6 + {{ror.title}} -http://www.ondarossa.info +{{ror.link}} it-it La radio di chi se la sente Ondarossa @@ -20,7 +38,10 @@ no - +episodic + + + Sostieni ondarossa {% for nid, node in ror.podcast.nodes %}