mirror of
https://framagit.org/les/gancio.git
synced 2025-01-31 16:42:22 +01:00
fix #23, add feed links in pages
This commit is contained in:
parent
46bc1854de
commit
f08273aa10
6 changed files with 28 additions and 11 deletions
|
@ -39,6 +39,9 @@ export default {
|
||||||
{ hid: 'og-title', property: 'og:title', content: this.settings.title },
|
{ hid: 'og-title', property: 'og:title', content: this.settings.title },
|
||||||
{ hid: 'og-url', property: 'og:url', content: this.settings.baseurl },
|
{ hid: 'og-url', property: 'og:url', content: this.settings.baseurl },
|
||||||
{ property: 'og:image', content: this.settings.baseurl + '/favicon.ico' }
|
{ property: 'og:image', content: this.settings.baseurl + '/favicon.ico' }
|
||||||
|
],
|
||||||
|
link: [
|
||||||
|
{ rel: 'alternate', type: 'application/rss+xml', title: this.settings.title, href: this.settings.baseurl + '/feed/rss' }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -17,11 +17,11 @@
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"email": "lesion@autistici.org",
|
"email": "lesion@autistici.org",
|
||||||
"url": "https://framagit.net/les/gancio/issues"
|
"url": "https://framagit.org/les/gancio/issues"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://framagit.net/les/gancio.git"
|
"url": "https://framagit.org/les/gancio"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"gancio": "server/cli.js"
|
"gancio": "server/cli.js"
|
||||||
|
|
|
@ -73,6 +73,10 @@ export default {
|
||||||
|
|
||||||
head () {
|
head () {
|
||||||
if (!this.event) { return {} }
|
if (!this.event) { return {} }
|
||||||
|
const tags_feed = this.event.tags.map(tag => ({ rel: 'alternate', type: 'application/rss+xml',
|
||||||
|
title: `${this.settings.title} events tagged ${tag.tag}`, href: this.settings.baseurl + `/feed/rss?tags=${tag.tag}` }))
|
||||||
|
const place_feed = { rel: 'alternate', type: 'application/rss+xml',
|
||||||
|
title: `${this.settings.title} events @${this.event.place.name}`, href: this.settings.baseurl + `/feed/rss?places=${this.event.placeId}` }
|
||||||
return {
|
return {
|
||||||
title: `${this.settings.title} - ${this.event.title}`,
|
title: `${this.settings.title} - ${this.event.title}`,
|
||||||
meta: [
|
meta: [
|
||||||
|
@ -87,7 +91,12 @@ export default {
|
||||||
{ hid: 'og-url', property: 'og:url', content: `event/${this.event.id}` },
|
{ hid: 'og-url', property: 'og:url', content: `event/${this.event.id}` },
|
||||||
{ property: 'og:type', content: 'event' },
|
{ property: 'og:type', content: 'event' },
|
||||||
{ property: 'og:image', content: this.imgPath }
|
{ property: 'og:image', content: this.imgPath }
|
||||||
]
|
],
|
||||||
|
link: [
|
||||||
|
{ rel: 'alternate', type: 'application/rss+xml', title: this.settings.title, href: this.settings.baseurl + '/feed/rss' },
|
||||||
|
...tags_feed,
|
||||||
|
place_feed
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async asyncData ({ $axios, params, error }) {
|
async asyncData ({ $axios, params, error }) {
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
//- el-input.mt-2(v-model='notification.email' :placeholder="$t('export.insert_your_address')" ref='email')
|
//- el-input.mt-2(v-model='notification.email' :placeholder="$t('export.insert_your_address')" ref='email')
|
||||||
//- el-button.mt-2.float-right(native-type= 'submit' type='success' @click='add_notification') {{$t('common.send')}}
|
//- el-button.mt-2.float-right(native-type= 'submit' type='success' @click='add_notification') {{$t('common.send')}}
|
||||||
|
|
||||||
el-tab-pane.pt-1(label='feed rss' name='feed')
|
el-tab-pane.pt-1(label='feed rss' name='rss')
|
||||||
span(v-html='$t(`export.feed_description`)')
|
span(v-html='$t(`export.feed_description`)')
|
||||||
el-input(v-model='link')
|
el-input(v-model='link')
|
||||||
el-button(slot='append' plain
|
el-button(slot='append' plain
|
||||||
|
@ -73,7 +73,7 @@ export default {
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
type: 'feed',
|
type: 'rss',
|
||||||
notification: { email: '' },
|
notification: { email: '' },
|
||||||
list: { title: 'Gancio' }
|
list: { title: 'Gancio' }
|
||||||
}
|
}
|
||||||
|
@ -128,10 +128,10 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return `${this.settings.baseurl}/api/export/${this.type}${query}`
|
return `${this.settings.baseurl}/feed/${this.type}${query}`
|
||||||
},
|
},
|
||||||
showLink () {
|
showLink () {
|
||||||
return (['feed', 'ics'].includes(this.type))
|
return (['rss', 'ics'].includes(this.type))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const { event: Event, place: Place, tag: Tag } = require('../models')
|
const { event: Event, place: Place, tag: Tag } = require('../models')
|
||||||
const { Op } = require('sequelize')
|
const { Op } = require('sequelize')
|
||||||
const moment = require('moment')
|
const moment = require('moment')
|
||||||
|
const config = require('config')
|
||||||
const ics = require('ics')
|
const ics = require('ics')
|
||||||
|
|
||||||
const exportController = {
|
const exportController = {
|
||||||
|
@ -21,6 +22,7 @@ const exportController = {
|
||||||
if (places) {
|
if (places) {
|
||||||
where.placeId = places.split(',')
|
where.placeId = places.split(',')
|
||||||
}
|
}
|
||||||
|
|
||||||
const events = await Event.findAll({
|
const events = await Event.findAll({
|
||||||
order: ['start_datetime'],
|
order: ['start_datetime'],
|
||||||
where: {
|
where: {
|
||||||
|
@ -30,7 +32,9 @@ const exportController = {
|
||||||
},
|
},
|
||||||
include: [ { model: Tag, ...where_tags }, { model: Place, attributes: ['name', 'id', 'address'] }]
|
include: [ { model: Tag, ...where_tags }, { model: Place, attributes: ['name', 'id', 'address'] }]
|
||||||
})
|
})
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
case 'rss':
|
||||||
case 'feed':
|
case 'feed':
|
||||||
return exportController.feed(res, events.slice(0, 20))
|
return exportController.feed(res, events.slice(0, 20))
|
||||||
case 'ics':
|
case 'ics':
|
||||||
|
@ -42,7 +46,7 @@ const exportController = {
|
||||||
|
|
||||||
feed (res, events) {
|
feed (res, events) {
|
||||||
res.type('application/rss+xml; charset=UTF-8')
|
res.type('application/rss+xml; charset=UTF-8')
|
||||||
res.render('feed/rss.pug', { events, config: process.env, moment })
|
res.render('feed/rss.pug', { events, config, moment })
|
||||||
},
|
},
|
||||||
|
|
||||||
ics (res, events) {
|
ics (res, events) {
|
||||||
|
|
|
@ -6,6 +6,7 @@ const federation = require('./federation')
|
||||||
const webfinger = require('./federation/webfinger')
|
const webfinger = require('./federation/webfinger')
|
||||||
const { spamFilter } = require('./federation/helpers')
|
const { spamFilter } = require('./federation/helpers')
|
||||||
const debug = require('debug')('routes')
|
const debug = require('debug')('routes')
|
||||||
|
const exportController = require('./api/controller/export')
|
||||||
|
|
||||||
const router = express.Router()
|
const router = express.Router()
|
||||||
router.use((req, res, next) => {
|
router.use((req, res, next) => {
|
||||||
|
@ -18,19 +19,19 @@ router.use(spamFilter)
|
||||||
|
|
||||||
router.use('/favicon.ico', express.static(path.resolve(config.favicon || 'assets/favicon.ico')))
|
router.use('/favicon.ico', express.static(path.resolve(config.favicon || 'assets/favicon.ico')))
|
||||||
router.use('/media/', express.static(config.upload_path))
|
router.use('/media/', express.static(config.upload_path))
|
||||||
|
router.get('/feed/:type', exportController.export)
|
||||||
router.use('/api', api)
|
router.use('/api', api)
|
||||||
|
|
||||||
// federation api / activitypub / webfinger / nodeinfo
|
// federation api / activitypub / webfinger / nodeinfo
|
||||||
router.use('/.well-known', webfinger)
|
router.use('/.well-known', webfinger)
|
||||||
router.use('/federation', federation)
|
router.use('/federation', federation)
|
||||||
|
|
||||||
// Handle 404
|
|
||||||
// router.use((req, res) => res.status(404).send('404: Page not found'))
|
|
||||||
|
|
||||||
// Handle 500
|
// Handle 500
|
||||||
router.use((error, req, res, next) => {
|
router.use((error, req, res, next) => {
|
||||||
debug('Error 500: %s', error)
|
debug('Error 500: %s', error)
|
||||||
res.status(500).send('500: Internal Server Error')
|
res.status(500).send('500: Internal Server Error')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// remaining request are for nuxt...
|
||||||
|
|
||||||
module.exports = router
|
module.exports = router
|
||||||
|
|
Loading…
Reference in a new issue