Show last authors
1 {{velocity}}
2 ###################
3 ## Configuration ##
4 ###################
5 ##
6 #set($source = 'class') ##json/class
7 ##
8 #set($json = 'Calendar.ExampleJSON')
9 #set($className = 'Blog.BlogPostClass')
10 #set($classDateField = 'publishDate')
11 ##
12 ######################
13 ## Display calendar ##
14 ######################
15 ##
16 #if("$!request.year" != '' && "$!request.month" != '')
17
18
19 {{calendar
20 #if($source == 'json')
21 json = "$json"
22 #else
23 classname = "$className"
24 startfield = "$classDateField"
25 #end
26 #if("$!request.day" != '')
27 defaultView = "agendaDay"
28 #end
29 editable = "false"
30 year = "$request.year"
31 month = "$request.month"
32 date = "#if("$!request.day" != '')$request.day#{else}1#{end}"
33 /}}
34
35 ##
36 ###################
37 ## Generate JSON ##
38 ###################
39 ##
40 #elseif("$!request.events" != '' && "$!request.xpage" == 'plain')
41 $response.setContentType('application/json')
42 ##
43 #set ($months = $request.events.split(','))
44 #set ($previous = [])
45 #set ($current = [])
46 #set ($next = [])
47 ##
48 #if ("$source" == 'json')
49 #set ($jsonURL = "$xwiki.getDocument($json).getExternalURL('get', 'xpage=plain&outputSyntax=plain')")
50 #set ($jsonData = $xwiki.getURLContent($jsonURL))
51 #set ($res = $jsontool.parse($jsonData))
52 #elseif ("$source" == 'class')
53 #set($hql = "select doc.fullName from XWikiDocument doc, BaseObject obj, DateProperty prop where doc.fullName=obj.name and obj.className='$className' and prop.id.id=obj.id and prop.name='$classDateField'")
54 #set($res = $xwiki.wrapDocs($xwiki.search($hql, 0, 0)))
55 #end
56 #foreach ($r in $res)
57 #if ("$source" == 'json')
58 #set($rDate = $datetool.toDate('yyyy-M-d', $r.get('start')))
59 #elseif ("$source" == 'class')
60 #set($rDate = $r.getObject($className).getProperty($classDateField).value)
61 #end
62 ##
63 #set($monthYear = $datetool.format('M-yyyy', $rDate))
64 #set($day = $datetool.format('d', $rDate))
65 ##
66 #if ($monthYear == $months[0] && !$previous.contains($day))
67 #set($ok = $previous.add($day))
68 #elseif ($monthYear == $months[1] && !$current.contains($day))
69 #set($ok = $current.add($day))
70 #elseif ($monthYear == $months[2] && !$next.contains($day))
71 #set($ok = $next.add($day))
72 #end
73 #end
74 {
75 "previous" : $previous,
76 "current" : $current,
77 "next" : $next
78 }
79 #end
80 {{/velocity}}
This wiki is licensed under a Creative Commons 2.0 license
XWiki Enterprise 13.10.5 - Documentation