Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/nextcloud.com.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJos Poortvliet <jospoortvliet@gmail.com>2020-06-04 21:50:35 +0300
committerJos Poortvliet <jospoortvliet@gmail.com>2020-06-04 21:51:47 +0300
commit9da59d16e42095e464a0eb7f1cd97839896e5e61 (patch)
tree974fbfd1893adbef048bb9d726809714a7770a12 /page-podcast.php
parent8b1fc1a95fab732f5aeeb0a0c9f601b42f4353ad (diff)
make it work ;-)
Signed-off-by: Jos Poortvliet <jospoortvliet@gmail.com>
Diffstat (limited to 'page-podcast.php')
-rw-r--r--page-podcast.php98
1 files changed, 90 insertions, 8 deletions
diff --git a/page-podcast.php b/page-podcast.php
index 11c3e67a..be153681 100644
--- a/page-podcast.php
+++ b/page-podcast.php
@@ -9,12 +9,94 @@ require(["require.config"], function() {
<!-- podcast player scripts - see https://docs.podlove.org/podlove-web-player/embedding.html -->
<script src="https://cdn.podlove.org/web-player/5.x/embed.js"></script>
<script>
-window.podlovePlayer("#podcast-player", "<?php echo get_template_directory_uri(); ?>/assets/podcast/episodes/episode1.json", "<?php echo get_template_directory_uri(); ?>/assets/podcast/config.json")
- .then(store => {
- store.subscribe(() => {
- console.log(store.getState());
+const RSS_URL = "<?php echo get_template_directory_uri(); ?>/podcast-feed.rss";
+const config_URL = "<?php echo get_template_directory_uri(); ?>/assets/podcast/config.json";
+const version = 5;
+const show = {
+ title: "Nextcloud Podcast",
+ subtitle: "Nextcloud's own podcast",
+ summary: "Every week we will talk about a subject concerning the community, data privacy and digital sovereignty",
+ poster: "https://nextcloud.com/media/nextcloud-podcast-logo.png",
+ link: "https://nextcloud.com/podcast"
+ };
+
+Promise.all([
+ fetch(RSS_URL)
+ .then(rss_response => rss_response.text()),
+ fetch(config_URL)
+ .then(config_response => config_response.json())
+]).then((response) => {
+ const rss_data = new window.DOMParser().parseFromString(response[0], "text/xml");
+ const episodes_nodes = rss_data.querySelectorAll("item");
+ let config_data = response[1];
+
+ let episodes_list = [];
+ let playlist = [];
+ episodes_nodes.forEach(episode => {
+ let audio_object = {
+ url: episode.querySelector("enclosure").getAttribute("url"),
+ size: episode.querySelector("enclosure").getAttribute("length"),
+ title: episode.querySelector("title").textContent,
+ mimeType: episode.querySelector("enclosure").getAttribute("type")
+ };
+
+ /**
+ * Episode related Information
+ */
+ let episode_config = {
+ version: version,
+ show: show,
+ title: episode.querySelector("title").textContent,
+ subtitle: episode.getElementsByTagName("itunes:subtitle")[0].textContent,
+ summary: episode.getElementsByTagName("itunes:summary")[0].textContent,
+ publicationDate: episode.querySelector("pubDate").textContent,
+ poster: "https://nextcloud.com/media/nextcloud-podcast-logo.png",
+ duration: episode.getElementsByTagName("itunes:duration")[0].textContent,
+ link: episode.querySelector("link").textContent,
+ audio: [ audio_object ],
+ playlist: [],
+ contributors: [
+ {
+ id: "",
+ name: "",
+ avatar: "",
+ group: { "id": "", "slug": "", "title": "" }
+ }
+ ]
+ };
+ episodes_list.push(episode_config);
+
+ let episode_object = {
+ title: episode_config.title,
+ duration: episode_config.duration,
+ href: episode_config.link,
+ image: "author.jpg",
+ config: {}
+ };
+ playlist.push(episode_object);
+ });
+
+ // add config for each episode in playlist
+ let episode_number = 0;
+ playlist.forEach(episode => {
+ episode.config = episodes_list[episode_number];
+ episode_number++;
});
- });
+
+ // add playlist to episodes
+ episodes_list.forEach(episode => {
+ episode.playlist = playlist;
+ });
+
+ config_data.playlist = playlist;
+ window.podlovePlayer("#podcast-player", episodes_list[0], config_data)
+ .then(store => {
+ store.subscribe(() => {
+ console.log(store.getState());
+ });
+ });
+
+});
</script>
<!-- podcast player scripts -->
@@ -64,9 +146,9 @@ window.podlovePlayer("#podcast-player", "<?php echo get_template_directory_uri()
<div class="row">
<div class="col-md-6 col-md-offset-3">
<ul>
- <?php $business_posts = get_posts( array( 'numberposts' => 5, 'category' => get_cat_ID('podcast') ) );
- foreach ($business_posts as $bpost) { ?>
- <li><a href="<?php echo wp_get_canonical_url($bpost->ID);?>"><?php echo $bpost->post_title;?></a></li>
+ <?php $podcast_posts = get_posts( array( 'numberposts' => 5, 'category' => get_cat_ID('podcast') ) );
+ foreach ($podcast_posts as $ppost) { ?>
+ <li><a href="<?php echo wp_get_canonical_url($ppost->ID);?>"><?php echo $ppost->post_title;?></a></li>
<?php } ; ?>
</ul>
</div>