Skip to content
Snippets Groups Projects
Episode.vue 4.15 KiB
Newer Older
<!--
  - @copyright Copyright (c) 2020 Jonas Heinrich
  -
  - @author Jonas Heinrich <onny@project-insanity.org>
  -
  - @license GNU AGPL version 3 or any later version
  -
  - This program is free software: you can redistribute it and/or modify
  - it under the terms of the GNU Affero General Public License as
  - published by the Free Software Foundation, either version 3 of the
  - License, or (at your option) any later version.
  -
  - This program is distributed in the hope that it will be useful,
  - but WITHOUT ANY WARRANTY; without even the implied warranty of
  - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  - GNU Affero General Public License for more details.
  -
  - You should have received a copy of the GNU Affero General Public License
  - along with this program. If not, see <http://www.gnu.org/licenses/>.
  -
  -->
<template>
	<div>
		<ShowEmpty v-show="pageLoading" />
		<transition name="fade">
			<div v-show="!pageLoading">
				<MediaHeader
					:imgurl="episode.imgURL"
					:title="episode.title"
					:author="episode.author"
					:html-url="episode.htmlURL">
					<button class="icon-play-white podcastButton button primary new-button">
						{{ t('podcast', 'Play episode') }}
					</button>
					<br><br>
					<span>
						<b>Duration:</b>
						{{ episode.duration_string }}
					</span>
					<br>
					<span>
						<b>Publication date:</b>
						{{ readableDate(episode.pubdate) }}
					</span>
				</MediaHeader>
				<ContentCollapsable
					title="Episode notes">
			    <p v-html="episode.description" />
			    <!-- eslint-enable -->
				</ContentCollapsable>
				<ContentCollapsable
					v-show="episode.chapters"
					title="Episode chapters">
					<table class="chapterTable">
						<tbody>
							<tr
								v-for="(chapter, idx) in episode.chapters"
								:key="idx">
								<td class="timeColumn">
									{{ readableTime(chapter.start) }}
								</td>
								<td class="titleColumn">
									{{ chapter.title }}
				</ContentCollapsable>
import { showError } from '@nextcloud/dialogs'
import axios from '@nextcloud/axios'
import ShowEmpty from './ShowEmpty'
import ContentCollapsable from '../components/ContentCollapsable'
import MediaHeader from '../components/MediaHeader'

import TimeAgo from 'javascript-time-ago'
const timeAgo = new TimeAgo('en-US')

export default {
	name: 'Episode',
	components: {
		ContentCollapsable,
		MediaHeader,
		pageLoading: false,
	}),
	mounted() {
		this.pageLoading = true
		const episodeId = this.$route.params.episodeId
		this.queryEpisode(episodeId)
		readableTime(timestamp) {
			return timestamp.split('.')[0]
		},
		readableDate(datetime) {
			return timeAgo.format(Date.parse(datetime), 'twitter-minute-now')
		async queryEpisode(episodeId) {
			const queryURI = 'https://api.fyyd.de/0.2/episode'
			try {
				delete axios.defaults.headers.requesttoken
				await axios.get(queryURI, {
					params: {
						episode_id: episodeId,
					},
				})
					.then(function(response) {
						vm.processPodcast(response.data)
					})
			} catch (error) {
				showError(t('podcast', 'Could not fetch episode from remote API'))
		processPodcast(episode) {
			this.episode = episode.data
			this.pageLoading = false
		},
.episodeContent {
	p {
		padding: 10px 30px;
		max-width: 550px;
		margin-top: 1px;
	}
}

table.chapterTable {
	width: 100%;
	min-width: 250px;
	table-layout:fixed;
	position: relative;
	margin-top: 1px;
			padding: 15px 0px;
			padding-left: 30px;
			font-style: normal;
			border-bottom: 1px solid var(--color-border);
			cursor: pointer;
		}

		tr {
			height: 30px;
			background-color: var(--color-background-light);
			transition: opacity 500ms ease 0s;

			tr:hover, tr:focus, tr.mouseOver td {
				background-color: var(--color-background-hover);
			}

		}

		tr td * {
			cursor: pointer;
		}

		td.timeColumn {
			width: 120px;
			color: #1976d2;
		}
		td.titleColumn {
			padding-left: 0px;
		}