Изменения документа HRlink. Новости об обновлениях

Редактировал(а) HRlink 22.08.2025

От версии 25.1
отредактировано HRlink
на 22.08.2025
Изменить комментарий: К данной версии нет комментариев
К версии 9.1
отредактировано HRlink
на 21.08.2025
Изменить комментарий: К данной версии нет комментариев

Сводка

Подробности

Свойства страницы
Содержимое
... ... @@ -1,67 +1,60 @@
1 1  {{velocity}}
2 -#set($PERPAGE = 10)
2 +## ------ НАСТРОЙКИ ------
3 +#set($PERPAGE = 10) ## записей на страницу
3 3  
4 -## --- Текущая страница категории ---
5 -#set($parentRef = $doc.documentReference) ## надёжно даже с "\." в именах
6 -#set($full = $doc.fullName) ## напр.: Blog.HRlink.-Novosti-ob-obnovleniiakh-.WebHome
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-.
7 7  
8 -## Префикс для фоллбэка: убираем .WebHome и добавляем точку
9 -#set($prefix = $full)
10 -#if($full.endsWith('.WebHome'))
11 - #set($prefix = $full.substring(0, $full.length() - 8))
12 -#end
13 -#set($prefix = $prefix + '.')
14 -
15 -## --- Пагинация ---
16 -#set($p = $request.get('p')) #if(!$p) #set($p = 1) #end
17 -#set($p = $numbertool.toInteger($p)) #if($p < 1) #set($p = 1) #end
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
18 18  #set($offset = ($p - 1) * $PERPAGE)
19 19  
20 -## --- A) дети по parent = текущая страница (DocumentReference) ---
21 -#set($total = $services.query.xwql(
22 - "select count(doc.fullName) from Document doc where doc.parent = :p"
23 -).bindValue('p', $parentRef).execute().get(0))
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))
24 24  
25 -#set($rows = [])
26 -#if($total > 0)
27 - #set($rows = $services.query.xwql(
28 - "select doc.fullName from Document doc where doc.parent = :p order by doc.date desc"
29 - ).bindValue('p', $parentRef).setLimit($PERPAGE).setOffset($offset).execute())
30 -#end
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())
31 31  
32 -## --- B) если вдруг пусто — берём по префиксу полного имени (включая подкатегории) ---
33 -#if($total == 0)
34 - #set($total = $services.query.xwql(
35 - "select count(doc.fullName) from Document doc where doc.fullName like :pref"
36 - ).bindValue('pref', $prefix + '%').execute().get(0))
37 - #set($rows = $services.query.xwql(
38 - "select doc.fullName from Document doc where doc.fullName like :pref order by doc.date desc"
39 - ).bindValue('pref', $prefix + '%').setLimit($PERPAGE).setOffset($offset).execute())
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>
40 40  #end
41 41  
42 -## --- Рендер ленты и пагинация ---
43 -#if($total == 0)
44 - <p>Пока нет публикаций в этой ветке.</p>
45 -#else
46 - #foreach($fn in $rows)
47 - #set($d = $xwiki.getDocument($fn))
48 - <article style="margin:14px 0; padding-bottom:10px; border-bottom:1px solid #e5e7eb">
49 - <div style="color:#6b7280; font-size:.9em">$datetool.format('dd MMM yyyy', $d.date)</div>
50 - <h3 style="margin:.2rem 0"><a href="$d.getURL('view')">$escapetool.html($d.displayTitle)</a></h3>
51 - <div>$!d.getPlainContent().substring(0,300)…</div>
52 - </article>
53 - #end
54 -
55 - #if($total > $PERPAGE)
56 - #set($pages = ($total + $PERPAGE - 1) / $PERPAGE)
57 - #set($base = $doc.getURL('view'))
58 - #set($prev = $math.sub($p, 1))
59 - #set($next = $math.add($p, 1))
60 - <nav style="margin-top:1em; display:flex; gap:1em; align-items:center">
61 - #if($p > 1)<a href="$base?p=$prev">← Назад</a>#else<span style="opacity:.5">← Назад</span>#end
62 - <span>Стр. $p / $pages</span>
63 - #if($p < $pages)<a href="$base?p=$next">Далее →</a>#else<span style="opacity:.5">Далее →</span>#end
64 - </nav>
65 - #end
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>
66 66  #end
67 67  {{/velocity}}