repod/src/components/Feed/Banner.vue

143 lines
2.6 KiB
Vue
Raw Normal View History

<!-- eslint-disable vue/no-v-html -->
2023-08-23 10:11:39 +02:00
<template>
<div class="header">
<img class="background" :src="imageUrl">
<div class="content">
2023-08-23 17:54:09 +02:00
<NcAvatar class="avatar"
:display-name="author || title"
2023-08-23 10:11:39 +02:00
:is-no-user="true"
2023-12-23 21:36:20 +01:00
:size="128"
2023-08-23 10:11:39 +02:00
:url="imageUrl" />
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>
<p>
<small v-html="strippedDescription" />
2023-12-24 10:58:37 +01:00
</p>
</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>
<Plus :size="20" />
</template>
</NcAppNavigationNew>
2023-08-23 10:11:39 +02:00
</div>
</div>
</div>
</template>
<script>
import { NcAppNavigationNew, NcAvatar } from '@nextcloud/vue'
import Plus from 'vue-material-design-icons/Plus.vue'
2023-08-23 17:54:09 +02:00
import axios from '@nextcloud/axios'
import { cleanHtml } from '../../utils/text.js'
import { decodeUrl } from '../../utils/url.js'
2023-08-23 17:54:09 +02:00
import { generateUrl } from '@nextcloud/router'
import { showError } from '@nextcloud/dialogs'
2023-08-23 10:11:39 +02:00
export default {
name: 'Banner',
components: {
NcAvatar,
NcAppNavigationNew,
Plus,
},
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)
},
2024-01-10 15:25:54 +01:00
strippedDescription() {
return cleanHtml(this.description)
2024-01-10 15:25:54 +01:00
},
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: [] })
} 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')
},
},
2023-08-23 10:11:39 +02:00
}
</script>
<style scoped>
2023-08-23 17:54:09 +02:00
.avatar {
height: 8rem;
width: 8rem;
2023-08-23 10:11:39 +02:00
}
.background {
2023-08-24 23:59:55 +02:00
filter: blur(1rem) brightness(50%);
2023-08-23 17:54:09 +02:00
height: auto;
left: 0;
2023-08-24 23:59:55 +02:00
opacity: .4;
2023-08-23 10:11:39 +02:00
position: absolute;
top: 0;
width: 100%;
z-index: -1;
2023-08-23 10:11:39 +02:00
}
.content {
2023-08-23 17:54:09 +02:00
display: flex;
gap: 2rem;
height: 10rem;
position: relative;
}
.header {
height: 14rem;
2023-08-24 18:22:40 +02:00
overflow: hidden;
2023-08-23 17:54:09 +02:00
padding: 2rem;
2023-08-23 10:11:39 +02:00
position: relative;
}
2023-12-24 10:58:37 +01:00
.infos {
overflow: auto;
}
.inner {
display: flex;
}
@media only screen and (max-width: 768px) {
.inner {
flex-direction: column;
}
}
2023-08-23 10:11:39 +02:00
</style>