allow_anon_event, comment via mastodon

This commit is contained in:
lesion
2019-06-25 01:05:38 +02:00
parent 3c9c85e268
commit b093dae3f3
32 changed files with 259 additions and 219 deletions

View File

@@ -5,31 +5,6 @@
v-icon(name='times' color='red')
h3 {{$t('common.info')}}
p.
Gancio e' un progetto dell'<a href='https://autistici.org/underscore'>underscore hacklab</a> e uno dei
servizi di <a href='https://cisti.org'>cisti.org</a>.
h5 Cos'è gancio?
p.
Uno strumento di condivisione di eventi per comunità radicali.
Dentro gancio puoi trovare e inserire eventi.
Gancio, come tutto <a href='https://cisti.org'>cisti.org</a> è uno strumento
antisessista, antirazzista, antifascista e anticapitalista, riflettici quando
pubblichi un evento.
h5 Ok, ma cosa vuol dire gancio?
blockquote.
Se vieni a Torino e dici: "ehi, ci diamo un gancio alle 8?" nessuno si presenterà con i guantoni per fare a mazzate.
Darsi un gancio vuol dire beccarsi alle ore X in un posto Y
li A: a che ora è il gancio in radio per andare al presidio?
li B: non so ma domani non posso venire, ho gia' un gancio per caricare il bar.
br
h5 Contatti
p.
Hai scritto una nuova interfaccia per gancio? Vuoi aprire un nuovo nodo di gancio nella tua città?
C'è qualcosa che vorresti migliorare? Per contribuire i sorgenti sono liberi e disponibili
<a href='https://git.lattuga.net/cisti/gancio'>qui</a>. Aiuti e suggerimenti sono sempre benvenuti, puoi scriverci
su underscore chicciola autistici.org
div(v-html='$t("about")')
</template>

View File

