Changes for page ngi-0-logo


From version 2.5
edited by OW2
on 2024/09/18 14:07
Change comment: There is no comment for this version
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
... ... @@ -5,6 +5,28 @@
5 5  // Récupérer l'image en pièce jointe
6 6  def img = doc.getAttachment(attachmentName)
7 7  
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 +
8 8  if (img != null) {
9 9   def outs = response.outputStream
10 10   response.setContentType("image/png")
... ... @@ -18,5 +18,6 @@
18 18  } else {
19 19   response.sendError(404, "L'image n'existe pas.")
20 20  }
43 +
21 21  {{/groovy}}
22 22  
commonsfund.ngi-0-logo[0]
count
... ... @@ -1,0 +1,3 @@
1 +{
2 + "2024-09-18": 1
3 +}