comment from mastodon to gancio

This commit is contained in:
lesion
2019-04-30 01:04:24 +02:00
parent ac5ef6e324
commit e50e5434bc
7 changed files with 81 additions and 67 deletions

View File

@@ -32,6 +32,17 @@
"prio": 0,
"references": [],
"title": "export lista"
},
{
"assignedTo": {
"name": "lesion"
},
"category": "feature",
"creation_time": "2019-04-23T19:56:46.263Z",
"id": "11",
"prio": 1,
"references": [],
"title": "get comments / media from mastodon"
}
],
"testing": [
@@ -72,17 +83,6 @@
"title": "rivedere ux / messaggi utente",
"type": "bug"
},
{
"assignedTo": {
"name": "lesion"
},
"category": "feature",
"creation_time": "2019-04-23T19:56:46.263Z",
"id": "11",
"prio": 1,
"references": [],
"title": "get comments / media from mastodon"
},
{
"assignedTo": {
"name": "lesion"
@@ -115,6 +115,15 @@
"title": "risolvere le modali quando il js e' disabilitato",
"type": "bug"
},
{
"assignedTo": {
"name": "lesion"
},
"creation_time": "2019-04-29T10:01:01.632Z",
"id": "14",
"references": [],
"title": "gestione errori quando non c'e' un evento"
},
{
"assignedTo": {
"name": "lesion"
@@ -134,6 +143,15 @@
"references": [],
"title": "rifare il calendario o solo il popup"
},
{
"assignedTo": {
"name": "lesion"
},
"creation_time": "2019-04-28T09:25:50.701Z",
"id": "13",
"references": [],
"title": "test altra visualizzazione"
},
{
"assignedTo": {
"name": "lesion"
@@ -156,15 +174,6 @@
"references": [],
"title": "documentare sorgenti",
"type": "bug"
},
{
"assignedTo": {
"name": "lesion"
},
"creation_time": "2019-04-28T09:25:50.701Z",
"id": "13",
"references": [],
"title": "test altra visualizzazione"
}
]
}

View File

@@ -10,7 +10,7 @@
span.d-md-none {{$t('common.add_event')}}
b-nav-item(v-if='$auth.loggedIn' to='/settings' v-b-tooltip :title='$t("common.settings")') <v-icon color='orange' name='cog'/>
span.d-md-none {{$t('common.settings')}}
b-nav-item(v-if='$auth.user.is_admin' to='/admin' v-b-tooltip :title='$t("common.admin")') <v-icon color='lightblue' name='tools'/>
b-nav-item(v-if='$auth.user && $auth.user.is_admin' to='/admin' v-b-tooltip :title='$t("common.admin")') <v-icon color='lightblue' name='tools'/>
span.d-md-none {{$t('common.admin')}}
b-nav-item(to='/export' v-b-tooltip :title='$t("common.export")') <v-icon name='file-export' color='yellow'/>
span.d-md-none {{$t('common.export')}}

View File

@@ -35,7 +35,9 @@
"hide": "Nascondi",
"remove": "Elimina",
"edit": "Modifica",
"actions": "Azioni"
"actions": "Azioni",
"resources": "Risorse",
"add": "Aggiungi"
},
"login": {
@@ -58,7 +60,8 @@
"anon_description": "",
"where_description" : "Dov'è il gancio? Se è un luogo fisico, scrivi il suo nome del per esteso (tipo 'Mezcal Squat'), se è una Piazza/Via metti quella (tipo 'Piazza Castello, Torino'). Se trovi già il luogo dell'evento premilo e l'indirizzo verrà autocompletato.",
"address_description": "",
"tag_description": "Puoi inserire un tag (es. concerto, corteo)"
"tag_description": "Puoi inserire un tag (es. concerto, corteo)",
"added": "Avento aggiunto"
},
"admin": {
@@ -69,4 +72,3 @@
"mastodon_instance": "Istanza mastodon"
}
}

View File

