feat: add a setting to display federated events in home page (default), fix #495

This commit is contained in:
lesion 2025-01-27 09:42:54 +01:00
parent 165c458433
commit 459882cc37
No known key found for this signature in database
GPG key ID: 352918250B012177
5 changed files with 18 additions and 4 deletions

View file

@ -10,6 +10,11 @@ v-container
template(v-if='enable_federation') template(v-if='enable_federation')
v-switch.mt-4(v-model='federated_events_in_home'
:label="$t('admin.federated_events_in_home')"
:hint="$t('admin.federated_events_in_home_help')"
persistent-hint inset)
v-switch.mt-4(v-model='enable_resources' v-switch.mt-4(v-model='enable_resources'
:label="$t('admin.enable_resources')" :label="$t('admin.enable_resources')"
:hint="$t('admin.enable_resources_help')" :hint="$t('admin.enable_resources_help')"
@ -157,6 +162,10 @@ export default {
get () { return this.settings.enable_resources }, get () { return this.settings.enable_resources },
set (value) { this.setSetting({ key: 'enable_resources', value }) } set (value) { this.setSetting({ key: 'enable_resources', value }) }
}, },
federated_events_in_home: {
get () { return this.settings.federated_events_in_home },
set (value) { this.setSetting({ key: 'federated_events_in_home', value }) }
},
default_fedi_hashtags: { default_fedi_hashtags: {
get () { return this.settings.default_fedi_hashtags }, get () { return this.settings.default_fedi_hashtags },
set (value) { this.setSetting({ key: 'default_fedi_hashtags', value }) } set (value) { this.setSetting({ key: 'default_fedi_hashtags', value }) }

View file

@ -350,7 +350,9 @@
"custom_js_help": "You can integrate some javascript code that will be loaded for each user by writing in this textarea below. You probably want to read the <a href='https://gancio.org/usage/custom_js'>documentation</a> first.", "custom_js_help": "You can integrate some javascript code that will be loaded for each user by writing in this textarea below. You probably want to read the <a href='https://gancio.org/usage/custom_js'>documentation</a> first.",
"custom_css_help": "You can customize some stylesheet too, read some example <a href='https://gancio.org/usage/custom_css'>here</a>.", "custom_css_help": "You can customize some stylesheet too, read some example <a href='https://gancio.org/usage/custom_css'>here</a>.",
"default_fedi_hashtags": "Default fediverse hashtags", "default_fedi_hashtags": "Default fediverse hashtags",
"default_fedi_hashtags_help": "The specified tags will be added to events sent to the fediverse" "default_fedi_hashtags_help": "The specified tags will be added to events sent to the fediverse",
"federated_events_in_home": "Show federated events on the home page",
"federated_events_in_home_help": "Incoming events from trusted federated sources will be shown by default on the home page. To only show some events you can use collections"
}, },
"auth": { "auth": {
"not_confirmed": "Not confirmed yet…", "not_confirmed": "Not confirmed yet…",

View file

@ -987,7 +987,7 @@ const eventController = {
const page = Number(req.query.page) || 0 const page = Number(req.query.page) || 0
const older = req.query.older || false const older = req.query.older || false
const show_federated = helpers.queryParamToBool(req.query.show_federated, false) const show_federated = helpers.queryParamToBool(req.query.show_federated, settings.federated_events_in_home)
const show_multidate = settings.allow_multidate_event && helpers.queryParamToBool(req.query.show_multidate, true) const show_multidate = settings.allow_multidate_event && helpers.queryParamToBool(req.query.show_multidate, true)
const show_recurrent = settings.allow_recurrent_event && helpers.queryParamToBool(req.query.show_recurrent, settings.recurrent_event_visible) const show_recurrent = settings.allow_recurrent_event && helpers.queryParamToBool(req.query.show_recurrent, settings.recurrent_event_visible)

View file

@ -39,6 +39,7 @@ const defaultSettings = {
tilelayer_provider: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', tilelayer_provider: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
tilelayer_provider_attribution: "<a target=\"_blank\" href=\"http://osm.org/copyright\">OpenStreetMap</a> contributors", tilelayer_provider_attribution: "<a target=\"_blank\" href=\"http://osm.org/copyright\">OpenStreetMap</a> contributors",
enable_federation: true, enable_federation: true,
federated_events_in_home: true,
enable_resources: false, enable_resources: false,
hide_boosts: true, hide_boosts: true,
enable_trusted_instances: true, enable_trusted_instances: true,

View file

@ -105,7 +105,8 @@ module.exports = {
collection_in_home: settings.collection_in_home, collection_in_home: settings.collection_in_home,
custom_js: settings.custom_js, custom_js: settings.custom_js,
custom_css: settings.custom_css, custom_css: settings.custom_css,
default_fedi_hashtags: settings.default_fedi_hashtags default_fedi_hashtags: settings.default_fedi_hashtags,
federated_events_in_home: settings.federated_events_in_home
} }
next() next()
}, },
@ -277,6 +278,7 @@ module.exports = {
const collectionController = require('./api/controller/collection') const collectionController = require('./api/controller/collection')
const eventController = require('./api/controller/event') const eventController = require('./api/controller/event')
const { DateTime } = require('luxon') const { DateTime } = require('luxon')
const show_federated = res.locals.settings.federated_events_in_home
const show_multidate = res.locals.settings.allow_multidate_event const show_multidate = res.locals.settings.allow_multidate_event
const show_recurrent = res.locals.settings.allow_recurrent_event const show_recurrent = res.locals.settings.allow_recurrent_event
const collection_in_home = res.locals.settings.collection_in_home const collection_in_home = res.locals.settings.collection_in_home
@ -286,7 +288,7 @@ module.exports = {
collectionController._getVisible(), collectionController._getVisible(),
collection_in_home ? collection_in_home ?
collectionController._getEvents({ name: collection_in_home, start: DateTime.local().toUnixInteger(), show_recurrent }) : collectionController._getEvents({ name: collection_in_home, start: DateTime.local().toUnixInteger(), show_recurrent }) :
eventController._select({ start: DateTime.local().toUnixInteger(), show_multidate, show_recurrent }) eventController._select({ start: DateTime.local().toUnixInteger(), show_multidate, show_recurrent, show_federated })
]) ])
res.locals.announcements = ret[0]?.value res.locals.announcements = ret[0]?.value