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

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

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

Сводка

Подробности

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