@@ -1,8 +1,7 @@
<template lang="pug">
el-card(v-loading='loading')
el-card
nuxt-link.float-right(to='/')
el-button
v-icon(name='times' color='red')
v-icon(name='times' color='red')
h5 {{edit?$t('common.edit_event'):$t('common.add_event')}}
el-form
no-ssr
@@ -103,6 +102,9 @@ import { Message } from 'element-ui'
export default {
name: 'Add',
components: { List },
validate ({store}) {
return (store.state.auth.loggedIn || store.state.settings.allow_anon_event)
},
data() {
const month = moment().month()+1
const year = moment().year()
@@ -120,7 +122,6 @@ export default {
date: null,
time: { start: '20:00', end: null },
edit: false,
loading: true,
}
},
name: 'newEvent',
@@ -153,7 +154,6 @@ export default {
let event
try {
event = await $axios.$get('/event/'+ data.id)
console.error(event)
} catch (e) {
error({ statusCode: 404, message: 'Event not found!'})
return {}
@@ -174,10 +174,9 @@ export default {
if (event.tags) {
data.event.tags = event.tags.map(t => t.tag)
}
data.loading = false
return data
}
return { loading: false }
return {}
},
computed: {
...mapState({
@@ -221,6 +220,7 @@ export default {
.filter(e => e.multidate)
.map( e => ({ key: e.id, highlight: {}, dates: {
start: new Date(e.start_datetime*1000), end: new Date(e.end_datetime*1000) }})))
return attributes
},
disableAddress () {
return this.places_name.find(p => p.name === this.event.place.name)
@@ -301,7 +301,6 @@ export default {
}
if (this.event.tags)
this.event.tags.forEach(tag => formData.append('tags[]', tag))
this.loading = true
try {
if (this.edit) {
await this.updateEvent(formData)
@@ -310,10 +309,8 @@ export default {
}
this.updateMeta()
this.$router.replace('/')
Message({ type: 'success', message: this.$auth.loggedIn ? this.$t('event.added') : this.$t('event.added_anon')})
this.loading = false
Message({ type: 'success', showClose: true, message: this.$auth.loggedIn ? this.$t('event.added') : this.$t('event.added_anon')})
} catch (e) {
this.loading = false
console.error(e)
}
}

View File

@@ -1,8 +1,7 @@
<template lang="pug">
el-card
nuxt-link.float-right(to='/')
el-button
v-icon(name='times' color='red')
v-icon(name='times' color='red')
h5 {{$t('common.admin')}}
el-tabs(v-model='tab')
@@ -40,8 +39,8 @@
el-button(size='mini'
type='danger'
@click='delete_user(data.row)') {{$t('admin.delete_user')}}
el-pagination(:page-size='perPage' :currentPage.sync='userPage' :total='users.length')
no-ssr
el-pagination(:page-size='perPage' :currentPage.sync='userPage' :total='users.length')
//- PLACES
el-tab-pane.pt-1
@@ -60,7 +59,8 @@
template(slot-scope='data') {{data.row.name}}
el-table-column(:label="$t('common.address')")
template(slot-scope='data') {{data.row.address}}
el-pagination(:page-size='perPage' :currentPage.sync='placePage' :total='places.length')
no-ssr
el-pagination(:page-size='perPage' :currentPage.sync='placePage' :total='places.length')
//- EVENTS
el-tab-pane.pt-1
@@ -77,8 +77,8 @@
template(slot-scope='data')
el-button(type='primary' @click='confirm(data.row.id)' size='mini') {{$t('common.confirm')}}
el-button(type='success' @click='preview(data.row.id)' size='mini') {{$t('common.preview')}}
el-pagination(:page-size='perPage' :currentPage.sync='eventPage' :total='events.length')
no-ssr
el-pagination(:page-size='perPage' :currentPage.sync='eventPage' :total='events.length')
//- SETTINGS
el-tab-pane.pt-1
@@ -96,6 +96,9 @@
p {{$t('admin.allow_registration_description')}}
el-form-item(:label="allow_registration?$t('common.disable'):$t('common.enable')")
el-switch(v-model='allow_registration')
p {{$t('admin.allow_anon_event')}}
el-form-item(:label="allow_anon_event?$t('common.disable'):$t('common.enable')")
el-switch(v-model='allow_anon_event')
</template>
@@ -141,7 +144,6 @@ export default {
},
async asyncData ({ $axios, params, store }) {
try {
console.error(store)
const users = await $axios.$get('/users')
const events = await $axios.$get('/event/unconfirmed')
return { users, events, mastodon_instance: store.state.settings.mastodon_instance }
@@ -152,12 +154,12 @@ export default {
computed: {
...mapState(['tags', 'places', 'settings']),
allow_registration: {
get () {
return this.settings.allow_registration
},
set (value) {
this.setSetting({ key: 'allow_registration', value })
}
get () { return this.settings.allow_registration },
set (value) { this.setSetting({ key: 'allow_registration', value }) }
},
allow_anon_event: {
get () { return this.settings.allow_anon_event },
set (value) { this.setSetting({ key: 'allow_anon_event', value })}
},
paginatedEvents () {
return this.events.slice((this.eventPage-1) * this.perPage,
@@ -221,6 +223,7 @@ export default {
.then( () => this.$axios.delete(`/user/${user.id}`) )
.then( () => {
Message({
showClose: true,
type: 'success',
message: this.$t('admin.user_remove_ok')
})
@@ -232,12 +235,15 @@ export default {
this.loading = true
const user = await this.$axios.$post('/user', this.new_user)
this.new_user = { email: '', password: '', is_admin: false }
Message({
Message({
showClose: true,
type: 'success',
message: this.$t('admin.user_create_ok')
})
this.users.push(user)
} catch (e) {
Message({
showClose: true,
type: 'error',
message: this.$t('user.error_create') + e
})
@@ -250,6 +256,7 @@ export default {
this.loading = false
Message({
message: this.$t('event.confirmed'),
showClose: true,
type: 'success'
})
this.events = this.events.filter(e => e.id !== id)

View File

@@ -2,8 +2,7 @@
el-card#eventDetail(v-loading='!loaded')
//- close button
nuxt-link.float-right(to='/')
el-button(type='danger' plain)
v-icon(name='times')
v-icon(name='times' color='red')
div(v-if='!event')
h5 {{$t('event.not_found')}}
@@ -13,10 +12,10 @@
h5.text-center {{event.title}}
div.nextprev
nuxt-link(v-if='prev' :to='`/event/${prev.id}`')
el-button(round type='success')
el-button( type='success' size='mini')
v-icon(name='chevron-left')
nuxt-link.float-right(v-if='next' :to='`/event/${next.id}`')
el-button(round type='success')
el-button(type='success' size='mini')
v-icon(name='chevron-right')
//- image
@@ -43,18 +42,20 @@
//- comments
.card-body(v-if='event.activitypub_id && settings')
strong {{$t('common.related')}} -
a(:href='`https://mastodon.cisti.org/web/statuses/${event.activitypub_id}`') {{$t('common.add')}}
a(:href='`https://${settings.mastodon_instance}/web/statuses/${event.activitypub_id}`') {{$t('common.add')}}
.card-header(v-for='comment in event.comments' :key='comment.id')
img.avatar(:src='comment.data.last_status.account.avatar')
strong {{comment.author}}
a.float-right(:href='comment.data.last_status.url')
//- a.float-right(:href='comment.data.last_status.url')
a.float-right(:href='`https://${settings.mastodon_instance}/web/statuses/${comment.data.last_status.id}`')
small {{comment.data.last_status.created_at|datetime}}
div.mt-1(v-html='comment_filter(comment.text)')
img(v-for='img in comment.data.last_status.media_attachments' :src='img.preview_url')
div.mt-1(v-html='comment_filter(comment.data.last_status.content)')
img(v-for='img in comment.data.last_status.media_attachments' :src='img.url')
</template>
<script>
import { mapState, mapActions, mapGetters } from 'vuex'
import { MessageBox } from 'element-ui'
export default {
name: 'Event',
@@ -147,9 +148,13 @@ export default {
},
async remove () {
try {
await MessageBox.confirm(this.$t('event.remove_confirmation'), this.$t('common.confirm'), {
confirmButtonText: this.$t('common.ok'),
cancelButtonText: this.$t('common.cancel'),
type: 'error'})
await this.$axios.delete(`/user/event/${this.id}`)
this.delEvent(Number(this.id))
this.$router.back()
this.$router.replace("/")
} catch (e) {
console.error(e)
}
@@ -184,7 +189,8 @@ export default {
}
h5 {
font-size: 1.4em;
font-size: 2em;
font-weight: 600;
min-height: 40px;
}

View File

@@ -2,11 +2,9 @@
el-card
nuxt-link.float-right(to='/')
el-button
v-icon(name='times' color='red')
v-icon(name='times' color='red')
h5 {{$t('common.export')}}
p {{$t('export.intro')}}
Search
//- li(v-if='filters.tags.length') {{$t('common.tags')}}:
@@ -71,28 +69,28 @@ export default {
components: { List, Search },
data () {
return {
type: 'email',
type: 'feed',
notification: { email: '' },
list: { title: 'Gancio' },
}
},
// filters,
methods: {
// TODO
async add_notification () {
if (!this.notification.email){
Message({message:'Inserisci una mail', type: 'error'})
Message({message:'Inserisci una mail', showClose: true, type: 'error'})
// return this.$refs.email.focus()
}
// await api.addNotification({ ...this.notification, filters: this.filters})
// this.$refs.modal.hide()
Message({message: this.$t('email_notification_activated'), type: 'success'})
Message({message: this.$t('email_notification_activated'), showClose: true, type: 'success'})
},
imgPath (event) {
return event.image_path && event.image_path
},
},
computed: {
...mapState(['filters', 'events']),
...mapState(['filters', 'events', 'settings']),
...mapGetters(['filteredEvents']),
listScript () {
const params = []
@@ -108,7 +106,7 @@ export default {
params.push(`tags=${this.filters.tags}`)
}
return `<iframe src="${this.$axios.defaults.baseURL}/embed/list?${params.join('&')}"></iframe>`
return `<iframe src="${this.settings.baseurl}/embed/list?${params.join('&')}"></iframe>`
},
link () {
const tags = this.filters.tags.join(',')
@@ -124,7 +122,7 @@ export default {
}
}
return `${this.$axios.defaults.baseURL}/api/export/${this.type}${query}`
return `${this.settings.baseurl}/api/export/${this.type}${query}`
},
showLink () {
return (['feed', 'ics'].indexOf(this.type)>-1)

View File

@@ -1,11 +1,9 @@
<template lang='pug'>
el-card
nuxt-link.float-right(to='/')
v-icon(name='times' color='red')
h5 {{$t('common.login')}}
el-form(v-loading='loading' method='POST' action='/api/auth/login')
el-form(v-loading='loading')
p(v-html="$t('login.description')")
el-input.mb-2(v-model='email' type='email' name='email'
@@ -16,7 +14,7 @@
type='password' :placeholder='$t("common.password")')
v-icon(name='lock' slot='prepend')
el-button.mr-1(plain type="success" native-type='submit'
el-button.mr-1(plain type="success"
:disabled='disabled' @click='submit') {{$t('common.login')}}
nuxt-link(to='/register' v-if='settings.allow_registration')
@@ -50,7 +48,7 @@ export default {
...mapActions(['login']),
async forgot () {
if (!this.email) {
Message({ message: this.$t('login.insert_email'), type: 'error' })
Message({ message: this.$t('login.insert_email'), showClose:true, type: 'error' })
this.$refs.email.focus()
return
}
@@ -60,15 +58,16 @@ export default {
Message({ message: this.$t('login.check_email'), type: 'success' })
},
async submit (e) {
console.error('dentro submit', e)
e.preventDefault()
try {
this.loading = true
await this.$auth.loginWith('local', { data: { email: this.email, password: this.password } })
this.loading = false
Message({ message: this.$t('login.ok'), type: 'success' })
Message({ message: this.$t('login.ok'), showClose: true, type: 'success' })
} catch (e) {
e = get(e, 'response.data.message', e)
Message({ message: this.$t('login.error') + this.$t(e), type: 'error' })
Message({ message: this.$t('login.error') + this.$t(e), showClose: true, type: 'error' })
this.loading = false
return
}

View File

@@ -37,11 +37,13 @@ export default {
try {
const res = await this.$axios.$post('/user/recover_password', { recover_code: this.code, password: this.new_password })
Message({
showClose: true,
type: 'success',
message: this.$t('Password changed!')
})
} catch(e) {
Message({
showClose: true,
type: 'warning',
message: e
})

View File

@@ -50,6 +50,7 @@ export default {
try {
const { user } = await this.$axios.$post('/user/register', this.user)
Message({
showClose: true,
message: this.$t(`register.${user.is_admin ? 'admin_' : ''}complete`),
type: 'success'
})
@@ -57,6 +58,7 @@ export default {
} catch (e) {
const error = get(e, 'e.response.data.errors[0].message', String(e))
Message({
showClose: true,
message: this.$t('register.error') + this.$t(error),
type: 'error'
})

View File

@@ -1,8 +1,7 @@
<template lang="pug">
el-card
nuxt-link.float-right(to='/')
el-button
v-icon(name='times' color='red')
v-icon(name='times' color='red')
h5 {{$t('common.settings')}}
el-form(action='/api/user' method='PUT' @submit.native.prevent='change_password')
@@ -35,7 +34,7 @@ export default {
const user_data = { id : this.$auth.user.id, password: this.password }
try {
const user = await this.$axios.$put('/user', user_data)
Message({ message: this.$t('settings.password_updated'), type: 'success' })
Message({ message: this.$t('settings.password_updated'), showClose: true, type: 'success' })
this.$router.replace('/')
} catch (e) {
console.log(e)