Commit e467a289 authored by les's avatar les
Browse files

[lint] linting

parent bda72f15
......@@ -34,7 +34,7 @@ export default {
return {
password: '',
email: '',
loading: false,
loading: false
}
},
computed: {
......@@ -61,7 +61,7 @@ export default {
Message({ message: this.$t('login.check_email'), type: 'success' })
},
async submit (e) {
if (this.disabled) return false
if (this.disabled) { return false }
e.preventDefault()
try {
this.loading = true
......@@ -79,4 +79,4 @@ export default {
}
}
}
</script>
\ No newline at end of file
</script>
......@@ -9,7 +9,7 @@
:placeholder='$t("common.username")' prefix-icon='el-icon-user')
el-input.mb-2(ref='email' v-model='user.email' type='email' required
:placeholder='$t("common.email")' autocomplete='email'
:placeholder='$t("common.email")' autocomplete='email'
prefix-icon='el-icon-message' name='email')
el-input.mb-2(v-model='user.password' type="password"
......
......@@ -22,12 +22,12 @@ export default {
},
enable_comments: {
get () { return this.settings.enable_comments },
set (value) { this.setSetting({ key: 'enable_comments', value }) }
set (value) { this.setSetting({ key: 'enable_comments', value }) }
},
disable_gamification: {
get () { return this.settings.disable_gamification },
set (value) { this.setSetting({ key: 'disable_gamification', value }) }
},
}
}
}
</script>
\ No newline at end of file
</script>
......@@ -5,7 +5,7 @@
el-form-item(:label="$t('admin.select_instance_timezone')")
el-select(v-model='instance_timezone' filterable)
el-option(v-for='timezone in timezones' :key='timezone.value' :value='timezone.value')
span.float-left {{timezone.value}}
span.float-left {{timezone.value}}
small.float-right.text-danger {{timezone.offset}}
//- allow open registration
......@@ -57,8 +57,8 @@ export default {
recurrent_event_visible: {
get () { return this.settings.recurrent_event_visible },
set (value) { this.setSetting({ key: 'recurrent_event_visible', value }) }
},
}
},
methods: mapActions(['setSetting'])
}
</script>
\ No newline at end of file
</script>
export default [
'Europe/Rome',
'Europe/Paris',
]
\ No newline at end of file
'Europe/Paris'
]
......@@ -137,7 +137,7 @@ export default {
due: 'alle',
from: 'Dalle',
image_too_big: 'Immagine troppo grande! Massimo 4M',
interact_with_me_at: 'Seguimi nel fediverso su',
interact_with_me_at: 'Seguimi nel fediverso su'
},
admin: {
......
......@@ -118,7 +118,6 @@ import List from '@/components/List'
import { Message } from 'element-ui'
export default {
name: 'Add',
name: 'newEvent',
components: { List },
validate ({ store }) {
......@@ -241,6 +240,7 @@ export default {
} else if (freq === '1d') {
return this.$t('event.recurrent_each_day')
}
return
},
todayEvents () {
if (this.event.type === 'multidate') {
......@@ -250,11 +250,11 @@ export default {
return this.events.filter(e =>
!e.multidate
? date_start.isSame(moment.unix(e.start_datetime), 'day') ||
date_start.isBefore(moment.unix(e.start_dateime)) && date_end.isAfter(moment.unix(e.start_datetime))
(date_start.isBefore(moment.unix(e.start_dateime)) && date_end.isAfter(moment.unix(e.start_datetime)))
: date_start.isSame(moment.unix(e.start_datetime), 'day') || date_start.isSame(moment.unix(e.end_datetime)) ||
date_start.isAfter(moment.unix(e.start_datetime)) && date_start.isBefore(moment.unix(e.end_datetime)))
(date_start.isAfter(moment.unix(e.start_datetime)) && date_start.isBefore(moment.unix(e.end_datetime))))
} else if (this.event.type === 'recurrent') {
return []
} else {
const date = moment(this.date)
return this.events.filter(e =>
......@@ -292,13 +292,17 @@ export default {
switch (Number(this.activeTab)) {
case 0 + t:
return true
break
case 1 + t:
return this.event.title.length > 0
break
case 2 + t:
return this.event.place.name.length > 0 &&
this.event.place.address.length > 0
break
case 3 + t:
if (this.date && this.time.start) { return true }
break
case 4 + t:
return this.event.place.name.length > 0 &&
this.event.place.address.length > 0 &&
......@@ -312,7 +316,7 @@ export default {
recurrentDays () {
if (this.event.type !== 'recurrent' || !this.date || !this.date.length) { return }
const type = this.event.recurrent.type
if (type === 'ordinal') { return map(this.date, d => moment(d).date()) } else if (type === 'weekday') { return map(this.date, moment(d).day() + 1) }
if (type === 'ordinal') { return map(this.date, d => moment(d).date()) } else if (type === 'weekday') { return map(this.date, d => moment(d).day() + 1) }
},
next () {
this.activeTab = String(Number(this.activeTab) + 1)
......@@ -424,4 +428,4 @@ export default {
#picker {
max-width: 400px;
}
</style>
\ No newline at end of file
</style>
......@@ -52,8 +52,8 @@
</template>
<script>
import { mapState, mapActions } from 'vuex'
import { Message, MessageBox } from 'element-ui'
import { mapState } from 'vuex'
import { Message } from 'element-ui'
import Users from '../components/admin/Users'
import Places from '../components/admin/Places'
import Settings from '../components/admin/Settings'
......@@ -91,7 +91,7 @@ export default {
paginatedEvents () {
return this.events.slice((this.eventPage - 1) * this.perPage,
this.eventPage * this.perPage)
},
}
},
methods: {
preview (id) {
......
......@@ -16,21 +16,20 @@
<script>
import { mapState } from 'vuex'
import Event from '../../components/Event'
import moment from 'dayjs'
import get from 'lodash/get'
export default {
layout: 'event_iframe',
components: { Event },
data: {
loading: true
data () {
return {
loading: true
}
},
async asyncData ({ $axios, params, error, store }) {
try {
const [ id, start_datetime ] = params.event_id.split('_')
const event = await $axios.$get(`/event/${id}`)
event.start_datetime = start_datetime ? Number(start_datetime) : event.start_datetime
event.end_datetime = event.end_datetime
return { event, id: Number(id) }
} catch (e) {
error({ statusCode: 404, message: 'Event not found' })
......
......@@ -2,10 +2,7 @@
List(:events="events" :title='title')
</template>
<script>
import { mapState } from 'vuex'
import List from '../../components/List'
import moment from 'dayjs'
import get from 'lodash/get'
export default {
layout: 'iframe',
......@@ -19,7 +16,6 @@ export default {
const title = query.title
const tags = query.tags
const places = query.places
const now = new Date()
let params = []
if (places) { params.push(`places=${places}`) }
......
......@@ -50,7 +50,7 @@
small.mr-3 🔖 {{event.likes.length}}
small ✊ {{event.boost.length}}<br/>
strong(v-if='settings.enable_comments') {{$tc('common.comments', event.comments.length)}} -
strong(v-if='settings.enable_comments') {{$tc('common.comments', event.comments.length)}} -
small {{$t('event.interact_with_me_at')}} <u>{{fedi_user}}@{{settings.baseurl|url2host}}</u>
.card-header(v-if='settings.enable_comments' v-for='comment in event.comments' :key='comment.id')
......@@ -61,37 +61,40 @@
</template>
<script>
import { mapState, mapActions, mapGetters } from 'vuex'
import { MessageBox } from 'element-ui'
import { mapState, mapGetters } from 'vuex'
import EventAdmin from './eventAdmin'
import moment from 'dayjs'
export default {
name: 'Event',
transition: null,
components: { EventAdmin },
data () {
return {
copied: false
}
},
components: { EventAdmin },
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}`, href: this.settings.baseurl + `/feed/rss?tags=${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}` }
const tags_feed = this.event.tags.map(tag => ({ rel: 'alternate',
type: 'application/rss+xml',
title: `${this.settings.title} events tagged ${tag}`,
href: this.settings.baseurl + `/feed/rss?tags=${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: [
// hid is used as unique identifier. Do not use `vmid` for it as it will not work
{ hid: 'description',
name: 'description',
content: this.event.description.replace("\n",'').slice(0, 1000) },
content: this.event.description.replace('\n', '').slice(0, 1000) },
{ hid: 'og-description',
name: 'og:description',
content: this.event.description.replace("\n",'').slice(0, 100) },
content: this.event.description.replace('\n', '').slice(0, 100) },
{ hid: 'og-title', property: 'og:title', content: this.event.title },
{ hid: 'og-url', property: 'og:url', content: `${this.settings.baseurl}/event/${this.event.id}` },
{ property: 'og:type', content: 'event' },
......@@ -99,18 +102,18 @@ export default {
{ property: 'og:site_name', content: this.settings.title },
{ property: 'og:updated_time', content: moment.unix(this.event.start_datetime).format() },
{ property: 'article:published_time', content: moment.unix(this.event.start_datetime).format() },
{ property: 'article:section', content: 'event'},
{ property: 'twitter:card', content: 'summary'},
{ property: 'article:section', content: 'event' },
{ property: 'twitter:card', content: 'summary' },
{ property: 'twitter:title', content: this.event.title },
{ property: 'twitter:image', content: `${this.settings.baseurl}${this.imgPath}` },
{ property: 'twitter:description', content: this.event.description.replace("\n",'').slice(0, 100) }
{ property: 'twitter:description', content: this.event.description.replace('\n', '').slice(0, 100) }
],
link: [
{ rel: 'image_src', href: `${this.settings.baseurl}${this.imgPath}` },
{ 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, store }) {
......@@ -118,7 +121,6 @@ export default {
const [ id, start_datetime ] = params.id.split('_')
const event = await $axios.$get(`/event/${id}`)
event.start_datetime = start_datetime ? Number(start_datetime) : event.start_datetime
event.end_datetime = event.end_datetime
const now = new Date()
const events = await $axios.$get(`/event/${now.getMonth()}/${now.getFullYear()}`)
store.commit('setEvents', events)
......@@ -168,11 +170,11 @@ export default {
},
methods: {
copyLink () {
this.copied=true
setTimeout(() => this.copied=false, 3000)
this.copied = true
setTimeout(() => { this.copied = false }, 3000)
},
comment_filter (value) {
return value.replace(/<a.*href="([^">]+).*>(?:.(?!\<\/a\>))*.<\/a>/, (orig, url) => {
return value.replace(/<a.*href="([^">]+).*>(?:.(?!<\/a>))*.<\/a>/, (orig, url) => {
// get extension
const ext = url.slice(-4)
if (['.mp3', '.ogg'].includes(ext)) {
......@@ -181,7 +183,7 @@ export default {
return orig
}
})
},
}
}
}
</script>
......@@ -247,7 +249,6 @@ export default {
}
}
@media only screen and (max-width: 768px) {
#eventDetail {
.menu {
......
......@@ -44,4 +44,4 @@ export default {
}
}
}
</script>
\ No newline at end of file
</script>
......@@ -53,11 +53,8 @@
</template>
<script>
import { mapState, mapGetters } from 'vuex'
import Calendar from '@/components/Calendar'
import List from '@/components/List'
import Search from '@/components/Search'
import { intersection } from 'lodash'
import { Message } from 'element-ui'
export default {
......@@ -68,12 +65,6 @@ export default {
title: `${this.settings.title} - ${this.$t('common.export')}`
}
},
async asyncData ({ $axios, params, store }) {
// get metadata just in case we are not coming from home
if (store.state.tags.length) return
const { tags, places } = await $axios.$get('/event/meta')
store.commit('update', { tags, places })
},
data () {
return {
type: 'rss',
......@@ -81,6 +72,12 @@ export default {
list: { title: 'Gancio' }
}
},
async asyncData ({ $axios, params, store }) {
// get metadata just in case we are not coming from home
if (store.state.tags.length) { return }
const { tags, places } = await $axios.$get('/event/meta')
store.commit('update', { tags, places })
},
methods: {
copy (msg) {
this.$copyText(msg).then(e => console.error('ok ', e)).catch(e => console.error('err ', e))
......
......@@ -13,11 +13,8 @@ import { mapState } from 'vuex'
export default {
name: 'Index',
computed: mapState(['settings']),
mounted (ctx) {
moment.tz.setDefault(this.settings.instance_timezone)
},
async fetch ({ store, $axios }) {
try {
try {
moment.tz.setDefault(store.state.settings.instance_timezone)
const now = new Date()
const events = await $axios.$get(`/event/${now.getMonth()}/${now.getFullYear()}`)
......@@ -28,6 +25,9 @@ export default {
console.error(e)
}
},
mounted (ctx) {
moment.tz.setDefault(this.settings.instance_timezone)
},
components: { Nav, Home }
}
</script>
......@@ -29,7 +29,7 @@ export default {
methods: {
async change_password () {
try {
const res = await this.$axios.$post('/user/recover_password', { recover_code: this.code, password: this.new_password })
await this.$axios.$post('/user/recover_password', { recover_code: this.code, password: this.new_password })
Message({
showClose: true,
type: 'success',
......
......@@ -50,7 +50,7 @@ export default {
},
async asyncData ({ $axios, params }) {
const user = await $axios.$get('/auth/user')
return { user, username_editable: user.username.length===0 }
return { user, username_editable: user.username.length === 0 }
},
computed: {
...mapState(['settings']),
......@@ -77,8 +77,8 @@ export default {
cancelButtonText: this.$t('common.cancel'),
type: 'error'
}).then(async () => {
this.user = await this.$axios.$put('/user', { ...this.user, password: this.password })
}).catch( e => {
this.user = await this.$axios.$put('/user', { ...this.user, password: this.password })
}).catch(e => {
Message({ message: e, showClose: true, type: 'warning' })
})
},
......
......@@ -49,4 +49,4 @@ export default {
}
}
}
</script>
\ No newline at end of file
</script>
......@@ -2,7 +2,6 @@ import Vue from 'vue'
import moment from 'moment-timezone'
export default ({ app, store }) => {
// set timezone to instance_timezone!!
// to show local time relative to event's place
// not where in the worlds I'm looking at the page from
......@@ -18,14 +17,14 @@ export default ({ app, store }) => {
// shown in mobile homepage
Vue.filter('day', value => moment.unix(value).locale(store.state.locale).format('dddd, D MMM'))
Vue.filter('to', value => moment().to(value.start_datetime*1000))
Vue.filter('to', value => moment().to(value.start_datetime * 1000))
// format event start/end datetime based on page
Vue.filter('when', (event, where) => {
moment.locale(store.state.locale)
const start = moment.unix(event.start_datetime)
const end = moment.unix(event.end_datetime)
const normal = `${start.format('dddd, D MMMM (HH:mm-')}${end.format('HH:mm) ')}`
// recurrent event
if (event.recurrent && where !== 'home') {
......
......@@ -7,10 +7,9 @@ import messages from '../locales'
Vue.use(VueI18n)
export default async ({ app, store, req }) => {
if (process.server) {
store.commit('setLocale', req.settings.locale)
if (req.settings.user_locale) store.commit('setUserLocale', req.settings.user_locale)
if (req.settings.user_locale) { store.commit('setUserLocale', req.settings.user_locale) }
}
if (store.state.user_locale) {
......
......@@ -2,8 +2,8 @@ const crypto = require('crypto')
const moment = require('moment-timezone')
const { Op } = require('sequelize')
const lodash = require('lodash')
const { event: Event, comment: Comment, tag: Tag, place: Place,
user: User, notification: Notification, event_notification: EventNotification } = require('../models')
const { event: Event, comment: Comment, tag: Tag, place: Place,
user: User, notification: Notification } = require('../models')
const Sequelize = require('sequelize')
const exportController = require('./export')
const debug = require('debug')('controller:event')
......@@ -142,7 +142,7 @@ const eventController = {
async unconfirm (req, res) {
const id = Number(req.params.event_id)
const event = await Event.findByPk(id)
if (!event) { return sendStatus(404) }
if (!event) { return req.sendStatus(404) }
try {
event.is_visible = false
......@@ -219,7 +219,7 @@ const eventController = {
{ start_datetime: { [Op.between]: [start.unix(), end.unix()] } }
]
},
attributes: { exclude: ['createdAt', 'updatedAt', 'placeId' ] },
attributes: { exclude: [ 'createdAt', 'updatedAt', 'placeId' ] },
order: [[Tag, 'weigth', 'DESC']],
include: [
{ model: Comment, required: false, attributes: ['id'] },
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment