mirror of
https://framagit.org/les/gancio.git
synced 2025-01-31 08:32:23 +01:00
.
This commit is contained in:
parent
7455553129
commit
c408c44676
40 changed files with 270 additions and 279 deletions
|
@ -19,6 +19,10 @@ module.exports = {
|
|||
],
|
||||
// add your custom rules here
|
||||
rules: {
|
||||
'nuxt/no-cjs-in-config': 'off'
|
||||
'nuxt/no-cjs-in-config': 'off',
|
||||
'camelcase': 'off',
|
||||
'no-console': 'off',
|
||||
'arrow-parens': 'off',
|
||||
'import/order': 'off'
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const path = require('path')
|
||||
|
||||
module.exports = {
|
||||
'config': path.resolve('server' ,'config.js'),
|
||||
'config': path.resolve('config.js'),
|
||||
'migrations-path': path.resolve('server', 'migrations'),
|
||||
'models-path': path.resolve('server', 'api', 'models')
|
||||
}
|
||||
|
|
|
@ -75,7 +75,9 @@ const it = {
|
|||
description: `I movimenti hanno bisogno di organizzarsi e autofinanziarsi. <br/>Questo è un dono per voi, usatelo solo per eventi non commerciali e ovviamente antifascisti, antisessisti, antirazzisti.
|
||||
<br/>Prima di poter pubblicare <strong>dobbiamo approvare l'account</strong>, considera che <strong>dietro questo sito ci sono delle persone</strong> di
|
||||
carne e sangue, scrivici quindi due righe per farci capire che eventi vorresti pubblicare.`,
|
||||
error: 'Errore: '
|
||||
error: 'Errore: ',
|
||||
admin_complete: 'Sei il primo utente e quindi sei amministratore!',
|
||||
complete: 'Confermeremo la registrazione quanto prima.'
|
||||
},
|
||||
|
||||
event: {
|
||||
|
@ -124,7 +126,7 @@ const it = {
|
|||
firstrun: {
|
||||
basic: `Inserisci titolo e descrizione della tua istanza di gancio.`,
|
||||
database: `Gancio ha bisogno di un database postgresql!`,
|
||||
smtp: `Inserisci un account SMTP relativo a questa istanza di gancio.`,
|
||||
smtp: `Inserisci un account SMTP relativo a questa istanza di gancio.`
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
const config = require('./server/config').SHARED_CONF
|
||||
const argv = require('yargs').argv
|
||||
const path = require('path')
|
||||
const config_path = path.resolve(argv.config || './config.js')
|
||||
|
||||
const config = require(config_path).SHARED_CONF
|
||||
|
||||
module.exports = {
|
||||
mode: 'universal',
|
||||
|
@ -15,7 +19,6 @@ module.exports = {
|
|||
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }]
|
||||
},
|
||||
dev: (process.env.NODE_ENV !== 'production'),
|
||||
|
||||
serverMiddleware: [
|
||||
{ path: '/api', handler: '@/server/api/index.js' }
|
||||
],
|
||||
|
@ -30,9 +33,11 @@ module.exports = {
|
|||
*/
|
||||
css: [
|
||||
'bootstrap/dist/css/bootstrap.css',
|
||||
'element-ui/lib/theme-chalk/index.css',
|
||||
'element-ui/lib/theme-chalk/index.css'
|
||||
],
|
||||
|
||||
env: {
|
||||
config
|
||||
},
|
||||
/*
|
||||
** Plugins to load before mounting the App
|
||||
*/
|
||||
|
@ -41,7 +46,7 @@ module.exports = {
|
|||
'@/plugins/filters', // text filters, datetime, etc.
|
||||
'@/plugins/i18n', // localization plugin
|
||||
'@/plugins/vue-awesome', // icon
|
||||
{ src: '@/plugins/v-calendar', ssr: false }, // calendar, TO-REDO
|
||||
{ src: '@/plugins/v-calendar', ssr: false } // calendar, TO-REDO
|
||||
],
|
||||
|
||||
/*
|
||||
|
@ -58,7 +63,7 @@ module.exports = {
|
|||
axios: {
|
||||
baseURL: config.baseurl + '/api',
|
||||
browserBaseURL: config.baseurl + '/api',
|
||||
prefix: '/api',
|
||||
prefix: '/api'
|
||||
// credentials: true
|
||||
// See https://github.com/nuxt-community/axios-module#options
|
||||
},
|
||||
|
@ -68,37 +73,19 @@ module.exports = {
|
|||
endpoints: {
|
||||
login: { url: '/auth/login', method: 'post', propertyName: 'token' },
|
||||
logout: false,
|
||||
user: { url: '/auth/user', method: 'get', propertyName: false },
|
||||
},
|
||||
user: { url: '/auth/user', method: 'get', propertyName: false }
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/*
|
||||
** Build configuration
|
||||
*/
|
||||
build: {
|
||||
// babel: {
|
||||
// presets: ['@nuxt/babel-preset-app']
|
||||
// },
|
||||
transpile: [/^element-ui/, /^vue-awesome/],
|
||||
splitChunks: {
|
||||
layouts: true
|
||||
}
|
||||
/*
|
||||
** You can extend webpack config here
|
||||
*/
|
||||
// extend(config, ctx) {
|
||||
// Run ESLint on save
|
||||
// if (ctx.isDev && ctx.isClient) {
|
||||
// config.module.rules.push({
|
||||
// enforce: 'pre',
|
||||
// test: /\.(js|vue)$/,
|
||||
// loader: 'eslint-loader',
|
||||
// exclude: /(node_modules)/
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
<template lang="pug">
|
||||
el-dialog(:title='$t("common.admin")' width='80%' :visible='open' :before-close='close')
|
||||
el-card(:title='$t("common.admin")' width='80%' :visible='open' :before-close='close')
|
||||
nuxt-link.float-right(to='/')
|
||||
v-icon(name='times' color='red')
|
||||
h5 {{$t('common.admin')}}
|
||||
|
||||
el-tabs(tabPosition='left' v-model='tab')
|
||||
|
||||
//- USERS
|
||||
|
@ -81,9 +85,18 @@
|
|||
template(slot='label')
|
||||
v-icon(name='cog')
|
||||
span {{$t('common.settings')}}
|
||||
|
||||
//- el-form(inline @submit.prevent.stop='save_settings' label-width='140px')
|
||||
//- p {{$t('settings.name_description')}}
|
||||
//- el-form-item(:label="$t('settings.name')")
|
||||
//- el-input(v-model="settings.title")
|
||||
//- el-form-item(:label="$t('settings.description')")
|
||||
//- el-input(v-model="settings.description")
|
||||
//- el-button(slot='append' @click='associate' :disabled='!mastodon_instance.length') {{$t('common.associate')}}
|
||||
|
||||
el-form(inline @submit.prevent.stop='associatemastodon_instance')
|
||||
span {{$t('admin.mastodon_description')}}
|
||||
el-input(v-model="mastodon_instance")
|
||||
el-input(v-model="settings.mastodon_instance")
|
||||
span(slot='prepend') {{$t('admin.mastodon_instance')}}
|
||||
el-button(slot='append' @click='associate' :disabled='!mastodon_instance.length') {{$t('common.associate')}}
|
||||
|
||||
|
@ -111,7 +124,9 @@ export default {
|
|||
tag: {name: '', color: ''},
|
||||
events: [],
|
||||
loading: false,
|
||||
settings: {
|
||||
mastodon_instance: '',
|
||||
},
|
||||
settings: {},
|
||||
tab: "0",
|
||||
open: true
|
||||
|
|
|
@ -11,9 +11,9 @@ export default {
|
|||
components: { List },
|
||||
computed: mapState(['config']),
|
||||
async asyncData ({ $axios, req, res }) {
|
||||
const title = req.query.title || config.title
|
||||
const tags = req.query.tags
|
||||
const places = req.query.places
|
||||
const title = req && req.query && req.query.title || this.config.title
|
||||
const tags = req && req.query && req.query.tags
|
||||
const places = req && req.query && req.query.places
|
||||
const now = new Date()
|
||||
|
||||
let params = []
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
Nav
|
||||
Home
|
||||
|
||||
|
||||
</template>
|
||||
<script>
|
||||
import Home from '~/components/Home.vue'
|
||||
|
@ -12,22 +11,16 @@ import { mapState } from 'vuex'
|
|||
|
||||
export default {
|
||||
name: 'Index',
|
||||
async asyncData ({ redirect, store }) {
|
||||
// console.error('diocane', store.state.settings)
|
||||
// const firstRun = store.state.settings.firstRun
|
||||
// if (firstRun!==true) {
|
||||
// redirect('/firstrun')
|
||||
// }
|
||||
},
|
||||
async fetch ({ store, $axios }) {
|
||||
try {
|
||||
const now = new Date()
|
||||
const events = await $axios.$get(`/event/${now.getMonth()}/${now.getFullYear()}`)
|
||||
console.error(events)
|
||||
store.commit('setEvents', events)
|
||||
const { tags, places } = await $axios.$get('/event/meta')
|
||||
store.commit('update', { tags, places })
|
||||
// const settings = await $axios.$get('/settings')
|
||||
// store.commit('setSettings', settings)
|
||||
} catch(e) {
|
||||
console.error(e)
|
||||
}
|
||||
},
|
||||
computed: mapState(['events']),
|
||||
components: { Nav, Home },
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
const Cookie = process.client ? require('js-cookie') : undefined
|
||||
import { mapActions } from 'vuex'
|
||||
import { Message } from 'element-ui'
|
||||
import get from 'lodash/get'
|
||||
|
|
|
@ -5,26 +5,26 @@
|
|||
v-icon(name='times' color='red')
|
||||
h5 {{$t('common.register')}}
|
||||
|
||||
el-form(method='POST' action='/api/user')
|
||||
el-form(@submit.native.prevent='register' method='POST' action='/api/user')
|
||||
p(v-html="$t('register.description')")
|
||||
el-input.mb-2(ref='email' v-model='user.email' type='email' required
|
||||
:placeholder='$t("common.email")' autocomplete='email' name='email')
|
||||
span(slot='prepend') @
|
||||
|
||||
el-input.mb-2(v-model='user.password' type="password" placeholder="Password" name='password')
|
||||
el-input.mb-2(v-model='user.password' type="password" placeholder="Password" name='password' required)
|
||||
v-icon(name='lock' slot='prepend')
|
||||
|
||||
el-input.mb-2(v-model='user.description' type="textarea" rows='3' :placeholder="$t('common.description')")
|
||||
v-icon(name='envelope-open-text')
|
||||
|
||||
el-button(plain type="success" native-type='submit'
|
||||
:disabled='disabled'
|
||||
@click='register') {{$t('common.send')}} <v-icon name='chevron-right'/>
|
||||
:disabled='disabled') {{$t('common.send')}} <v-icon name='chevron-right'/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapActions } from 'vuex'
|
||||
import { Message } from 'element-ui'
|
||||
import get from 'lodash/get'
|
||||
|
||||
export default {
|
||||
name: 'Register',
|
||||
|
@ -44,14 +44,14 @@ export default {
|
|||
...mapActions(['login']),
|
||||
async register () {
|
||||
try {
|
||||
const user = await this.$axios.$post('/user', this.user)
|
||||
const { user } = await this.$axios.$post('/user', this.user)
|
||||
Message({
|
||||
message: this.$t(`register.${user.is_admin && 'admin_'}complete`),
|
||||
message: this.$t(`register.${user.is_admin ? 'admin_' : ''}complete`),
|
||||
type: 'success'
|
||||
})
|
||||
this.$router.replace("/")
|
||||
} catch (e) {
|
||||
const error = e && e.response && e.response.data && e.response.data.errors[0].message || e
|
||||
const error = get(e, 'e.response.data.errors[0].message', String(e))
|
||||
Message({
|
||||
message: this.$t('register.error') + this.$t(error),
|
||||
type: 'error'
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
<template lang="pug">
|
||||
el-dialog(:title="$t('common.settings')" :before-close='close' visible)
|
||||
el-card
|
||||
nuxt-link.float-right(to='/')
|
||||
v-icon(name='times' color='red')
|
||||
h5 {{$t('common.settings')}}
|
||||
|
||||
//- el-form
|
||||
//- el-form-item {{$t('settings.change_password')}}
|
||||
el-divider {{$t('settings.change_password')}}
|
||||
|
@ -23,11 +27,11 @@ export default {
|
|||
methods: {
|
||||
async change () {
|
||||
if (!this.password) return
|
||||
const user = this.user
|
||||
user.password = this.password
|
||||
// this.$auth.user.password = this.password
|
||||
const user_data = { id : this.$auth.user.id, password: this.password }
|
||||
try {
|
||||
// this.$axios.
|
||||
// await api.updateUser(user)
|
||||
const user = await this.$axios.$put('/user', user_data)
|
||||
console.error(user)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
|
|
|
@ -23,11 +23,9 @@ export default (a) => {
|
|||
const end = moment(event.end_datetime)
|
||||
if (event.multidate) {
|
||||
return `${start.format('ddd, D MMMM')} (${short_hour(start)}) - ${end.format('ddd, D MMMM')} (${short_hour(end)})`
|
||||
} else {
|
||||
if (event.end_datetime && event.end_datetime !== event.start_datetime)
|
||||
} else if (event.end_datetime && event.end_datetime !== event.start_datetime)
|
||||
return `${start.format('ddd, D MMMM')} (${short_hour(start)}-${short_hour(end)}`
|
||||
else
|
||||
return `${start.format('dddd, D MMMM')} (${short_hour(start)})`
|
||||
}
|
||||
})
|
||||
}
|
|
@ -12,7 +12,6 @@ export default ({ app, store }) => {
|
|||
fallbackLocale: 'it',
|
||||
messages: {
|
||||
it
|
||||
// 'fr': require('~/locales/fr.json')
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ ${event.description.length > 200 ? event.description.substr(0, 200) + '...' : ev
|
|||
const comment = await Comment.create({
|
||||
activitypub_id: msg.data.last_status.id,
|
||||
// text: msg.data.last_status.content,
|
||||
data: msg.data,
|
||||
data: msg.data
|
||||
// author: msg.data.accounts[0].username
|
||||
})
|
||||
event.addComment(comment)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
const { event: Event, place: Place } = require('../models')
|
||||
const { Op } = require('sequelize')
|
||||
const config = require('../../config').SHARED_CONF
|
||||
const moment = require('moment')
|
||||
const ics = require('ics')
|
||||
|
||||
|
@ -21,7 +20,6 @@ const exportController = {
|
|||
if (places) {
|
||||
wherePlace.id = places.split(',')
|
||||
}
|
||||
console.error(places)
|
||||
const events = await Event.findAll({
|
||||
order: ['start_datetime'],
|
||||
where: {
|
||||
|
@ -44,12 +42,12 @@ const exportController = {
|
|||
}
|
||||
},
|
||||
|
||||
async feed (res, events) {
|
||||
feed(res, events) {
|
||||
res.type('application/rss+xml; charset=UTF-8')
|
||||
res.render('feed/rss.pug', { events, config, moment })
|
||||
res.render('feed/rss.pug', { events, config: process.env.config, moment })
|
||||
},
|
||||
|
||||
async ics (res, events) {
|
||||
ics(res, events) {
|
||||
const eventsMap = events.map(e => {
|
||||
const tmpStart = moment(e.start_datetime)
|
||||
const tmpEnd = moment(e.end_datetime)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const Mastodon = require('mastodon-api')
|
||||
const { setting: Setting } = require('../models')
|
||||
const config = require('../../config').SHARED_CONF
|
||||
|
||||
const baseurl = process.env.baseurl
|
||||
|
||||
const settingsController = {
|
||||
|
||||
|
@ -17,15 +18,11 @@ const settingsController = {
|
|||
res.json(settings)
|
||||
},
|
||||
|
||||
async getConfig (req, res) {
|
||||
res.json(config)
|
||||
},
|
||||
|
||||
async getAuthURL(req, res) {
|
||||
const instance = req.body.instance
|
||||
const callback = `${config.baseurl}/api/settings/oauth`
|
||||
const callback = `${baseurl}/api/settings/oauth`
|
||||
const { client_id, client_secret } = await Mastodon.createOAuthApp(`https://${instance}/api/v1/apps`,
|
||||
config.title, 'read write', callback)
|
||||
'gancio', 'read write', callback)
|
||||
const url = await Mastodon.getAuthorizationUrl(client_id, client_secret,
|
||||
`https://${instance}`, 'read write', callback)
|
||||
|
||||
|
@ -36,7 +33,7 @@ const settingsController = {
|
|||
async code(req, res) {
|
||||
const code = req.query.code
|
||||
let client_id, client_secret, instance
|
||||
const callback = `${config.baseurl}/api/settings/oauth`
|
||||
const callback = `${baseurl}/api/settings/oauth`
|
||||
|
||||
const settings = await settingsController.settings()
|
||||
|
||||
|
@ -55,10 +52,9 @@ const settingsController = {
|
|||
},
|
||||
|
||||
async settings() {
|
||||
console.error('ma sono dentro settings ?!?!')
|
||||
const settings = await Setting.findAll()
|
||||
return settings
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -4,14 +4,13 @@ const crypto = require('crypto')
|
|||
const jwt = require('jsonwebtoken')
|
||||
const { Op } = require('sequelize')
|
||||
const jsonwebtoken = require('jsonwebtoken')
|
||||
const { SECRET_CONF, SHARED_CONF } = require('../../config')
|
||||
const mail = require('../mail')
|
||||
const { user: User, event: Event, tag: Tag, place: Place } = require('../models')
|
||||
const eventController = require('./event')
|
||||
const config = require('../../config')
|
||||
|
||||
const userController = {
|
||||
async login(req, res) {
|
||||
|
||||
// find the user
|
||||
const user = await User.findOne({ where: { email: { [Op.eq]: req.body && req.body.email } } })
|
||||
if (!user) {
|
||||
|
@ -31,7 +30,7 @@ const userController = {
|
|||
email: user.email,
|
||||
scope: [user.is_admin ? 'admin' : 'user']
|
||||
},
|
||||
SECRET_CONF.secret
|
||||
config.SECRET_CONF.secret
|
||||
)
|
||||
|
||||
res.json({ token: accessToken })
|
||||
|
@ -89,9 +88,7 @@ const userController = {
|
|||
eventDetails.image_path = req.file.filename
|
||||
}
|
||||
|
||||
console.error('prima la creazione di evento')
|
||||
let event = await Event.create(eventDetails)
|
||||
console.error('dopo la creazione di evento')
|
||||
|
||||
// create place if needs to
|
||||
let place
|
||||
|
@ -167,7 +164,7 @@ const userController = {
|
|||
if (!user) return res.sendStatus(200)
|
||||
|
||||
user.recover_code = crypto.randomBytes(16).toString('hex')
|
||||
mail.send(user.email, 'recover', { user, config: SHARED_CONF })
|
||||
mail.send(user.email, 'recover', { user, config: config.SHARED_CONF })
|
||||
|
||||
await user.save()
|
||||
res.sendStatus(200)
|
||||
|
@ -196,11 +193,8 @@ const userController = {
|
|||
}
|
||||
},
|
||||
|
||||
async current(req, res) {
|
||||
if (req.user)
|
||||
res.json(req.user)
|
||||
else
|
||||
res.sendStatus(404)
|
||||
current(req, res) {
|
||||
if (req.user) { res.json(req.user) } else { res.sendStatus(404) }
|
||||
},
|
||||
|
||||
async getAll(req, res) {
|
||||
|
@ -212,9 +206,10 @@ const userController = {
|
|||
|
||||
async update(req, res) {
|
||||
const user = await User.findByPk(req.body.id)
|
||||
console.error(req.body.id)
|
||||
if (user) {
|
||||
if (!user.is_active && req.body.is_active) {
|
||||
await mail.send(user.email, 'confirm', { user, config: SHARED_CONF })
|
||||
await mail.send(user.email, 'confirm', { user, config: config.SHARED_CONF })
|
||||
}
|
||||
await user.update(req.body)
|
||||
res.json(user)
|
||||
|
@ -226,7 +221,6 @@ const userController = {
|
|||
async register(req, res) {
|
||||
const n_users = await User.count()
|
||||
try {
|
||||
|
||||
// the first registered user will be an active admin
|
||||
if (n_users === 0) {
|
||||
req.body.is_active = req.body.is_admin = true
|
||||
|
@ -236,7 +230,7 @@ const userController = {
|
|||
|
||||
const user = await User.create(req.body)
|
||||
try {
|
||||
mail.send([user.email, SECRET_CONF.admin], 'register', { user, config: SHARED_CONF })
|
||||
mail.send([user.email, config.SECRET_CONF.admin], 'register', { user, config: config.SHARED_CONF })
|
||||
} catch (e) {
|
||||
return res.status(400).json(e)
|
||||
}
|
||||
|
@ -245,9 +239,8 @@ const userController = {
|
|||
email: user.email,
|
||||
scope: [user.is_admin ? 'admin' : 'user']
|
||||
}
|
||||
const token = jwt.sign(payload, SECRET_CONF.secret)
|
||||
res.json({ token })
|
||||
// res.redirect('/')
|
||||
const token = jwt.sign(payload, config.SECRET_CONF.secret)
|
||||
res.json({ token, user })
|
||||
} catch (e) {
|
||||
res.status(404).json(e)
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ const multer = require('multer')
|
|||
const cookieParser = require('cookie-parser')
|
||||
const bodyParser = require('body-parser')
|
||||
const expressJwt = require('express-jwt')
|
||||
const config = require('../config')
|
||||
|
||||
const { fillUser, isAuth, isAdmin } = require('./auth')
|
||||
const eventController = require('./controller/event')
|
||||
|
@ -10,8 +11,6 @@ const exportController = require('./controller/export')
|
|||
const userController = require('./controller/user')
|
||||
const settingsController = require('./controller/settings')
|
||||
|
||||
const { SECRET_CONF } = require('../config')
|
||||
|
||||
const storage = require('./storage')({
|
||||
destination: 'uploads/'
|
||||
})
|
||||
|
@ -23,19 +22,20 @@ api.use(bodyParser.urlencoded({ extended: false }))
|
|||
api.use(bodyParser.json())
|
||||
|
||||
const jwt = expressJwt({
|
||||
secret: SECRET_CONF.secret,
|
||||
credentialsRequired: false,
|
||||
// getToken: req => {
|
||||
// // if (req.headers.authorization && req.headers.authorization.split(' ')[0] === 'Bearer') {
|
||||
// // return req.headers.authorization.split(' ')[1];
|
||||
// if (req.cookies && req.cookies['token']) {
|
||||
// console.error(req.cookies['token'])
|
||||
// return req.cookies['token']
|
||||
// }
|
||||
// return null
|
||||
// }
|
||||
secret: config.SECRET_CONF.secret,
|
||||
credentialsRequired: false
|
||||
})
|
||||
|
||||
function errorHandler(fn) {
|
||||
return async (req, res) => {
|
||||
try {
|
||||
await fn(req, res)
|
||||
} catch (e) {
|
||||
console.error(String(e))
|
||||
return res.status(500).json(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// AUTH
|
||||
api.post('/auth/login', userController.login)
|
||||
|
@ -84,7 +84,6 @@ api.get('/event/unconfirmed', jwt, isAuth, isAdmin, eventController.getUnconfirm
|
|||
api.post('/event/notification', eventController.addNotification)
|
||||
api.delete('/event/notification/:code', eventController.delNotification)
|
||||
|
||||
api.get('/config', settingsController.getConfig)
|
||||
api.get('/settings', jwt, fillUser, isAdmin, settingsController.getAdminSettings)
|
||||
api.post('/settings', jwt, fillUser, isAdmin, settingsController.setAdminSetting)
|
||||
|
||||
|
@ -99,7 +98,7 @@ api.get('/event/unconfirm/:event_id', jwt, isAuth, isAdmin, eventController.unco
|
|||
api.get('/export/:type', exportController.export)
|
||||
|
||||
// get events in this range
|
||||
api.get('/event/:month/:year', eventController.getAll)
|
||||
api.get('/event/:month/:year', errorHandler(eventController.getAll))
|
||||
|
||||
// mastodon oauth auth
|
||||
api.post('/settings/getauthurl', jwt, isAuth, isAdmin, settingsController.getAuthURL)
|
||||
|
|
|
@ -2,8 +2,8 @@ const Email = require('email-templates')
|
|||
const path = require('path')
|
||||
const moment = require('moment')
|
||||
const config = require('../config')
|
||||
moment.locale(config.SHARED_CONF.locale)
|
||||
|
||||
moment.locale(config.SHARED_CONF.locale)
|
||||
const mail = {
|
||||
send(addresses, template, locals) {
|
||||
const email = new Email({
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
'use strict';
|
||||
'use strict'
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const comment = sequelize.define('comment', {
|
||||
activitypub_id: DataTypes.BIGINT,
|
||||
data: DataTypes.JSON
|
||||
}, {});
|
||||
}, {})
|
||||
comment.associate = function (models) {
|
||||
comment.belongsTo(models.event)
|
||||
// Event.hasMany(Comment)
|
||||
// associations can be defined here
|
||||
};
|
||||
return comment;
|
||||
}
|
||||
return comment
|
||||
};
|
|
@ -1,4 +1,4 @@
|
|||
'use strict';
|
||||
'use strict'
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const event = sequelize.define('event', {
|
||||
title: DataTypes.STRING,
|
||||
|
@ -16,7 +16,7 @@ module.exports = (sequelize, DataTypes) => {
|
|||
type: DataTypes.BIGINT,
|
||||
index: true
|
||||
}
|
||||
}, {});
|
||||
}, {})
|
||||
event.associate = function (models) {
|
||||
event.belongsTo(models.place)
|
||||
event.belongsTo(models.user)
|
||||
|
@ -26,6 +26,6 @@ module.exports = (sequelize, DataTypes) => {
|
|||
// Tag.belongsToMany(Event, { through: 'tagEvent' })
|
||||
// Event.hasMany(models.Tag)
|
||||
// associations can be defined here
|
||||
};
|
||||
return event;
|
||||
}
|
||||
return event
|
||||
};
|
|
@ -1,4 +1,4 @@
|
|||
'use strict';
|
||||
'use strict'
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const eventNotification = sequelize.define('eventNotification', {
|
||||
status: {
|
||||
|
@ -7,10 +7,10 @@ module.exports = (sequelize, DataTypes) => {
|
|||
defaultValue: 'new',
|
||||
index: true
|
||||
}
|
||||
}, {});
|
||||
}, {})
|
||||
|
||||
eventNotification.associate = function (models) {
|
||||
// associations can be defined here
|
||||
};
|
||||
return eventNotification;
|
||||
};
|
||||
}
|
||||
return eventNotification
|
||||
}
|
||||
|
|
|
@ -1,31 +1,31 @@
|
|||
'use strict';
|
||||
const argv = require('yargs').argv
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const Sequelize = require('sequelize')
|
||||
const config_path = path.resolve(argv.config || './config.js')
|
||||
const basename = path.basename(__filename)
|
||||
const config = require(config_path).SECRET_CONF.db
|
||||
const db = {}
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const Sequelize = require('sequelize');
|
||||
const basename = path.basename(__filename);
|
||||
const config = require(__dirname + '/../../config.js').SECRET_CONF.db
|
||||
const db = {};
|
||||
|
||||
let sequelize = new Sequelize(config);
|
||||
const sequelize = new Sequelize(config)
|
||||
|
||||
fs
|
||||
.readdirSync(__dirname)
|
||||
.filter(file => {
|
||||
return (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js');
|
||||
return (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js')
|
||||
})
|
||||
.forEach(file => {
|
||||
const model = sequelize['import'](path.join(__dirname, file));
|
||||
db[model.name] = model;
|
||||
});
|
||||
const model = sequelize.import(path.join(__dirname, file))
|
||||
db[model.name] = model
|
||||
})
|
||||
|
||||
Object.keys(db).forEach(modelName => {
|
||||
if (db[modelName].associate) {
|
||||
db[modelName].associate(db);
|
||||
db[modelName].associate(db)
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
db.sequelize = sequelize;
|
||||
db.Sequelize = Sequelize;
|
||||
db.sequelize = sequelize
|
||||
db.Sequelize = Sequelize
|
||||
|
||||
module.exports = db;
|
||||
module.exports = db
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
'use strict';
|
||||
'use strict'
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const notification = sequelize.define('notification', {
|
||||
filters: DataTypes.JSON,
|
||||
|
@ -8,10 +8,10 @@ module.exports = (sequelize, DataTypes) => {
|
|||
type: DataTypes.ENUM,
|
||||
values: ['mail', 'admin_email', 'mastodon']
|
||||
}
|
||||
}, {});
|
||||
}, {})
|
||||
notification.associate = function (models) {
|
||||
notification.belongsToMany(models.event, { through: 'event_notification' })
|
||||
// associations can be defined here
|
||||
};
|
||||
return notification;
|
||||
};
|
||||
}
|
||||
return notification
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
'use strict';
|
||||
'use strict'
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const place = sequelize.define('place', {
|
||||
name: DataTypes.STRING,
|
||||
address: DataTypes.STRING,
|
||||
weigth: DataTypes.INTEGER
|
||||
}, {});
|
||||
}, {})
|
||||
|
||||
place.associate = function (models) {
|
||||
// associations can be defined here
|
||||
place.hasMany(models.event)
|
||||
};
|
||||
}
|
||||
|
||||
return place;
|
||||
};
|
||||
return place
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
'use strict';
|
||||
'use strict'
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const setting = sequelize.define('setting', {
|
||||
key: {
|
||||
type: DataTypes.STRING,
|
||||
primaryKey: true,
|
||||
allowNull: false,
|
||||
index: true,
|
||||
index: true
|
||||
},
|
||||
value: DataTypes.JSON
|
||||
}, {});
|
||||
}, {})
|
||||
|
||||
return setting;
|
||||
};
|
||||
return setting
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
'use strict';
|
||||
'use strict'
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const tag = sequelize.define('tag', {
|
||||
tag: {
|
||||
|
@ -8,12 +8,12 @@ module.exports = (sequelize, DataTypes) => {
|
|||
},
|
||||
weigth: DataTypes.INTEGER,
|
||||
color: DataTypes.STRING
|
||||
}, {});
|
||||
}, {})
|
||||
|
||||
tag.associate = function (models) {
|
||||
tag.belongsToMany(models.event, { through: 'event_tags' })
|
||||
// associations can be defined here
|
||||
};
|
||||
}
|
||||
|
||||
return tag;
|
||||
return tag
|
||||
};
|
|
@ -1,4 +1,4 @@
|
|||
'use strict';
|
||||
'use strict'
|
||||
const bcrypt = require('bcrypt')
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
|
@ -14,12 +14,16 @@ module.exports = (sequelize, DataTypes) => {
|
|||
recover_code: DataTypes.STRING,
|
||||
is_admin: DataTypes.BOOLEAN,
|
||||
is_active: DataTypes.BOOLEAN
|
||||
}, {});
|
||||
}, {
|
||||
defaultScope: {
|
||||
exclude: ['password', 'recover_code']
|
||||
}
|
||||
})
|
||||
|
||||
user.associate = function (models) {
|
||||
// associations can be defined here
|
||||
user.hasMany(models.event)
|
||||
};
|
||||
}
|
||||
|
||||
user.prototype.comparePassword = async function (pwd) {
|
||||
if (!this.password) return false
|
||||
|
@ -35,5 +39,5 @@ module.exports = (sequelize, DataTypes) => {
|
|||
}
|
||||
})
|
||||
|
||||
return user;
|
||||
return user
|
||||
};
|
|
@ -1,8 +1,9 @@
|
|||
// check config.js existance
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const argv = require('yargs').argv
|
||||
|
||||
const config_path = path.join(__dirname, 'config.js')
|
||||
const config_path = path.resolve(argv.config || './config.js')
|
||||
|
||||
if (!fs.existsSync(config_path)) {
|
||||
console.error(`Configuration file not found at '${config_path}. Please copy 'config.example.js' and modify it.`)
|
||||
|
@ -12,7 +13,7 @@ if (!fs.existsSync(config_path)) {
|
|||
const { SECRET_CONF, SHARED_CONF } = require(config_path)
|
||||
if (!SECRET_CONF.secret) {
|
||||
console.error(`Please specify a random 'secret' in '${config_path}'!`)
|
||||
process.exit(1);
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const Sequelize = require('sequelize')
|
||||
|
@ -24,7 +25,6 @@ try {
|
|||
process.exit(1)
|
||||
}
|
||||
|
||||
|
||||
// return db existence
|
||||
module.exports = db.authenticate()
|
||||
.then(() => {
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
const firstRun = require('./firstrun')
|
||||
#!/bin/env node
|
||||
const path = require('path')
|
||||
const express = require('express')
|
||||
const consola = require('consola')
|
||||
const morgan = require('morgan')
|
||||
const path = require('path')
|
||||
const app = express()
|
||||
const { Nuxt, Builder } = require('nuxt')
|
||||
const firstRun = require('./firstrun')
|
||||
// Import and Set Nuxt.js options
|
||||
const config = require('../nuxt.config.js')
|
||||
|
||||
const app = express()
|
||||
async function start() {
|
||||
// Init Nuxt.js
|
||||
const nuxt = new Nuxt(config)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
'use strict';
|
||||
'use strict'
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.createTable('events', {
|
||||
|
@ -13,7 +13,7 @@ module.exports = {
|
|||
},
|
||||
slug: {
|
||||
type: Sequelize.STRING,
|
||||
index: true,
|
||||
index: true
|
||||
},
|
||||
description: {
|
||||
type: Sequelize.TEXT
|
||||
|
@ -58,9 +58,9 @@ module.exports = {
|
|||
allowNull: false,
|
||||
type: Sequelize.DATE
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.dropTable('events');
|
||||
return queryInterface.dropTable('events')
|
||||
}
|
||||
}
|
||||
};
|
|
@ -1,4 +1,4 @@
|
|||
'use strict';
|
||||
'use strict'
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.createTable('notifications', {
|
||||
|
@ -29,9 +29,9 @@ module.exports = {
|
|||
allowNull: false,
|
||||
type: Sequelize.DATE
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.dropTable('notifications');
|
||||
return queryInterface.dropTable('notifications')
|
||||
}
|
||||
}
|
||||
};
|
|
@ -1,4 +1,3 @@
|
|||
'use strict';
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.createTable('event_notification', {
|
||||
|
@ -30,9 +29,9 @@ module.exports = {
|
|||
allowNull: false,
|
||||
type: Sequelize.DATE
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.dropTable('event_notification');
|
||||
return queryInterface.dropTable('event_notification')
|
||||
}
|
||||
}
|
||||
};
|
|
@ -11,7 +11,7 @@ module.exports = {
|
|||
eventId: {
|
||||
type: Sequelize.INTEGER,
|
||||
references: {
|
||||
model: 'event',
|
||||
model: 'events',
|
||||
key: 'id'
|
||||
}
|
||||
},
|
|
@ -1,4 +1,4 @@
|
|||
'use strict';
|
||||
'use strict'
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.createTable('settings', {
|
||||
|
@ -6,7 +6,7 @@ module.exports = {
|
|||
type: Sequelize.STRING,
|
||||
primaryKey: true,
|
||||
allowNull: false,
|
||||
index: true,
|
||||
index: true
|
||||
},
|
||||
value: {
|
||||
type: Sequelize.JSON
|
||||
|
@ -19,9 +19,9 @@ module.exports = {
|
|||
allowNull: false,
|
||||
type: Sequelize.DATE
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.dropTable('settings');
|
||||
return queryInterface.dropTable('settings')
|
||||
}
|
||||
}
|
||||
};
|
|
@ -1,4 +1,4 @@
|
|||
'use strict';
|
||||
'use strict'
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.createTable('event_tags', {
|
||||
|
@ -24,9 +24,9 @@ module.exports = {
|
|||
allowNull: false,
|
||||
type: Sequelize.DATE
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.dropTable('event_tags');
|
||||
return queryInterface.dropTable('event_tags')
|
||||
}
|
||||
}
|
||||
};
|
|
@ -14,7 +14,7 @@ export const state = () => ({
|
|||
show_past_events: false,
|
||||
show_recurrent_events: false,
|
||||
show_pinned_event: false
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
export const getters = {
|
||||
|
|
Loading…
Reference in a new issue