fix(Public): handle URL erros
This commit is contained in:
parent
09269a95b7
commit
8231d58c82
1 changed files with 47 additions and 31 deletions
|
@ -70,11 +70,11 @@ export default class PublicController {
|
||||||
organizationsJSON: JSON.stringify(organizationsData)
|
organizationsJSON: JSON.stringify(organizationsData)
|
||||||
})
|
})
|
||||||
}).catch(err => () => {
|
}).catch(err => () => {
|
||||||
console.log(err)
|
console.error(err)
|
||||||
return ErrorController.handleServerError(err, req, res, [])
|
return ErrorController.handleServerError(err, req, res, [])
|
||||||
})
|
})
|
||||||
}).catch(err => () => {
|
}).catch(err => () => {
|
||||||
console.log(err)
|
console.error(err)
|
||||||
return ErrorController.handleServerError(err, req, res, [])
|
return ErrorController.handleServerError(err, req, res, [])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -138,13 +138,28 @@ export default class PublicController {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Utils.isStrUsable(version.contacts, 'facebook')) {
|
if (Utils.isStrUsable(version.contacts, 'facebook')) {
|
||||||
|
try {
|
||||||
version.contacts.facebookLabel = new URL(version.contacts.facebook).pathname.replace('/', '')
|
version.contacts.facebookLabel = new URL(version.contacts.facebook).pathname.replace('/', '')
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err)
|
||||||
|
version.contacts.facebook = version.contacts.facebookLabel = "OULA, c'est pas bon :("
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (Utils.isStrUsable(version.contacts, 'twitter')) {
|
if (Utils.isStrUsable(version.contacts, 'twitter')) {
|
||||||
|
try {
|
||||||
version.contacts.twitterLabel = new URL(version.contacts.twitter).pathname.replace('/', '')
|
version.contacts.twitterLabel = new URL(version.contacts.twitter).pathname.replace('/', '')
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err)
|
||||||
|
version.contacts.twitter = version.contacts.twitterLabel = "OULA, c'est pas bon :("
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (Utils.isStrUsable(version.contacts, 'instagram')) {
|
if (Utils.isStrUsable(version.contacts, 'instagram')) {
|
||||||
|
try {
|
||||||
version.contacts.instagramLabel = new URL(version.contacts.instagram).pathname.replace('/', '')
|
version.contacts.instagramLabel = new URL(version.contacts.instagram).pathname.replace('/', '')
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err)
|
||||||
|
version.contacts.instagram = version.contacts.instagramLabel = "OULA, c'est pas bon :("
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Array.isArray(version.gallery)) {
|
if (Array.isArray(version.gallery)) {
|
||||||
|
@ -153,10 +168,8 @@ export default class PublicController {
|
||||||
return media
|
return media
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
version.cutDescription = Utils.isStrUsable(version, 'descriptionLong') && version.descriptionLong.length > 200
|
if (Utils.isUsable(version, 'schedule')) {
|
||||||
|
|
||||||
// TODO: Rassembler les horaires qui sont dans le même jour, uniquement pour le front
|
// TODO: Rassembler les horaires qui sont dans le même jour, uniquement pour le front
|
||||||
|
|
||||||
version.schedule = version.schedule.map((s: any) => {
|
version.schedule = version.schedule.map((s: any) => {
|
||||||
let days = [...new Set(s.when.map((w: any) => w.day))]
|
let days = [...new Set(s.when.map((w: any) => w.day))]
|
||||||
return {
|
return {
|
||||||
|
@ -173,25 +186,28 @@ export default class PublicController {
|
||||||
description: s.description
|
description: s.description
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
version.cutDescription = Utils.isStrUsable(version, 'descriptionLong') && version.descriptionLong.length > 200
|
||||||
|
|
||||||
// if (version.cutDescription) {
|
// if (version.cutDescription) {
|
||||||
// version.descriptionFirstHalf = version.descriptionLong.substr(0, 200) // not gonna lie
|
// version.descriptionFirstHalf = version.descriptionLong.substr(0, 200) // not gonna lie
|
||||||
// version.descriptionSecondHalf = version.descriptionLong.substr(200)
|
// version.descriptionSecondHalf = version.descriptionLong.substr(200)
|
||||||
// }
|
// }
|
||||||
let hour = lastPublished.toLocaleTimeString('fr-FR', { timezone: '+2' })
|
// let hour = lastPublished.toLocaleTimeString('fr-FR', { timezone: '+2' })
|
||||||
if (hour.charAt(1) === ':') {
|
// if (hour.charAt(1) === ':') {
|
||||||
hour = '0' + hour
|
// hour = '0' + hour
|
||||||
}
|
// }
|
||||||
res.render('organization.twig', {
|
res.render('organization.twig', {
|
||||||
layout: 'standalone',
|
layout: 'standalone',
|
||||||
data: version,
|
data: version,
|
||||||
lastPublished: lastPublished.toLocaleDateString('fr-FR') + ' ' + hour.substr(0, 5),
|
//lastPublished: lastPublished.toLocaleDateString('fr-FR') + ' ' + hour.substr(0, 5),
|
||||||
isProposed,
|
isProposed,
|
||||||
id: org.get('_id')
|
id: org.get('_id')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}).catch(err => () => {
|
}).catch(err => () => {
|
||||||
console.log(err)
|
console.error(err)
|
||||||
return ErrorController.handleServerError(err, req, res, [])
|
return ErrorController.handleServerError(err, req, res, [])
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue