More metadata, descriptions, refresh rate
This commit is contained in:
parent
1804879022
commit
3e0f3a54f9
2 changed files with 54 additions and 8 deletions
|
@ -91,14 +91,18 @@ class PodcastRorController extends ControllerBase {
|
||||||
}
|
}
|
||||||
return $data;
|
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
|
// TODO: add $title argument to the function
|
||||||
$template = $this->twig->loadTemplate(drupal_get_path('module', 'podcast_ror') . '/templates/podcast.html.twig');
|
$template = $this->twig->loadTemplate(drupal_get_path('module', 'podcast_ror') . '/templates/podcast.html.twig');
|
||||||
$query_results = $this->query($query);
|
$query_results = $this->query($query);
|
||||||
$tmpl_data = [ 'ror' => array('podcast' => $query_results,
|
$tmpl_data = [ 'ror' => array('podcast' => $query_results,
|
||||||
'url' => \Drupal::service('path.current')->getPath(),
|
'url' => \Drupal::service('path.current')->getPath(),
|
||||||
'description' => $description,
|
'description' => $description,
|
||||||
'title' => 'Radio Onda Rossa',
|
'title' => $title,
|
||||||
|
'link' => $link,
|
||||||
|
'expected_episodes_per_week' => $expected_episodes_per_week,
|
||||||
)];
|
)];
|
||||||
$headers = array(
|
$headers = array(
|
||||||
'Content-Type' => 'application/rss+xml',
|
'Content-Type' => 'application/rss+xml',
|
||||||
|
@ -126,19 +130,40 @@ class PodcastRorController extends ControllerBase {
|
||||||
}
|
}
|
||||||
public function podcastAll() {
|
public function podcastAll() {
|
||||||
$query = \Drupal::entityQuery('node');
|
$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) {
|
public function podcastByType($contentType) {
|
||||||
$query = \Drupal::entityQuery('node')
|
$query = \Drupal::entityQuery('node')
|
||||||
->condition('type', $contentType);
|
->condition('type', $contentType);
|
||||||
// TODO: get "nice name" for $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) {
|
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')
|
$query = \Drupal::entityQuery('node')
|
||||||
->condition('type', 'news_trasmissioni')
|
->condition('type', 'news_trasmissioni')
|
||||||
->condition('field_trasmissione', $trxID);
|
->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,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,30 @@
|
||||||
xmlns:atom="http://www.w3.org/2005/Atom"
|
xmlns:atom="http://www.w3.org/2005/Atom"
|
||||||
xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
|
xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
|
||||||
xmlns:podcast="https://podcastindex.org/namespace/1.0"
|
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/"
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
version="2.0">
|
version="2.0">
|
||||||
<channel>
|
<channel>
|
||||||
<atom:link href="http://www.ondarossa.info{{ ror.url | escape("html_attr") }}" rel="self" type="application/rss+xml" />
|
<atom:link href="http://www.ondarossa.info{{ ror.url | escape("html_attr") }}" rel="self" type="application/rss+xml" />
|
||||||
|
{% if ror.expected_episodes_per_week > 1 %}
|
||||||
|
<ttl>30</ttl>
|
||||||
|
<sy:updatePeriod>hourly</sy:updatePeriod>
|
||||||
|
<sy:updateFrequency>6</sy:updateFrequency>
|
||||||
|
{% else %}
|
||||||
|
<ttl>360</ttl>
|
||||||
|
<sy:updatePeriod>daily</sy:updatePeriod>
|
||||||
|
<sy:updateFrequency>3</sy:updateFrequency>
|
||||||
|
{% endif %}
|
||||||
|
<skipHours>
|
||||||
|
<hour>1</hour>
|
||||||
|
<hour>2</hour>
|
||||||
|
<hour>3</hour>
|
||||||
|
<hour>4</hour>
|
||||||
|
<hour>5</hour>
|
||||||
|
<hour>6</hour>
|
||||||
|
</skipHours>
|
||||||
<title>{{ror.title}}</title>
|
<title>{{ror.title}}</title>
|
||||||
<link>http://www.ondarossa.info</link>
|
<link>{{ror.link}}</link>
|
||||||
<language>it-it</language>
|
<language>it-it</language>
|
||||||
<itunes:subtitle>La radio di chi se la sente</itunes:subtitle>
|
<itunes:subtitle>La radio di chi se la sente</itunes:subtitle>
|
||||||
<itunes:author>Ondarossa</itunes:author>
|
<itunes:author>Ondarossa</itunes:author>
|
||||||
|
@ -20,7 +38,10 @@
|
||||||
</itunes:owner>
|
</itunes:owner>
|
||||||
<itunes:explicit>no</itunes:explicit>
|
<itunes:explicit>no</itunes:explicit>
|
||||||
<itunes:image href="http://www.ondarossa.info/favicon.png" />
|
<itunes:image href="http://www.ondarossa.info/favicon.png" />
|
||||||
<itunes:category text="News & Politics"/>
|
<itunes:type>episodic</itunes:type>
|
||||||
|
<itunes:category text="News">
|
||||||
|
<itunes:category text="Politics"/>
|
||||||
|
</itunes:category >
|
||||||
<podcast:funding url="http://www.ondarossa.info/sostieni">Sostieni ondarossa</podcast:funding>
|
<podcast:funding url="http://www.ondarossa.info/sostieni">Sostieni ondarossa</podcast:funding>
|
||||||
|
|
||||||
{% for nid, node in ror.podcast.nodes %}
|
{% for nid, node in ror.podcast.nodes %}
|
||||||
|
|
Loading…
Reference in a new issue