better SEO
This commit is contained in:
@@ -56,10 +56,11 @@
|
||||
<script>
|
||||
import { mapState, mapActions, mapGetters } from 'vuex'
|
||||
import { MessageBox } from 'element-ui'
|
||||
import moment from 'dayjs'
|
||||
|
||||
export default {
|
||||
name: 'Event',
|
||||
// transition: null,
|
||||
transition: null,
|
||||
// Watch for $route.query.page to call
|
||||
// Component methods (asyncData, fetch, validate, layout, etc.)
|
||||
// watchQuery: ['id'],
|
||||
@@ -77,22 +78,32 @@ export default {
|
||||
title: `${this.settings.title} events tagged ${tag.tag}`, href: this.settings.baseurl + `/feed/rss?tags=${tag.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.slice(0, 1000) },
|
||||
content: this.event.description.replace("\n",'').slice(0, 1000) },
|
||||
{ hid: 'og-description',
|
||||
name: 'og:description',
|
||||
content: this.event.description.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: `event/${this.event.id}` },
|
||||
{ hid: 'og-url', property: 'og:url', content: `${this.settings.baseurl}/event/${this.event.id}` },
|
||||
{ property: 'og:type', content: 'event' },
|
||||
{ property: 'og:image', content: this.imgPath }
|
||||
{ property: 'og:image', content: `${this.settings.baseurl}/${this.imgPath}` },
|
||||
{ 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: '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) }
|
||||
],
|
||||
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
|
||||
|
||||
@@ -5,7 +5,9 @@ const config = require('config')
|
||||
const settings = require('./controller/settings')
|
||||
const debug = require('debug')('email')
|
||||
|
||||
// TOFIX
|
||||
moment.locale('it')
|
||||
|
||||
const mail = {
|
||||
send (addresses, template, locals) {
|
||||
debug(`Send ${template} email to ${addresses}`)
|
||||
|
||||
@@ -39,11 +39,11 @@ module.exports = (sequelize, DataTypes) => {
|
||||
//
|
||||
event.prototype.toAP = function (username, follower = []) {
|
||||
const tags = this.tags && this.tags.map(t => '#' + t.tag).join(' ')
|
||||
const content = `<a href='${config.baseurl}/event/${this.id}'>${this.title}<br/>
|
||||
const content = `<a href='${config.baseurl}/event/${this.id}'>${this.title}</a><br/>
|
||||
📍${this.place.name}<br/>
|
||||
⏰ ${moment.unix(this.start_datetime).format('dddd, D MMMM (HH:mm)')}<br/><br/>
|
||||
${this.description.length > 200 ? this.description.substr(0, 200) + '...' : this.description}<br/>
|
||||
${tags} <br/></a>`
|
||||
${tags} <br/>`
|
||||
|
||||
const attachment = []
|
||||
if (this.image_path) {
|
||||
|
||||
@@ -8,8 +8,6 @@ module.exports = {
|
||||
// search for related event
|
||||
const inReplyTo = body.object.inReplyTo
|
||||
const match = inReplyTo.match('.*\/federation\/m\/(.*)')
|
||||
console.error('inReplyTo', inReplyTo)
|
||||
console.error('match', match)
|
||||
if (!match || match.length < 2) {
|
||||
debug('Comment not found %s', inReplyTo)
|
||||
return res.status(404).send('Event not found!')
|
||||
|
||||
@@ -14,10 +14,10 @@ module.exports = {
|
||||
if (!user) { return res.status(404).send('User not found') }
|
||||
|
||||
// check for duplicate
|
||||
if (!user.fed_users.includes(body.actor)) {
|
||||
await user.addFed_users([req.fedi_user.id])
|
||||
if (!user.followers.includes(body.actor)) {
|
||||
await user.addFollowers([req.fedi_user.id])
|
||||
// await user.update({ followers: [...user.followers, body.actor] })
|
||||
debug('%s followed by %s (%d)', username, body.actor, user.fed_users.length+1)
|
||||
debug('%s followed by %s (%d)', username, body.actor, user.followers.length+1)
|
||||
} else {
|
||||
debug('duplicate %s followed by %s', username, body.actor)
|
||||
}
|
||||
@@ -37,7 +37,7 @@ module.exports = {
|
||||
async unfollow (req, res) {
|
||||
const body = req.body
|
||||
const username = body.object.object.replace(`${config.baseurl}/federation/u/`, '')
|
||||
const user = await User.findOne({ where: { username } })
|
||||
const user = await User.findOne({ where: { username }, include: { model: FedUsers, as: 'followers'} })
|
||||
if (!user) { return res.status(404).send('User not found') }
|
||||
|
||||
if (body.actor !== body.object.actor || body.actor !== req.fedi_user.id) {
|
||||
@@ -45,7 +45,7 @@ module.exports = {
|
||||
return res.status(400).send('Bad things')
|
||||
}
|
||||
|
||||
if (req.fedi_user) await user.removeFed_users(req.fedi_user.id)
|
||||
if (req.fedi_user) await user.removeFollowers(req.fedi_user.id)
|
||||
debug('%s unfollowed by %s', username, body.actor)
|
||||
res.sendStatus(200)
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ const Helpers = {
|
||||
const urlToIgnore = [
|
||||
'/api/v1/instance',
|
||||
'/api/meta',
|
||||
'/api/statusnet/version.json',
|
||||
'/api/gnusocial/version.json',
|
||||
'/api/statusnet/config.json',
|
||||
'/poco',
|
||||
]
|
||||
@@ -31,7 +33,7 @@ const Helpers = {
|
||||
const signer = crypto.createSign('sha256')
|
||||
const d = new Date()
|
||||
const stringToSign = `(request-target): post ${toUrl.path}\nhost: ${toUrl.hostname}\ndate: ${d.toUTCString()}`
|
||||
|
||||
debug('Sign and send', user.username, to)
|
||||
signer.update(stringToSign)
|
||||
signer.end()
|
||||
const signature = signer.sign(privkey)
|
||||
@@ -52,13 +54,10 @@ const Helpers = {
|
||||
|
||||
async sendEvent (event, user) {
|
||||
if (!settings.settings.enable_federation) {
|
||||
console.error(settings.settings)
|
||||
console.error(settings.secretSettings)
|
||||
debug('federation disabled')
|
||||
debug('event not send, federation disabled')
|
||||
return
|
||||
}
|
||||
|
||||
console.error('dentro sendEvent ', user)
|
||||
|
||||
// event is sent by user that published it and by the admin instance
|
||||
// collect followers from admin and user
|
||||
@@ -68,23 +67,24 @@ const Helpers = {
|
||||
return
|
||||
}
|
||||
|
||||
console.error(instanceAdmin.followers)
|
||||
let recipients = {}
|
||||
instanceAdmin.followers.forEach(follower => {
|
||||
const sharedInbox = follower.user_followers.endpoints.sharedInbox
|
||||
const sharedInbox = follower.object.endpoints.sharedInbox
|
||||
if (!recipients[sharedInbox]) recipients[sharedInbox] = []
|
||||
recipients[sharedInbox].push(follower.id)
|
||||
recipients[sharedInbox].push(follower.ap_id)
|
||||
})
|
||||
|
||||
for(const sharedInbox in recipients) {
|
||||
debug('Notify %s with event %s (from admin user %s) cc => %d', sharedInbox, event.title, instanceAdmin.username, recipients[sharedInbox].length)
|
||||
debug('Notify %s with event %s (from admin %s) cc => %d', sharedInbox, event.title, instanceAdmin.username, recipients[sharedInbox].length)
|
||||
const body = {
|
||||
id: `${config.baseurl}/federation/m/${event.id}#create`,
|
||||
type: 'Create',
|
||||
to: ['https://www.w3.org/ns/activitystreams#Public'],
|
||||
cc: [`${config.baseurl}/federation/u/${instanceAdmin.username}/followers`, ...recipients[sharedInbox]],
|
||||
// cc: [`${config.baseurl}/federation/u/${instanceAdmin.username}/followers`, ...recipients[sharedInbox]],
|
||||
cc: recipients[sharedInbox],
|
||||
actor: `${config.baseurl}/federation/u/${instanceAdmin.username}`,
|
||||
object: event.toAP(instanceAdmin.username, [`${config.baseurl}/federation/u/${instanceAdmin.username}/followers`, ...recipients[sharedInbox]])
|
||||
// object: event.toAP(instanceAdmin.username, [`${config.baseurl}/federation/u/${instanceAdmin.username}/followers`, ...recipients[sharedInbox]])
|
||||
object: event.toAP(instanceAdmin.username, recipients[sharedInbox])
|
||||
}
|
||||
body['@context'] = 'https://www.w3.org/ns/activitystreams'
|
||||
Helpers.signAndSend(body, instanceAdmin, sharedInbox)
|
||||
@@ -100,24 +100,27 @@ const Helpers = {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
debug('Sending to user followers => ', user.username)
|
||||
user = await User.findByPk( user.id, { include: { model: FedUsers, as: 'followers' }})
|
||||
debug('Sending to user followers => ', user.followers.length)
|
||||
recipients = {}
|
||||
user.followers.forEach(follower => {
|
||||
const sharedInbox = follower.object.endpoints.sharedInbox
|
||||
if (!recipients[sharedInbox]) recipients[sharedInbox] = []
|
||||
recipients[sharedInbox].push(follower.id)
|
||||
recipients[sharedInbox].push(follower.ap_id)
|
||||
})
|
||||
|
||||
debug(recipients)
|
||||
for(const sharedInbox in recipients) {
|
||||
debug('Notify %s with event %s (from admin user %s) cc => %d', sharedInbox, event.title, user.username, recipients[sharedInbox].length)
|
||||
debug('Notify %s with event %s (from user %s) cc => %d', sharedInbox, event.title, user.username, recipients[sharedInbox].length)
|
||||
const body = {
|
||||
id: `${config.baseurl}/federation/m/${event.id}#create`,
|
||||
type: 'Create',
|
||||
to: ['https://www.w3.org/ns/activitystreams#Public'],
|
||||
cc: [`${config.baseurl}/federation/u/${user.username}/followers`, ...recipients[sharedInbox]],
|
||||
// cc: [`${config.baseurl}/federation/u/${user.username}/followers`, ...recipients[sharedInbox]],
|
||||
cc: recipients[sharedInbox],
|
||||
actor: `${config.baseurl}/federation/u/${user.username}`,
|
||||
object: event.toAP(user.username, [`${config.baseurl}/federation/u/${user.username}/followers`, ...recipients[sharedInbox]])
|
||||
// object: event.toAP(user.username, [`${config.baseurl}/federation/u/${user.username}/followers`, ...recipients[sharedInbox]])
|
||||
object: event.toAP(user.username, recipients[sharedInbox])
|
||||
}
|
||||
body['@context'] = 'https://www.w3.org/ns/activitystreams'
|
||||
Helpers.signAndSend(body, user, sharedInbox)
|
||||
|
||||
Reference in New Issue
Block a user