2022-05-02 23:42:30 +02:00
|
|
|
<template>
|
|
|
|
<modals-modal v-model="show" name="rss-feed-modal" :width="600" :height="'unset'" :processing="processing">
|
|
|
|
<template #outer>
|
|
|
|
<div class="absolute top-0 left-0 p-5 w-2/3 overflow-hidden">
|
|
|
|
<p class="font-book text-3xl text-white truncate">{{ title }}</p>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<div ref="wrapper" class="px-8 py-6 w-full text-sm rounded-lg bg-bg shadow-lg border border-black-300 relative overflow-hidden">
|
2022-05-04 01:52:34 +02:00
|
|
|
<div v-if="currentFeedUrl" class="w-full">
|
2022-05-02 23:42:30 +02:00
|
|
|
<p class="text-lg font-semibold mb-4">Podcast RSS Feed is Open</p>
|
|
|
|
|
|
|
|
<div class="w-full relative">
|
2022-05-04 01:52:34 +02:00
|
|
|
<ui-text-input v-model="currentFeedUrl" readonly />
|
2022-05-02 23:42:30 +02:00
|
|
|
|
2022-05-04 01:52:34 +02:00
|
|
|
<span class="material-icons absolute right-2 bottom-2 p-0.5 text-base transition-transform duration-100 text-gray-300 hover:text-white transform hover:scale-125 cursor-pointer" @click="copyToClipboard(currentFeedUrl)">content_copy</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div v-else class="w-full">
|
|
|
|
<p class="text-lg font-semibold mb-4">Open RSS Feed</p>
|
|
|
|
|
2022-05-12 01:34:17 +02:00
|
|
|
<div class="w-full relative mb-2">
|
2022-05-04 01:52:34 +02:00
|
|
|
<ui-text-input-with-label v-model="newFeedSlug" label="RSS Feed Slug" />
|
|
|
|
<p class="text-xs text-gray-400 py-0.5 px-1">Feed will be {{ demoFeedUrl }}</p>
|
2022-05-02 23:42:30 +02:00
|
|
|
</div>
|
2022-05-12 01:34:17 +02:00
|
|
|
|
|
|
|
<p v-if="isHttp" class="w-full pt-2 text-warning text-xs">Warning: Most podcast apps will require the RSS feed URL is using HTTPS</p>
|
|
|
|
<p v-if="hasEpisodesWithoutPubDate" class="w-full pt-2 text-warning text-xs">Warning: 1 or more of your episodes do not have a Pub Date. Some podcast apps require this.</p>
|
2022-05-02 23:42:30 +02:00
|
|
|
</div>
|
|
|
|
<div v-show="userIsAdminOrUp" class="flex items-center pt-6">
|
2022-05-12 01:34:17 +02:00
|
|
|
<p class="text-xs text-gray-300">Note: RSS feed URLs are not authenticated</p>
|
2022-05-02 23:42:30 +02:00
|
|
|
<div class="flex-grow" />
|
2022-05-04 01:52:34 +02:00
|
|
|
<ui-btn v-if="currentFeedUrl" color="error" small @click="closeFeed">Close RSS Feed</ui-btn>
|
|
|
|
<ui-btn v-else color="success" small @click="openFeed">Open RSS Feed</ui-btn>
|
2022-05-02 23:42:30 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</modals-modal>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
value: Boolean,
|
|
|
|
libraryItem: {
|
|
|
|
type: Object,
|
|
|
|
default: () => null
|
|
|
|
},
|
|
|
|
feedUrl: String
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2022-05-04 01:52:34 +02:00
|
|
|
processing: false,
|
|
|
|
newFeedSlug: null,
|
|
|
|
currentFeedUrl: null
|
2022-05-02 23:42:30 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
show: {
|
|
|
|
immediate: true,
|
|
|
|
handler(newVal) {
|
|
|
|
if (newVal) {
|
|
|
|
this.init()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
show: {
|
|
|
|
get() {
|
|
|
|
return this.value
|
|
|
|
},
|
|
|
|
set(val) {
|
|
|
|
this.$emit('input', val)
|
|
|
|
}
|
|
|
|
},
|
2022-05-04 01:52:34 +02:00
|
|
|
libraryItemId() {
|
|
|
|
return this.libraryItem.id
|
|
|
|
},
|
2022-05-02 23:42:30 +02:00
|
|
|
media() {
|
|
|
|
return this.libraryItem.media || {}
|
|
|
|
},
|
|
|
|
mediaMetadata() {
|
|
|
|
return this.media.metadata || {}
|
|
|
|
},
|
|
|
|
title() {
|
|
|
|
return this.mediaMetadata.title
|
|
|
|
},
|
|
|
|
userIsAdminOrUp() {
|
|
|
|
return this.$store.getters['user/getIsAdminOrUp']
|
2022-05-04 01:52:34 +02:00
|
|
|
},
|
|
|
|
demoFeedUrl() {
|
|
|
|
return `${window.origin}/feed/${this.newFeedSlug}`
|
2022-05-12 01:34:17 +02:00
|
|
|
},
|
|
|
|
isHttp() {
|
|
|
|
return window.origin.startsWith('http://')
|
|
|
|
},
|
|
|
|
episodes() {
|
|
|
|
return this.media.episodes || []
|
|
|
|
},
|
|
|
|
hasEpisodesWithoutPubDate() {
|
|
|
|
return this.episodes.some((ep) => !ep.pubDate)
|
2022-05-02 23:42:30 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2022-05-04 01:52:34 +02:00
|
|
|
openFeed() {
|
|
|
|
if (!this.newFeedSlug) {
|
|
|
|
this.$toast.error('Must set a feed slug')
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
var sanitized = this.$sanitizeSlug(this.newFeedSlug)
|
|
|
|
if (this.newFeedSlug !== sanitized) {
|
|
|
|
this.newFeedSlug = sanitized
|
|
|
|
this.$toast.warning('Slug had to be modified - Run again')
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
const payload = {
|
|
|
|
serverAddress: window.origin,
|
|
|
|
slug: this.newFeedSlug
|
|
|
|
}
|
|
|
|
if (this.$isDev) payload.serverAddress = 'http://localhost:3333'
|
|
|
|
|
|
|
|
console.log('Payload', payload)
|
|
|
|
this.$axios
|
2022-05-20 01:51:58 +02:00
|
|
|
.$post(`/api/items/${this.libraryItemId}/open-feed`, payload)
|
2022-05-04 01:52:34 +02:00
|
|
|
.then((data) => {
|
|
|
|
if (data.success) {
|
|
|
|
console.log('Opened RSS Feed', data)
|
|
|
|
this.currentFeedUrl = data.feedUrl
|
|
|
|
} else {
|
|
|
|
const errorMsg = data.error || 'Unknown error'
|
|
|
|
this.$toast.error(errorMsg)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
console.error('Failed to open RSS Feed', error)
|
|
|
|
this.$toast.error()
|
|
|
|
})
|
|
|
|
},
|
2022-05-02 23:42:30 +02:00
|
|
|
copyToClipboard(str) {
|
|
|
|
this.$copyToClipboard(str, this)
|
|
|
|
},
|
|
|
|
closeFeed() {
|
|
|
|
this.processing = true
|
|
|
|
this.$axios
|
2022-05-20 01:51:58 +02:00
|
|
|
.$post(`/api/items/${this.libraryItem.id}/close-feed`)
|
2022-05-02 23:42:30 +02:00
|
|
|
.then(() => {
|
|
|
|
this.$toast.success('RSS Feed Closed')
|
|
|
|
this.show = false
|
|
|
|
this.processing = false
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
console.error('Failed to close RSS feed', error)
|
|
|
|
this.processing = false
|
|
|
|
this.$toast.error()
|
|
|
|
})
|
|
|
|
},
|
2022-05-04 01:52:34 +02:00
|
|
|
init() {
|
|
|
|
if (!this.libraryItem) return
|
|
|
|
this.newFeedSlug = this.libraryItem.id
|
|
|
|
this.currentFeedUrl = this.feedUrl
|
|
|
|
}
|
2022-05-02 23:42:30 +02:00
|
|
|
},
|
|
|
|
mounted() {}
|
|
|
|
}
|
|
|
|
</script>
|