Merge branch 'dev'

This commit is contained in:
lesion 2024-09-25 23:33:18 +02:00
commit 92a5abf1a0
No known key found for this signature in database
GPG key ID: 352918250B012177
6 changed files with 41 additions and 9 deletions

View file

@ -13,6 +13,7 @@ Is it possible to modify the style by integrating some custom css in `Admin > Th
Don't imagine you can accomplish miracles because the templates are not designed to be easily modified,
but don't be afraid to [open an issue](https://framagit.org/les/gancio/-/issues) or even better a PR to add some css selectors or some usage examples to this page.
Also note that for every element you want to change the style to, you need to overload the style already there: css has an order to choose which one to use, in case of conflict the more specific selector win (or you need to specify !important).
### Remove navbar
```css
@ -21,5 +22,15 @@ but don't be afraid to [open an issue](https://framagit.org/les/gancio/-/issues)
}
```
### Fixed footer
```css
footer.v-footer {
position: fixed;
bottom: 0px;
width: 100%;
}
```
> info "References"
> [#413](https://framagit.org/les/gancio/-/issues/413)
> [#451](https://framagit.org/les/gancio/-/issues/451)

View file

@ -177,6 +177,9 @@ export default {
disableAddress: false
}
},
mounted () {
this.$nextTick( async () => this.tags = await this.$axios.$get('/tag') )
},
head() {
return {
title: `${this.settings.title} - ${this.$t('common.add_event')}`

View file

@ -545,6 +545,9 @@ const eventController = {
// create/assign tags
let tags = []
if (body.tags) {
if (!Array.isArray(body.tags)) {
return res.status(400).send('tags field must be an array')
}
tags = await tagController._findOrCreate(body.tags)
await event.setTags(tags)
}
@ -691,6 +694,9 @@ const eventController = {
// create/assign tags
let tags = []
if (body.tags) {
if (!Array.isArray(body.tags)) {
return res.status(400).send('tags field must be an array')
}
tags = await tagController._findOrCreate(body.tags)
}
await event.setTags(tags)
@ -958,7 +964,7 @@ const eventController = {
const show_recurrent = settings.allow_recurrent_event && helpers.queryParamToBool(req.query.show_recurrent, settings.recurrent_event_visible)
let events = []
if (settings.collection_in_home && !(tags || places)) {
if (settings.collection_in_home && !(tags || places || query)) {
events = await collectionController._getEvents({
name: settings.collection_in_home,
start,

View file

@ -11,7 +11,7 @@ module.exports = {
async _findOrCreate (tags) {
// trim tags
const trimmedTags = tags.map(t => t.trim())
const trimmedTags = tags?.map(t => t.trim())
// search for already existing tags (case insensitive, note that LOWER sql function is not the same as toLocaleLowerCase due to #329)
const existingTags = await sequelize.query(`SELECT * FROM ${escapeCol('tags')} where LOWER(${escapeCol('tag')}) in (${tags.map(t => 'LOWER(?)').join(',')})`,
@ -72,13 +72,15 @@ module.exports = {
* sorted by usage
*/
async search (req, res) {
const search = req.query.search
const search = req?.query?.search
let where = { }
if (search) {
where = { tag: { [Op.like]: `%${search}%` } }
}
const tags = await Tag.findAll({
order: [[fn('COUNT', col('tag.tag')), 'DESC']],
attributes: ['tag'],
where: {
tag: { [Op.like]: `%${search}%` }
},
where,
include: [{ model: Event, where: { is_visible: true }, attributes: [], through: { attributes: [] }, required: true }],
group: ['tag.tag'],
limit: 10,

View file

@ -5,8 +5,8 @@ const log = require('../log')
module.exports = {
async boost (req, res) {
if (typeof req.body?.object !== 'string') {
log.debug('[FEDI] Igonre Boost for a whole object? %s', JSON.stringify(req.body?.object))
return res.status(404).send('?')
log.debug('[FEDI] Ignore Announce for a whole object (Announce are currently supported for internal events only): %s', JSON.stringify(req.body?.object))
return res.status(404).send('Announce is supported for internal events only')
}
const match = req.body?.object?.match(`${config.baseurl}/federation/m/(.*)`)
if (!match || match.length < 2) {

View file

@ -401,6 +401,16 @@ describe('Tags', () => {
expect(event.body.tags).toStrictEqual(['ciao'])
})
test('should not allow non-array tags field', async () => {
const response = await request(app).post('/api/event')
.send({ title: 'test non-array tags', place_id: places[1], start_datetime: dayjs().unix() + 1000, tags: 'Tag1' })
.auth(token.access_token, { type: 'bearer' })
.expect(400)
expect(response.text).toBe('tags field must be an array')
})
test('should create event trimming tags / ignore sensitiviness', async () => {
const ret = await request(app).post('/api/event')
.send({ title: 'test trimming tags', place_id: places[1], start_datetime: dayjs().unix() + 1000, tags: ['Tag1', 'taG2 '] })
@ -477,7 +487,7 @@ describe('Place', () => {
.expect(200)
expect(response.body.place.name).toBe('place name 2')
expect(response.body.events.length).toBe(3)
expect(response.body.events.length).toBe(4)
expect(response.body.events[0].place.name).toBe('place name 2')
})