fix #23, add feed links in pages

This commit is contained in:
les 2019-09-17 18:16:59 +02:00
parent 46bc1854de
commit f08273aa10
6 changed files with 28 additions and 11 deletions

View file

@ -39,6 +39,9 @@ export default {
{ hid: 'og-title', property: 'og:title', content: this.settings.title },
{ hid: 'og-url', property: 'og:url', content: this.settings.baseurl },
{ 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' }
]
}
},

View file

@ -17,11 +17,11 @@
"license": "AGPL-3.0",
"bugs": {
"email": "lesion@autistici.org",
"url": "https://framagit.net/les/gancio/issues"
"url": "https://framagit.org/les/gancio/issues"
},
"repository": {
"type": "git",
"url": "https://framagit.net/les/gancio.git"
"url": "https://framagit.org/les/gancio"
},
"bin": {
"gancio": "server/cli.js"

View file

@ -73,6 +73,10 @@ export default {
head () {
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 {
title: `${this.settings.title} - ${this.event.title}`,
meta: [
@ -87,6 +91,11 @@ export default {
{ hid: 'og-url', property: 'og:url', content: `event/${this.event.id}` },
{ property: 'og:type', content: 'event' },
{ 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
]
}
},

View file

@ -19,7 +19,7 @@
//- 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-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`)')
el-input(v-model='link')
el-button(slot='append' plain
@ -73,7 +73,7 @@ export default {
},
data () {
return {
type: 'feed',
type: 'rss',
notification: { email: '' },
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 () {
return (['feed', 'ics'].includes(this.type))
return (['rss', 'ics'].includes(this.type))
}
}
}

View file

@ -1,6 +1,7 @@
const { event: Event, place: Place, tag: Tag } = require('../models')
const { Op } = require('sequelize')
const moment = require('moment')
const config = require('config')
const ics = require('ics')
const exportController = {
@ -21,6 +22,7 @@ const exportController = {
if (places) {
where.placeId = places.split(',')
}
const events = await Event.findAll({
order: ['start_datetime'],
where: {
@ -30,7 +32,9 @@ const exportController = {
},
include: [ { model: Tag, ...where_tags }, { model: Place, attributes: ['name', 'id', 'address'] }]
})
switch (type) {
case 'rss':
case 'feed':
return exportController.feed(res, events.slice(0, 20))
case 'ics':
@ -42,7 +46,7 @@ const exportController = {
feed (res, events) {
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) {

View file

@ -6,6 +6,7 @@ const federation = require('./federation')
const webfinger = require('./federation/webfinger')
const { spamFilter } = require('./federation/helpers')
const debug = require('debug')('routes')
const exportController = require('./api/controller/export')
const router = express.Router()
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('/media/', express.static(config.upload_path))
router.get('/feed/:type', exportController.export)
router.use('/api', api)
// federation api / activitypub / webfinger / nodeinfo
router.use('/.well-known', webfinger)
router.use('/federation', federation)
// Handle 404
// router.use((req, res) => res.status(404).send('404: Page not found'))
// Handle 500
router.use((error, req, res, next) => {
debug('Error 500: %s', error)
res.status(500).send('500: Internal Server Error')
})
// remaining request are for nuxt...
module.exports = router