@@ -14,7 +14,6 @@
br
b-card-body(v-if='event.description || event.tags')
pre(v-html='event.description')
br
el-tag.mr-1(:color='tag.color' v-for='tag in event.tags'
size='mini' :key='tag.tag') {{tag.tag}}
div(v-if='mine')
@@ -24,27 +23,17 @@
el-button(plain type='danger' @click.prevent='remove' icon='el-icon-remove') {{$t('common.remove')}}
el-button(plain type='primary' @click='$router.replace("/edit/"+event.id)') <v-icon color='orange' name='edit'/> {{$t('common.edit')}}
//- COMMENTS ...
//- b-navbar(type="dark" variant="dark" toggleable='lg')
//- template(slot='footer')
//- b-navbar-nav
//- b-button(variant='success') {{$t('Share')}} <v-icon name='share'/>
//- b-nav-item( {{$t('')}})
//- b-card-footer.text-right
//- span.mr-3 {{event.comments.length}} <v-icon name='comments'/>
//- a(href='#', @click='remove')
v-icon(color='orange' name='times')
//- el-footer(v-for='comment in event.comments')
strong {{comment.author}}
div(v-html='comment.text')
//- el-timeline
//- el-timeline-item(v-for='comment in event.comments')
//- p(v-html='comment.text')
//- a.el-timeline-item__timestamp(href='') {{comment.createdAt}}
strong {{$t('common.comments')}}
div.text.item(v-for='comment in event.comments')
span(v-html='comment.text')
b-card-body(v-if='event.activitypub_id')
strong {{$t('common.resources')}} -
a(:href='`https://mastodon.cisti.org/web/statuses/${event.activitypub_id}`') {{$t('common.add')}}
b-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')
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')
//- span {{comment}}
</template>
<script>
import { mapState, mapActions } from 'vuex';
@@ -74,7 +63,7 @@ export default {
},
mine () {
return this.event.userId === this.$auth.user.id || this.$auth.user.is_admin
}
},
},
data () {
return {
@@ -83,25 +72,25 @@ export default {
loading: true,
}
},
// mounted () {
// this.id = this.$route.params.id
// this.load()
// },
async asyncData ( { $axios, params }) {
console.error('daje dentro asyncData!')
console.error('async data porcod')
const event = await $axios.$get(`/event/${params.id}`)
// this.event = event
// this.loading = false
return { event, id: params.id, loading: false }
},
methods: {
...mapActions(['delEvent']),
// async load () {
// const event = await this.api.getEvent(this.id)
// this.event = event
// this.loading = false
// },
comment_filter (value) {
console.log('dentro comment_filter')
return value.replace(/<a.*href="([^">]+).*>(?:.(?!\<\/a\>))*.<\/a>/, (orig, url) => {
// get extension
const ext = url.slice(-4)
console.log('dentro il replace ', ext)
if (['.mp3', '.ogg'].indexOf(ext)>-1) {
return `<audio controls><source src='${url}'></audio>`
} else {
return orig
}
})
},
async remove () {
await api.delEvent(this.event.id)
this.delEvent(this.event.id)
@@ -125,6 +114,15 @@ export default {
</script>
<style>
#eventDetail .avatar {
height: 40px;
border-radius: 5px;
}
#eventDetail .image {
max-height: 200px;
}
/* #eventDetail {
display: block !important;
opacity: 1;
@@ -144,10 +142,10 @@ export default {
}
#eventDetail .close_button {
background-color: rgba(100, 100, 100, 0.4);
background-color: rgba(100, 100, 100, 0.3);
color: red;
font-size: 20px;
border: none;
border: 1px dashed rgba(20,20,20,0.3);
position: absolute;
top: 10px;
right: 10px;

View File

@@ -72,7 +72,12 @@ ${event.description.length > 200 ? event.description.substr(0, 200) + '...' : ev
// const comment = await Comment.findOne( {where: { }})
return
}
const comment = await Comment.create({activitypub_id: msg.data.last_status.id, text: msg.data.last_status.content, author: msg.data.accounts[0].username })
const comment = await Comment.create({
activitypub_id: msg.data.last_status.id,
text: msg.data.last_status.content,
data: msg.data,
author: msg.data.accounts[0].username
})
event.addComment(comment)
console.log(event)
// const comment = await Comment.findOne( { where: {activitypub_id: msg.data.in_reply_to}} )

View File

@@ -1,5 +1,5 @@
const Sequelize = require('sequelize')
const conf = require('./config.js')
const db = new Sequelize(conf.db)
// db.sync({force: true})
db.sync()
module.exports = db

View File

@@ -10,7 +10,7 @@ const Event = db.define('event', {
end_datetime: { type: Sequelize.DATE, index: true },
image_path: Sequelize.STRING,
is_visible: Sequelize.BOOLEAN,
activitypub_id: { type: Sequelize.INTEGER, index: true },
activitypub_id: { type: Sequelize.STRING, index: true },
// activitypub_ids: { type: Sequelize.ARRAY, index}
})
@@ -20,9 +20,9 @@ const Tag = db.define('tag', {
})
const Comment = db.define('comment', {
activitypub_id: { type: Sequelize.INTEGER, index: true },
activitypub_id: { type: Sequelize.STRING, index: true },
data: Sequelize.JSON,
url: Sequelize.STRING,
media_attachments: { type: Sequelize.ARRAY(Sequelize.STRING) },
author: Sequelize.STRING,
text: Sequelize.STRING
})