Code source wiki de Macros
Modifié par Administrator le 2007/04/10 16:05
Afficher les derniers auteurs
author | version | line-number | content |
---|---|---|---|
1 | #macro(blog $category $nbitems $nbstart) | ||
2 | |||
3 | #if(!$maxchars) | ||
4 | #set($maxchars = 400) | ||
5 | #end | ||
6 | |||
7 | <div class="hfeed"> | ||
8 | #if("$!category"=="") | ||
9 | #set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='XWiki.ArticleClass' and obj.name<>'XWiki.ArticleClassTemplate' order by doc.creationDate desc") | ||
10 | #else | ||
11 | #set ($sql = ", BaseObject as obj, DBStringListProperty as prop join prop.list list where obj.name=doc.fullName and obj.className='XWiki.ArticleClass' and obj.name<>'XWiki.ArticleClassTemplate' and obj.id=prop.id.id and prop.id.name='category' and list='${category}' order by doc.creationDate desc") | ||
12 | ## TODO: feed category | ||
13 | #end | ||
14 | #set($cdate = "") | ||
15 | #set($inbitems = $util.parseInt($nbitems)) | ||
16 | #set($inbstart = $util.parseInt($nbstart)) | ||
17 | #foreach ($item in $xwiki.searchDocuments($sql, $inbitems, $inbstart)) | ||
18 | #set($bentrydoc = $xwiki.getDocument($item)) | ||
19 | #if($bentrydoc.fullName == $item) | ||
20 | #set($bentryobj = $bentrydoc.getObject("XWiki.ArticleClass")) | ||
21 | #set($creationDate = $xwiki.formatDate($bentrydoc.creationDate, "MMMM dd, yyyy")) | ||
22 | #if($cdate!=$creationDate) | ||
23 | <div class="article_date">$creationDate</div> | ||
24 | #set ($cdate = $creationDate) | ||
25 | #end | ||
26 | <div class="hentry"> | ||
27 | <h3 class="entry-title"><a href="$bentrydoc.getURL()">$bentrydoc.display("title","view", $bentryobj)</a></h3> | ||
28 | <div class="article_content entry-summary"> | ||
29 | #set($content = $bentrydoc.display("extract", "view", $bentryobj)) | ||
30 | #if($content=="") | ||
31 | #set($content = $bentrydoc.display("content", "view", $bentryobj)) | ||
32 | #if($content.length()>400) | ||
33 | #set($i = $content.lastIndexOf(" ", $maxchars)) | ||
34 | #set($i = $i + 1) | ||
35 | #set($content = "${content.substring(0,$i)} [...>${bentrydoc.fullName}]") | ||
36 | #end | ||
37 | #else | ||
38 | #set($content = "${content} [...>${bentrydoc.fullName}]") | ||
39 | #end | ||
40 | $bentrydoc.getRenderedContent($content, $bentrydoc.syntaxId) | ||
41 | </div> ## entry-content | ||
42 | <div class="article_footer"> | ||
43 | #set($bcategories = $bentryobj.getProperty("category").value) | ||
44 | Posted by <address class="author vcard">#userfn($bentrydoc.creator)</address> at <abbr class="published" title="#formatdateISO($bentrydoc.creationDate)">$xwiki.formatDate($bentrydoc.creationDate, "MMM dd, yyyy HH:mm")</abbr>#if($bcategories.size() > 0) in #foreach($bcategory in $bcategories)<a rel="tag" href="$xwiki.getURL("Blog.Category", "view", "category=${bcategory}")">$bcategory</a> #end#end #if($bentrydoc.date != $bentrydoc.creationDate) | Modified by <address class="author vcard">#userfn($bentrydoc.author)</address> at <abbr class="updated" title="#formatdateISO($bentrydoc.date)">$xwiki.formatDate($bentrydoc.date, "MMM dd, yyyy HH:mm")</abbr> #end | [$bentrydoc.comments.size() Comment(s)>${bentrydoc.fullName}?xpage=comments] | <a href="$bentrydoc.getURL("view")" rel="bookmark">Permalink</a> | ||
45 | </div> ## article_footer | ||
46 | </div> ## hentry | ||
47 | #end | ||
48 | #end | ||
49 | ## | ||
50 | ## prev/next links | ||
51 | #if (!$velocityCount) | ||
52 | ## if $velocityCount has not been initialized (e.g. $xwiki.searchDocuments has returned an empty list) | ||
53 | #set($velocityCount = -1) | ||
54 | #end | ||
55 | #if(($inbstart != 0) || ($velocityCount==$inbitems)) | ||
56 | <div class="pagingLinks"> | ||
57 | #if ($inbstart!=0) | ||
58 | #set($iprev = $inbstart - $inbitems) | ||
59 | <span class="prevPage">[Previous>$doc.name?category=$!category&nbstart=${iprev}]</span> | ||
60 | #end | ||
61 | #if($velocityCount==$inbitems) | ||
62 | #set($inext = $inbstart + $inbitems) | ||
63 | <span class="nextPage">[Next>$doc.name?category=$!category&nbstart=${inext}]</span> | ||
64 | #end | ||
65 | <span class="clear"></span> | ||
66 | </div> ## pagingLinks | ||
67 | #end | ||
68 | </div> ## hfeed | ||
69 | #end | ||
70 | #if("$!{nbitems}" == '') | ||
71 | #set($nbitems = "10") | ||
72 | #end | ||
73 | #if("$!{nbstart}" == '') | ||
74 | #set($nbstart = "0") | ||
75 | #end | ||
76 | #blog($category $nbitems $nbstart) |