Changes for page ngi-0-logo


From version 2.1
edited by OW2
on 2024/09/18 14:01
Change comment: Upload new image "NGIZero_logo.png", version 1.1
To version 3.1
edited by OW2
on 2024/09/18 14:20
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -1,8 +1,45 @@
1 1  {{groovy}}
2 -
3 3  // Nom de l'image en pièce jointe
4 -def attachmentName = 'image.gif'
3 +def attachmentName = 'NGIZero_logo.png'
5 5  
5 +// Récupérer l'image en pièce jointe
6 +def img = doc.getAttachment(attachmentName)
6 6  
8 +// Accéder à l'objet et à la propriété 'count'
9 +def obj = doc.getObject(doc.toString())
10 +def countProperty = obj.getProperty('count')
11 +def countValue = countProperty.value
12 +
13 +// Initialiser un compteur pour la date du jour
14 +def currentDate = new Date().format('yyyy-MM-dd')
15 +def jsonSlurper = new groovy.json.JsonSlurper()
16 +def json = countValue ? jsonSlurper.parseText(countValue) : [:]
17 +
18 +// Incrémenter le compteur pour la date actuelle
19 +if (json.containsKey(currentDate)) {
20 + json[currentDate] += 1
21 +} else {
22 + json[currentDate] = 1
23 +}
24 +
25 +// Mettre à jour la propriété 'count' avec le nouveau JSON
26 +def jsonOutput = new groovy.json.JsonBuilder(json).toPrettyString()
27 +obj.set('count',jsonOutput)
28 +doc.save()
29 +
30 +if (img != null) {
31 + def outs = response.outputStream
32 + response.setContentType("image/png")
33 +
34 + // Récupérer le contenu de l'image
35 + def imgBytes = img.getContent()
36 +
37 + // Écrire les bytes dans le flux de sortie
38 + outs.write(imgBytes)
39 + outs.close()
40 +} else {
41 + response.sendError(404, "L'image n'existe pas.")
42 +}
43 +
7 7  {{/groovy}}
8 8  
commonsfund.ngi-0-logo[0]
count
... ... @@ -1,0 +1,3 @@
1 +{
2 + "2024-09-18": 1
3 +}
count
Editor
... ... @@ -1,0 +1,1 @@
1 +---
Pretty Name
... ... @@ -1,0 +1,1 @@
1 +count
Rows
... ... @@ -1,0 +1,1 @@
1 +5
Number
... ... @@ -1,0 +1,1 @@
1 +1
Size
... ... @@ -1,0 +1,1 @@
1 +40
Restricted
... ... @@ -1,0 +1,1 @@
1 +0
Name
... ... @@ -1,0 +1,1 @@
1 +count
Use Suggest
... ... @@ -1,0 +1,1 @@
1 +1