diff --git a/components/Home.vue b/components/Home.vue index 32f853c4..10554917 100644 --- a/components/Home.vue +++ b/components/Home.vue @@ -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' } ] } }, diff --git a/package.json b/package.json index f76969bc..65618ed7 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/pages/event/_id.vue b/pages/event/_id.vue index b5c6488e..cc1ed4f6 100644 --- a/pages/event/_id.vue +++ b/pages/event/_id.vue @@ -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,7 +91,12 @@ 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 + ] } }, async asyncData ({ $axios, params, error }) { diff --git a/pages/export.vue b/pages/export.vue index a9ab2bff..d8b898fc 100644 --- a/pages/export.vue +++ b/pages/export.vue @@ -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)) } } } diff --git a/server/api/controller/export.js b/server/api/controller/export.js index eef46214..8ff1e823 100644 --- a/server/api/controller/export.js +++ b/server/api/controller/export.js @@ -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) { diff --git a/server/routes.js b/server/routes.js index eefe59bf..2dc0c523 100644 --- a/server/routes.js +++ b/server/routes.js @@ -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