Версия 9.1 от HRlink на 21.08.2025

Последние авторы
1 {{velocity}}
2 ## ------ НАСТРОЙКИ ------
3 #set($PERPAGE = 10) ## записей на страницу
4
5 ## ------ ПРЕФИКС ВЕТКИ ------
6 #set($full = $doc.fullName) ## напр.: Blog.HRlink.-Novosti-ob-obnovleniiakh-.WebHome
7 #set($lastDot = $full.lastIndexOf('.'))
8 #set($PREFIX = $full.substring(0, $lastDot) + ".") ## напр.: Blog.HRlink.-Novosti-ob-obnovleniiakh-.
9
10 ## ------ ПАГИНАЦИЯ ------
11 #set($p = $request.get('p'))
12 #if(!$p) #set($p = 1) #end
13 #set($p = $numbertool.toInteger($p))
14 #if($p < 1) #set($p = 1) #end
15 #set($offset = ($p - 1) * $PERPAGE)
16
17 ## ------ СКОЛЬКО ВСЕГО ДОКУМЕНТОВ В ВЕТКЕ ------
18 #set($total = $services.query.hql(
19 "select count(doc.fullName) from XWikiDocument doc " +
20 "where doc.fullName like :prefix"
21 ).bindValue("prefix", $PREFIX + "%").execute().get(0))
22
23 ## ------ ТЕКУЩАЯ СТРАНИЦА ДОКУМЕНТОВ (НОВЫЕ СВЕРХУ) ------
24 #set($docs = $services.query.hql(
25 "select doc.fullName from XWikiDocument doc " +
26 "where doc.fullName like :prefix " +
27 "order by doc.date desc"
28 ).bindValue("prefix", $PREFIX + "%").setLimit($PERPAGE).setOffset($offset).execute())
29
30 ## ------ ВЫВОД ЛЕНТЫ ------
31 #foreach($fn in $docs)
32 #set($d = $xwiki.getDocument($fn))
33 <article style="margin:14px 0; padding-bottom:10px; border-bottom:1px solid #e5e7eb">
34 <div style="color:#6b7280; font-size:.9em">$datetool.format('dd MMM yyyy', $d.date)</div>
35 <h3 style="margin:.2rem 0"><a href="$d.getURL('view')">$escapetool.html($d.displayTitle)</a></h3>
36 <div>$!d.getPlainContent().substring(0,300)…</div>
37 </article>
38 #end
39
40 ## ------ ПАГИНАЦИЯ ------
41 #if($total > $PERPAGE)
42 #set($pages = ($total + $PERPAGE - 1) / $PERPAGE)
43 #set($base = $doc.getURL('view'))
44 #set($prev = $math.sub($p, 1))
45 #set($next = $math.add($p, 1))
46 <nav style="margin-top:1em; display:flex; gap:1em; align-items:center">
47 #if($p > 1)
48 <a href="$base?p=$prev">← Назад</a>
49 #else
50 <span style="opacity:.5">← Назад</span>
51 #end
52 <span>Стр. $p / $pages</span>
53 #if($p < $pages)
54 <a href="$base?p=$next">Далее →</a>
55 #else
56 <span style="opacity:.5">Далее →</span>
57 #end
58 </nav>
59 #end
60 {{/velocity}}