From 8c3642e868316e0c581d5aa62200240f2a088129 Mon Sep 17 00:00:00 2001 From: lesion Date: Tue, 5 Mar 2019 21:57:53 +0100 Subject: [PATCH] fix #1 - description link clickable --- app/controller/event.js | 1 - app/controller/user.js | 12 ++++++++++-- client/src/assets/main.css | 4 ++++ client/src/components/EventDetail.vue | 2 +- client/src/components/newEvent.vue | 2 +- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/controller/event.js b/app/controller/event.js index 4229a0da..397b66e4 100644 --- a/app/controller/event.js +++ b/app/controller/event.js @@ -34,7 +34,6 @@ const eventController = { }, async updatePlace (req, res) { const place = await Place.findByPk(req.body.id) - console.log(place) await place.update(req.body) res.json(place) }, diff --git a/app/controller/user.js b/app/controller/user.js index bdf848ff..9241229c 100644 --- a/app/controller/user.js +++ b/app/controller/user.js @@ -52,11 +52,14 @@ const userController = { } }, - async addEvent (req, res, next) { + async addEvent (req, res) { const body = req.body + const description = body.description + .replace(/(<([^>]+)>)/ig, '') + .replace(/(https?:\/\/[^\s]+)/g, '$1') const eventDetails = { title: body.title, - description: body.description, + description, multidate: body.multidate, start_datetime: body.start_datetime, end_datetime: body.end_datetime @@ -99,6 +102,11 @@ const userController = { async updateEvent (req, res) { const body = req.body const event = await Event.findByPk(body.id) + + body.description = body.description + .replace(/(<([^>]+)>)/ig, '') // remove all tags from description + .replace(/(https?:\/\/[^\s]+)/g, '$1') // add links + await event.update(body) let place try { diff --git a/client/src/assets/main.css b/client/src/assets/main.css index 672dc25a..9badc857 100644 --- a/client/src/assets/main.css +++ b/client/src/assets/main.css @@ -23,4 +23,8 @@ pre { .el-tag:hover { cursor: pointer; +} + +a, a:hover { + color: orange; } \ No newline at end of file diff --git a/client/src/components/EventDetail.vue b/client/src/components/EventDetail.vue index 11139749..39e28003 100644 --- a/client/src/components/EventDetail.vue +++ b/client/src/components/EventDetail.vue @@ -11,7 +11,7 @@ span {{event.place.name}} - {{event.place.address}} br b-card-body(v-if='event.description || event.tags') - pre {{event.description}} + pre(v-html='event.description') br el-tag.mr-1(:color='tag.color' v-for='tag in event.tags' size='mini') {{tag.tag}} diff --git a/client/src/components/newEvent.vue b/client/src/components/newEvent.vue index 60e5b730..63e075ad 100644 --- a/client/src/components/newEvent.vue +++ b/client/src/components/newEvent.vue @@ -93,7 +93,7 @@ export default { this.time.start = moment(event.start_datetime).format('HH:mm') this.time.end = moment(event.end_datetime).format('HH:mm') this.event.title = event.title - this.event.description = event.description + this.event.description = event.description.replace(/(<([^>]+)>)/ig, '') this.event.id = event.id if (event.tags) { this.event.tags = event.tags.map(t => t.tag)