mirror of
https://framagit.org/les/gancio.git
synced 2025-02-01 00:52:01 +01:00
use res.download to download flyer
This commit is contained in:
parent
e8ed2ec4b0
commit
81c2bd3dd1
3 changed files with 8 additions and 4 deletions
|
@ -49,7 +49,7 @@ v-container#event.pa-0.pa-sm-2
|
||||||
:href='`/api/event/${event.slug || event.id}.ics`')
|
:href='`/api/event/${event.slug || event.id}.ics`')
|
||||||
v-icon(v-text='mdiCalendarExport')
|
v-icon(v-text='mdiCalendarExport')
|
||||||
v-btn.ml-2(v-if='hasMedia' large icon :title="$t('event.download_flyer')" color='primary' :aria-label="$t('event.download_flyer')"
|
v-btn.ml-2(v-if='hasMedia' large icon :title="$t('event.download_flyer')" color='primary' :aria-label="$t('event.download_flyer')"
|
||||||
:href='event | mediaURL')
|
:href='event | mediaURL("download")')
|
||||||
v-icon(v-text='mdiFileDownloadOutline')
|
v-icon(v-text='mdiFileDownloadOutline')
|
||||||
|
|
||||||
.p-description.text-body-1.pa-3.rounded(v-if='hasMedia && event.description' itemprop='description' v-html='event.description')
|
.p-description.text-body-1.pa-3.rounded(v-if='hasMedia && event.description' itemprop='description' v-html='event.description')
|
||||||
|
|
|
@ -42,14 +42,15 @@ export default ({ app, store }) => {
|
||||||
// shown in mobile homepage
|
// shown in mobile homepage
|
||||||
Vue.filter('day', value => dayjs.unix(value).tz().locale(store.state.locale).format('dddd, D MMM'))
|
Vue.filter('day', value => dayjs.unix(value).tz().locale(store.state.locale).format('dddd, D MMM'))
|
||||||
Vue.filter('mediaURL', (event, type, format = '.jpg') => {
|
Vue.filter('mediaURL', (event, type, format = '.jpg') => {
|
||||||
|
const mediaPath = type === 'download' ? '/download/' : '/media/'
|
||||||
if (event.media && event.media.length) {
|
if (event.media && event.media.length) {
|
||||||
if (type === 'alt') {
|
if (type === 'alt') {
|
||||||
return event.media[0].name
|
return event.media[0].name
|
||||||
} else {
|
} else {
|
||||||
return store.state.settings.baseurl + '/media/' + (type === 'thumb' ? 'thumb/' : '') + event.media[0].url.replace(/.jpg$/, format)
|
return store.state.settings.baseurl + mediaPath + (type === 'thumb' ? 'thumb/' : '') + event.media[0].url.replace(/.jpg$/, format)
|
||||||
}
|
}
|
||||||
} else if (type !== 'alt') {
|
} else if (type !== 'alt') {
|
||||||
return store.state.settings.baseurl + '/media/' + (type === 'thumb' ? 'thumb/' : '') + 'logo.svg'
|
return store.state.settings.baseurl + mediaPath + (type === 'thumb' ? 'thumb/' : '') + 'logo.svg'
|
||||||
}
|
}
|
||||||
return ''
|
return ''
|
||||||
})
|
})
|
||||||
|
|
|
@ -91,6 +91,9 @@ module.exports = {
|
||||||
const router = express.Router()
|
const router = express.Router()
|
||||||
// serve images/thumb
|
// serve images/thumb
|
||||||
router.use('/media/', express.static(config.upload_path, { immutable: true, maxAge: '1y' }), (_req, res) => res.sendStatus(404))
|
router.use('/media/', express.static(config.upload_path, { immutable: true, maxAge: '1y' }), (_req, res) => res.sendStatus(404))
|
||||||
|
router.use('/download/:filename', (req, res, next) => {
|
||||||
|
return res.download(req.params.filename, undefined, { root: config.upload_path }, err => res.status(404).send('Not found (but nice try 😊)'))
|
||||||
|
})
|
||||||
router.use('/noimg.svg', express.static('./static/noimg.svg'))
|
router.use('/noimg.svg', express.static('./static/noimg.svg'))
|
||||||
|
|
||||||
router.use('/logo.png', (req, res, next) => {
|
router.use('/logo.png', (req, res, next) => {
|
||||||
|
|
Loading…
Reference in a new issue