manage / display trusted instances
This commit is contained in:
parent
f42d96c06b
commit
b298e29a2d
6 changed files with 76 additions and 22 deletions
|
@ -15,14 +15,14 @@
|
|||
i.el-icon-share
|
||||
span.hidden-xs-only {{$t('common.share')}}
|
||||
|
||||
el-submenu(v-if='settings.trusted_instances && settings.trusted_instances.length' index=4)
|
||||
el-submenu(v-if='settings.enable_trusted_instances && settings.trusted_instances && settings.trusted_instances.length' index=4)
|
||||
template(slot='title')
|
||||
i.el-icon-guide
|
||||
span.hidden-xs-only {{$t('common.places')}}
|
||||
el-menu-item(v-for='instance in settings.trusted_instances' :key='instance.name')
|
||||
a(:href='instance.url' target='_link')
|
||||
img(:src='`${instance.url}/favicon.ico`')
|
||||
span.ml-1 {{instance.name}}
|
||||
img.mr-1(:src='`${instance.url}/favicon.ico`' style='height: 25px;')
|
||||
span.ml-1 {{instance.label || instance.name}}
|
||||
|
||||
el-menu-item(v-if='!$auth.loggedIn' index='/login')
|
||||
i.el-icon-user
|
||||
|
|
|
@ -12,12 +12,20 @@
|
|||
small.text-secondary {{$t('admin.hide_boost_bookmark_help')}}
|
||||
|
||||
div.mt-4 {{$t('admin.instance_name')}}
|
||||
el-input(v-model='instance_name' placeholder='Instance name')
|
||||
el-input(v-model='instance_name' placeholder='Instance name' @blur='save("instance_name", instance_name)')
|
||||
small.d-block.text-secondary {{$t('admin.instance_name_help')}} (<u>@{{instance_name}}@{{settings.baseurl|url2host}}</u>)
|
||||
|
||||
div.mt-4 {{$t('admin.trusted_instances')}}
|
||||
el-input(v-model='instance_url')
|
||||
el-button(slot='append' @click='createTrustedInstance') {{$t('common.send')}}
|
||||
el-switch.d-block.mt-4(v-model='enable_trusted_instances' :active-text="$t('admin.enable_trusted_instances')")
|
||||
small.text-secondary {{$t('admin.trusted_instances_help')}}
|
||||
|
||||
template(v-if='enable_trusted_instances')
|
||||
div.mt-4 {{$t('admin.instance_place')}}
|
||||
el-input(v-model='instance_place' @blur='save("instance_place", instance_place)')
|
||||
small.d-block.text-secondary {{$t('admin.instance_place_help')}}
|
||||
|
||||
div.mt-4 {{$t('admin.add_trusted_instance')}}
|
||||
el-input(v-model='instance_url' :placeholder="$t('common.url')")
|
||||
el-button(slot='append' @click='createTrustedInstance') {{$t('common.send')}}
|
||||
|
||||
el-table(:data='settings.trusted_instances')
|
||||
el-table-column(:label="$t('common.name')")
|
||||
|
@ -26,29 +34,32 @@
|
|||
el-table-column(:label="$t('common.url')")
|
||||
template(slot-scope='data')
|
||||
span {{data.row.url}}
|
||||
el-table-column(:label="$t('common.action')")
|
||||
el-table-column(:label="$t('common.place')")
|
||||
template(slot-scope='data')
|
||||
span {{data.row.label}}
|
||||
el-table-column(:label="$t('common.actions')")
|
||||
template(slot-scope='data')
|
||||
el-button(size='mini'
|
||||
type='danger'
|
||||
@click='delete_instance(data.row)') {{$t('admin.delete_user')}}
|
||||
@click='deleteInstance(data.row)') {{$t('admin.delete_user')}}
|
||||
|
||||
</template>
|
||||
<script>
|
||||
import { mapActions, mapState } from 'vuex'
|
||||
import { Message } from 'element-ui'
|
||||
import axios from 'axios'
|
||||
|
||||
export default {
|
||||
name: 'Federation',
|
||||
data () {
|
||||
data ({ $store }) {
|
||||
return {
|
||||
instance_url: ''
|
||||
instance_url: '',
|
||||
instance_name: $store.state.settings.instance_name,
|
||||
instance_place: $store.state.settings.instance_place
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState(['settings']),
|
||||
instance_name: {
|
||||
get () { return this.settings.instance_name },
|
||||
set (value) { this.setSetting({ key: 'instance_name', value }) }
|
||||
},
|
||||
enable_federation: {
|
||||
get () { return this.settings.enable_federation },
|
||||
set (value) { this.setSetting({ key: 'enable_federation', value }) }
|
||||
|
@ -60,10 +71,42 @@ export default {
|
|||
hide_boosts: {
|
||||
get () { return this.settings.hide_boosts },
|
||||
set (value) { this.setSetting({ key: 'hide_boosts', value }) }
|
||||
},
|
||||
enable_trusted_instances: {
|
||||
get () { return this.settings.enable_trusted_instances },
|
||||
set (value) { this.setSetting({ key: 'enable_trusted_instances', value }) }
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapActions(['setSetting']),
|
||||
async createTrustedInstance () {
|
||||
try {
|
||||
const instance = await axios
|
||||
.get(`${this.instance_url}/.well-known/nodeinfo/2.1`)
|
||||
console.error(instance)
|
||||
this.setSetting({
|
||||
key: 'trusted_instances',
|
||||
value: this.settings.trusted_instances.concat({
|
||||
url: this.instance_url,
|
||||
name: instance.data.metadata.nodeName,
|
||||
label: instance.data.metadata.nodeLabel
|
||||
})
|
||||
})
|
||||
this.instance_url = ''
|
||||
} catch (e) {
|
||||
Message({
|
||||
showClose: true,
|
||||
type: 'error',
|
||||
message: e
|
||||
})
|
||||
}
|
||||
},
|
||||
async deleteInstance (instance) {
|
||||
await this.setSetting({
|
||||
key: 'trusted_instances',
|
||||
value: this.settings.trusted_instances.filter(i => i.url !== instance.url)
|
||||
})
|
||||
},
|
||||
save (key, value) {
|
||||
if (this.settings[key] !== value) {
|
||||
this.setSetting({ key, value })
|
||||
|
|
|
@ -78,7 +78,9 @@
|
|||
"fediverse": "Fediverso",
|
||||
"skip": "Salta",
|
||||
"delete": "Elimina",
|
||||
"announcements": "Annunci"
|
||||
"announcements": "Annunci",
|
||||
"url": "Indirizzo URL",
|
||||
"place": "Luogo"
|
||||
},
|
||||
"login": {
|
||||
"description": "Entrando puoi pubblicare nuovi eventi.",
|
||||
|
@ -185,10 +187,14 @@
|
|||
"announcement_description": "In questa sezione puoi inserire annunci che rimarranno in homepage",
|
||||
"instance_locale": "Lingua di default",
|
||||
"instance_locale_description": "La lingua utilizzata per mostare le pagine è quella preferita dall'utente. In alcuni casi però dobbiamo mostrare dei messaggi per tutti allo stesso modo (ad esempio quando pubblichiamo via ActivityPub o nell'invio di alcune mail). In questi casi useremo la lingua selezionata qui sopra.",
|
||||
"instance_place": "Luogo indicativo dell'istanza",
|
||||
"instance_place": "Luogo indicativo di questa istanza",
|
||||
"title_description": "Viene usato nel titolo della pagina, nell'oggetto delle email, nell'esportazione dei feed e degli ics ",
|
||||
"description_description": "Compare nell'header accanto al titolo",
|
||||
"instance_name_help": "Nome dell'account ActivityPub da seguire"
|
||||
"instance_name_help": "Nome dell'account ActivityPub da seguire",
|
||||
"enable_trusted_instances": "Abilita istanze amiche",
|
||||
"trusted_instances_help": "Le istanze amiche compariranno nella barra di navigazione in cima alla pagina",
|
||||
"add_trusted_instance": "Aggiungi un istanza amica",
|
||||
"instance_place_help": "Verrà mostrata questa stringa nel menù delle altre istanze amiche"
|
||||
},
|
||||
"auth": {
|
||||
"not_confirmed": "Non abbiamo ancora confermato questa mail...",
|
||||
|
|
|
@ -13,6 +13,7 @@ const defaultSettings = {
|
|||
instance_timezone: 'Europe/Rome',
|
||||
instance_locale: 'en',
|
||||
instance_name: config.title.toLowerCase().replace(/ /g, ''),
|
||||
instance_place: '',
|
||||
allow_registration: true,
|
||||
allow_anon_event: true,
|
||||
allow_recurrent_event: false,
|
||||
|
@ -20,6 +21,7 @@ const defaultSettings = {
|
|||
enable_federation: true,
|
||||
enable_resources: false,
|
||||
hide_boosts: true,
|
||||
enable_trusted_instances: true,
|
||||
trusted_instances: []
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,8 @@ router.get('/nodeinfo/:nodeinfo_version', async (req, res) => {
|
|||
const ret = {
|
||||
metadata: {
|
||||
nodeDescription: req.settings.description,
|
||||
nodeName: req.settings.title
|
||||
nodeName: req.settings.title,
|
||||
nodeLabel: req.settings.instance_place
|
||||
},
|
||||
openRegistrations: settingsController.settings.allow_registration,
|
||||
protocols: ['activitypub'],
|
||||
|
@ -109,8 +110,8 @@ router.get('/x-nodeinfo2', async (req, res) => {
|
|||
router.get('/nodeinfo', (req, res) => {
|
||||
const ret = {
|
||||
links: [
|
||||
{ href: `${req.settings.baseurl}/.well-known/nodeinfo/2.0`, rel: `http://nodeinfo.diaspora.software/ns/schema/2.0` },
|
||||
{ href: `${req.settings.baseurl}/.well-known/nodeinfo/2.1`, rel: `http://nodeinfo.diaspora.software/ns/schema/2.1` }
|
||||
{ href: `${req.settings.baseurl}/.well-known/nodeinfo/2.0`, rel: 'http://nodeinfo.diaspora.software/ns/schema/2.0' },
|
||||
{ href: `${req.settings.baseurl}/.well-known/nodeinfo/2.1`, rel: 'http://nodeinfo.diaspora.software/ns/schema/2.1' }
|
||||
]
|
||||
}
|
||||
res.json(ret)
|
||||
|
|
|
@ -16,7 +16,9 @@ export const state = () => ({
|
|||
recurrent_event_visible: false,
|
||||
enable_federation: false,
|
||||
enable_resources: false,
|
||||
hide_boosts: true
|
||||
hide_boosts: true,
|
||||
enable_trusted_instances: true,
|
||||
trusted_instances: []
|
||||
},
|
||||
in_past: false,
|
||||
filters: {
|
||||
|
|
Loading…
Reference in a new issue