repod/src/components/Feed/Banner.vue

158 lines
2.8 KiB
Vue
Raw Normal View History

2023-08-23 10:11:39 +02:00
<template>
<div class="header">
<img class="background" :src="imageUrl" />
2023-08-23 10:11:39 +02:00
<div class="content">
<div>
<NcAvatar
:display-name="author || title"
:is-no-user="true"
:size="128"
:url="imageUrl" />
<a class="feed" :href="url" @click.prevent="copyFeed">
2024-03-16 18:35:31 +01:00
<RssIcon :size="20" />
<i>{{ t('repod', 'Copy feed') }}</i>
</a>
</div>
2023-12-24 10:58:37 +01:00
<div class="inner">
<div class="infos">
<h2>{{ title }}</h2>
<a :href="link" target="_blank">
<i>{{ author }}</i>
</a>
<br /><br />
<SafeHtml :source="description" />
2023-12-24 10:58:37 +01:00
</div>
<NcAppNavigationNew
v-if="!isSubscribed"
2024-01-10 15:25:54 +01:00
:text="t('repod', 'Subscribe')"
2023-12-24 10:58:37 +01:00
@click="addSubscription">
<template #icon>
2024-03-16 18:35:31 +01:00
<PlusIcon :size="20" />
2023-12-24 10:58:37 +01:00
</template>
</NcAppNavigationNew>
2023-08-23 10:11:39 +02:00
</div>
</div>
</div>
</template>
<script>
import { NcAppNavigationNew, NcAvatar } from '@nextcloud/vue'
import { showError, showSuccess } from '../../utils/toast.js'
2024-03-16 18:35:31 +01:00
import PlusIcon from 'vue-material-design-icons/Plus.vue'
import RssIcon from 'vue-material-design-icons/Rss.vue'
import SafeHtml from '../Atoms/SafeHtml.vue'
2023-08-23 17:54:09 +02:00
import axios from '@nextcloud/axios'
import { decodeUrl } from '../../utils/url.js'
2023-08-23 17:54:09 +02:00
import { generateUrl } from '@nextcloud/router'
2023-08-23 10:11:39 +02:00
export default {
name: 'Banner',
components: {
NcAvatar,
NcAppNavigationNew,
2024-03-16 18:35:31 +01:00
PlusIcon,
RssIcon,
SafeHtml,
2023-08-23 10:11:39 +02:00
},
props: {
author: {
type: String,
required: true,
},
2023-08-23 17:54:09 +02:00
description: {
type: String,
required: true,
},
2023-08-23 10:11:39 +02:00
imageUrl: {
type: String,
required: true,
},
link: {
type: String,
required: true,
},
title: {
type: String,
required: true,
},
},
2023-08-23 17:54:09 +02:00
computed: {
url() {
return decodeUrl(this.$route.params.url)
2023-08-23 17:54:09 +02:00
},
2023-08-24 22:29:11 +02:00
isSubscribed() {
return this.$store.state.subscriptions.subscriptions.includes(this.url)
},
2023-08-23 17:54:09 +02:00
},
methods: {
async addSubscription() {
try {
await axios.post(
generateUrl('/apps/gpoddersync/subscription_change/create'),
{
add: [this.url],
remove: [],
},
)
2023-08-23 17:54:09 +02:00
} catch (e) {
console.error(e)
2024-01-10 15:25:54 +01:00
showError(t('repod', 'Error while adding the feed'))
2023-08-23 17:54:09 +02:00
}
this.$store.dispatch('subscriptions/fetch')
},
copyFeed() {
window.navigator.clipboard.writeText(this.url)
showSuccess(t('repod', 'Link copied to the clipboard'))
},
2023-08-23 17:54:09 +02:00
},
2023-08-23 10:11:39 +02:00
}
</script>
<style scoped>
.background {
filter: blur(1rem) brightness(50%);
height: auto;
left: 0;
opacity: 0.4;
position: absolute;
top: 0;
width: 100%;
z-index: -1;
}
2023-08-23 10:11:39 +02:00
.content {
display: flex;
gap: 1rem;
height: 10rem;
position: relative;
}
2023-08-23 17:54:09 +02:00
.feed {
display: flex;
gap: 0.2rem;
margin: 0.5rem;
}
.header {
height: 14rem;
overflow: hidden;
padding: 2rem;
position: relative;
}
2023-12-24 10:58:37 +01:00
.infos {
overflow: auto;
}
2023-12-24 10:58:37 +01:00
.inner {
display: flex;
}
2023-12-24 10:58:37 +01:00
@media only screen and (max-width: 768px) {
.inner {
flex-direction: column;
2023-12-24 10:58:37 +01:00
}
}
2023-08-23 10:11:39 +02:00
</style>