Last modified by Administrator on 2010/08/19 12:49

Show last authors
1 {{include document="Blog.BlogCode"/}}
2
3 {{velocity output="false"}}
4 ##
5 ##
6 ##
7 #**
8 * Display a blog as a RSS feed. The output corresponds to the RSS 1.0 specification, and it makes use of the Dublin
9 * Core module to specify metadata.
10 *
11 * @param blogDoc The XDocument corresponding to the blog to be syndicated.
12 * @param entries The entries to display. Usually, these are the last entries belonging to the blog.
13 *###
14 #macro(displayBlogRss $blogDoc $entries)
15 ## Create a Jodatime date formatter that will be used to format dates
16 #set($dateFormatter = $xwiki.jodatime.getDateTimeFormatterForPattern("yyyy-MM-dd'T'hh:mm:ssZZ"))
17 ## Set the right mimetype
18 $!response.setContentType('application/rdf+xml')##
19 #setBlogRssCacheSettings()
20 #printBlogRssHeader()
21 #printBlogRssChannelDescription($blogDoc $entries)
22 #printBlogRssImage($blogDoc)
23 #printBlogRssItems($entries)
24 #printBlogRssFooter()
25 #end
26 ##
27 ##
28 ##
29 #**
30 * Display blog entries from all the wiki as a RSS feed. The output corresponds to the RSS 1.0 specification, and it
31 * makes use of the Dublin Core module to specify metadata.
32 *
33 * @param entries The entries to display. Usually, these are the last entries belonging to the blog.
34 *###
35 #macro(displayGlobalBlogRss $entries)
36 ## Create a Jodatime date formatter that will be used to format dates
37 #set($dateFormatter = $xwiki.jodatime.getDateTimeFormatterForPattern("yyyy-MM-dd'T'hh:mm:ssZZ"))
38 ## Set the right mimetype
39 $!response.setContentType('application/rdf+xml')##
40 #setBlogRssCacheSettings()
41 #printBlogRssHeader()
42 #printGlobalBlogRssChannelDescription($entries)
43 #printWikiRssImage($blogDoc)
44 #printBlogRssItems($entries)
45 #printBlogRssFooter()
46 #end
47 ##
48 ##
49 ##
50 #**
51 * Display blog entries belonging to a target category as a RSS feed. The output corresponds to the RSS 1.0
52 * specification, and it makes use of the Dublin Core module to specify metadata.
53 *
54 * @param blogDoc The XDocument corresponding to the blog to be syndicated.
55 * @param categoryDoc The XDocument corresponding to the blog category to be syndicated.
56 * @param entries The entries to display. Usually, these are the last entries belonging to the blog.
57 *###
58 #macro(displayBlogCategoryRss $blogDoc $categoryDoc $entries)
59 ## Create a Jodatime date formatter that will be used to format dates
60 #set($dateFormatter = $xwiki.jodatime.getDateTimeFormatterForPattern("yyyy-MM-dd'T'hh:mm:ssZZ"))
61 ## Set the right mimetype
62 $!response.setContentType('application/rdf+xml')##
63 #setBlogRssCacheSettings()
64 #printBlogRssHeader()
65 #printBlogCategoryRssChannelDescription($categoryDoc $entries)
66 #printBlogRssItems($entries)
67 #printBlogRssFooter()
68 #end
69 ##
70 ##
71 ##
72 #**
73 * Set the proper cache settings, both for the client (HTTP headers) and for the server (rendering cache).
74 *###
75 #macro(setBlogRssCacheSettings)
76 ## Internally cache the rendered RSS for 30 minutes, for better performance
77 ## TODO: This is disabled for security reasons. Since the cache doesn't take into account the current user, it might
78 ## serve hidden/unpublished entries to non-creators.
79 ## $!context.setCacheDuration(1800)
80 ## Instruct the client to cache the response for 1 hour
81 #set($expires = $xwiki.jodatime.getMutableDateTime())##
82 $!expires.addHours(1)##
83 ## TODO: This has no effect, as the core contains a no-cache setting in com.xpn.xwiki.web.Utils
84 $!response.setDateHeader('Expires', $expires.millis)##
85 $!response.setHeader('Cache-Control', 'public')##
86 #end
87 ##
88 ##
89 ##
90 #**
91 * Print the start of the RSS: XML declaration and open root element.
92 *###
93 #macro(printBlogRssHeader)
94 <?xml version="1.0" encoding="$xwiki.encoding" ?>
95 <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/">
96 #end
97 ##
98 ##
99 ##
100 #**
101 * Print the blog channel description: title, link, description, logo, creator, copyright, and the list of entries.
102 *
103 * @param blogDoc The XDocument corresponding to the blog to be displayed.
104 * @param entries The entries to display. Usually, these are the last entries belonging to the blog.
105 *###
106 #macro(printBlogRssChannelDescription $blogDoc $entries)
107 <channel rdf:about="$blogDoc.getURL()">
108 #getBlogTitle($blogDoc $title)
109 <title>$title</title>
110 <link>$blogDoc.getExternalURL()</link>
111 ## TODO: Add a Description field in the blog class
112 <description>Most recent blog posts in the $blogDoc.space space</description>
113 #getWikiLogo($logoUrl)
114 <image rdf:resource="$logoUrl"/>
115 <dc:language>$blogDoc.defaultLanguage</dc:language>
116 <dc:rights>$escapetool.xml($xwiki.webCopyright)</dc:rights>
117 ## TODO: Usually this is not something meaningful. Maybe add some Blog object properties for these.
118 ## <dc:publisher>$escapetool.xml($xwiki.getUserName($blogDoc.author, false))</dc:publisher>
119 ## <dc:creator>$escapetool.xml($xwiki.getUserName($blogDoc.creator, false))</dc:creator>
120 <items>
121 <rdf:Seq>
122 ## This is just a list of blog entries, which are detailed below.
123 #foreach ($entryDoc in $entries)
124 #if($xwiki.hasAccessLevel('view', ${entryDoc.fullName}))
125 <rdf:li rdf:resource="$entryDoc.getExternalURL('view', "language=${entryDoc.realLanguage}")" />
126 #end
127 #end
128 </rdf:Seq>
129 </items>
130 </channel>
131 #end
132 ##
133 ##
134 ##
135 #**
136 * Print the wiki-wide channel description: title, link, description, logo, creator, copyright, and the list of entries.
137 *
138 * @param entries The entries to display. Usually, these are the last entries published in the wiki.
139 *###
140 #macro(printGlobalBlogRssChannelDescription $entries)
141 ## TODO: Replace hardcoded Main.WebHome with a setting once the core provides this information.
142 #set($mainDoc = $xwiki.getDocument('Main.WebHome'))
143 <channel rdf:about="$mainDoc.getExternalURL()">
144 <title>$xwiki.getXMLEncoded($mainDoc.displayTitle)</title>
145 <link>$mainDoc.getExternalURL()</link>
146 ## TODO: Add a Description field in the blog class
147 <description>Most recent blog posts in the wiki</description>
148 #getWikiLogo($logoUrl)
149 <image rdf:resource="$logoUrl"/>
150 <dc:rights>$escapetool.xml($xwiki.webCopyright)</dc:rights>
151 <dc:publisher>XWiki</dc:publisher>
152 <items>
153 <rdf:Seq>
154 ## This is just a list of blog entries, which are detailed below.
155 #foreach ($entryDoc in $entries)
156 #if($xwiki.hasAccessLevel('view', ${entryDoc.fullName}))
157 <rdf:li rdf:resource="$entryDoc.getExternalURL('view', "language=${entryDoc.realLanguage}")" />
158 #end
159 #end
160 </rdf:Seq>
161 </items>
162 </channel>
163 #end
164 ##
165 ##
166 ##
167 #**
168 * Print the blog channel description: title, link, description, logo, creator, copyright, and the list of entries.
169 *
170 * @param blogDoc The XDocument corresponding to the blog to be displayed.
171 * @param entries The entries to display. Usually, these are the last entries belonging to the blog.
172 *###
173 #macro(printBlogCategoryRssChannelDescription $categoryDoc $entries)
174 <channel rdf:about="$categoryDoc.getURL()">
175 <title>$categoryDoc.display('name')</title>
176 <link>$categoryDoc.getExternalURL()</link>
177 ## TODO: Add a Description field in the blog class
178 <description>Most recent blog posts in the $categoryDoc.display('name') category</description>
179 <dc:rights>$escapetool.xml($xwiki.webCopyright)</dc:rights>
180 <items>
181 <rdf:Seq>
182 ## This is just a list of blog entries, which are detailed below.
183 #foreach ($entryDoc in $entries)
184 #if($xwiki.hasAccessLevel('view', ${entryDoc.fullName}))
185 <rdf:li rdf:resource="$entryDoc.getExternalURL('view', "language=${entryDoc.realLanguage}")" />
186 #end
187 #end
188 </rdf:Seq>
189 </items>
190 </channel>
191 #end
192 ##
193 ##
194 ##
195 #**
196 * Print the blog image description. Currently, this is the logo of the wiki.
197 *
198 * @param blogDoc The XDocument corresponding to the displayed blog.
199 *###
200 #macro(printBlogRssImage $blogDoc)
201 #getWikiLogo($logoUrl)
202 <image rdf:about="$logoUrl">
203 <title>Wiki Logo</title>
204 <url>$logoUrl</url>
205 <link>$blogDoc.getExternalURL()</link>
206 </image>
207 #end
208 ##
209 ##
210 ##
211 #**
212 * Print the syndicated blog entries. These are the detailed "item"s, which must be referenced above, in the channel
213 * description, as otherwise they are ignored.
214 *
215 * @param entries The entries to display. Usually, these are the last entries belonging to the blog.
216 *###
217 #macro(printBlogRssItems $entries)
218 ## Print all the entry details
219 #foreach ($entryDoc in $entries)
220 #if($xwiki.hasAccessLevel('view', ${entryDoc.fullName}))
221 #printBlogRssItem($entryDoc)
222 #end
223 #end
224 #end
225 ##
226 ##
227 ##
228 #**
229 * Print a blog entry in the RSS feed. besides the mandatory RSS elements (title, link, and description), also print
230 * some metadata in the Dublin Core vocabulary (creator, categories, date).
231 *
232 * @param entryDoc The XDocument corresponding to the displayed blog entry.
233 *###
234 #macro(printBlogRssItem $entryDoc)
235 #set($entryUrl = $entryDoc.getExternalURL('view', "language=${entryDoc.realLanguage}"))
236 #getEntryObject($entryDoc $entryObj)
237 #getEntryContent($entryDoc $entryObj true $entryContent)
238 #if($!entryDoc.syntax.toIdString() == 'xwiki/1.0')
239 #set($desc = $entryContent)
240 #else
241 #set($desc = $entryDoc.getRenderedContent($entryContent, $entryDoc.getSyntax().toIdString()))
242 #end
243 #set($desc = $escapetool.xml($desc))
244 <item rdf:about="$entryUrl">
245 <title>$escapetool.xml($entryDoc.display("title", "view", $entryObj))</title>
246 <link>$entryUrl</link>
247 <description>$desc</description>
248 ## Some metadata, using the Dublin Core extension to RSS.
249 ## TODO: Display this in a better way.
250 <dc:subject>$escapetool.xml($entryObj.display('category', 'view'))</dc:subject>
251 <dc:date>$dateFormatter.print($entryDoc.date.time)</dc:date>
252 <dc:creator>$escapetool.xml($xwiki.getUserName($entryDoc.creator, false))</dc:creator>
253 #if($entryDoc.creator != $entryDoc.author)
254 <dc:contributor>
255 <rdf:Description link="$xwiki.getURL($entryDoc.author)">
256 <rdf:value>$escapetool.xml($xwiki.getUserName($entryDoc.author, false))</rdf:value>
257 </rdf:Description>
258 </dc:contributor>
259 #end
260 </item>
261 #end
262 ##
263 ##
264 ##
265 #**
266 * Print the end of the RSS: close the root element.
267 *###
268 #macro(printBlogRssFooter)
269 </rdf:RDF>
270 #end
271 ##
272 ##
273 ##
274 #**
275 * Normally, this should be a Template eXtension, which would be used to display a blog as a RSS feed. Since TX are not
276 * yet implemented, the target blog should be passed in the URL. This macro determines exactly which blog should be
277 * syndicated. If the "blog" request parameter is not present, then the default Blog is used.
278 *
279 * @param blogDoc The resulting XDocument of the target blog.
280 *###
281 #macro(getTargetBlog $blogDoc)
282 #if("$!{request.blog}" != '')
283 #set($blogDoc = $xwiki.getDocument($request.blog))
284 #else
285 #getBlogDocument('Blog' $blogDoc)
286 #end
287 ## TODO: Check if the document has a Blog.BlogClass object.
288 #end
289 ##
290 ##
291 ##
292 #macro(printFieldContent $entryDoc $entryObj $fieldName)
293 $escapetool.xml($entryDoc.display($fieldName, 'view', $entryObj))#end
294 ##
295 ##
296 ##
297 #macro(getWikiLogo $logoUrl)
298 #set($logoUrl = $xwiki.getSkinFile($xwiki.getSkinPreference('logo', 'logo.png')))
299 #set($port = '')
300 #if(($request.scheme == 'http') && ($request.serverPort != 80))
301 #set($port = ":${request.serverPort}")
302 #elseif(($request.scheme == 'https') && ($request.serverPort != 443))
303 #set($port = ":${request.serverPort}")
304 #end
305 #set($logoUrl = "${request.scheme}://${request.serverName}${port}$logoUrl")
306 #end
307 {{/velocity}}

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [daning:Blog.BlogParameters]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [daning:Blog.BlogCode]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [daning:Blog.RecentPostsPanel]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [daning:Blog.BlogParameters]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [daning:Blog.BlogCode]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [daning:Blog.UnpublishedPanel]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [daning:Blog.BlogParameters]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [daning:Blog.BlogCode]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [daning:Blog.CategoriesCode]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [daning:Blog.CategoriesPanel]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [daning:Blog.BlogParameters]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [daning:Blog.BlogCode]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [daning:Blog.ArchivePanel]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.