Изменения документа HRlink. Новости об обновлениях
Редактировал(а) HRlink 22.08.2025
Сводка
-
Свойства страницы (1 изменено, 0 добавлено, 0 удалено)
Подробности
- Свойства страницы
-
- Содержимое
-
... ... @@ -1,15 +1,81 @@ 1 1 {{velocity}} 2 -#set($query = "select distinct post.category from doc.object(Blog.BlogPostClass) as post order by post.category") 3 -#set($categories = $services.query.xwql($query).execute()) 2 +#set($PERPAGE = 10) 4 4 5 -<h3>Все категории, используемые в блогах:</h3> 6 -<ul> 7 -#foreach($cat in $categories) 8 - <li><strong>"$cat"</strong></li> 4 +## --- Текущая страница категории --- 5 +#set($full = $doc.fullName) 6 + 7 +## Сформируем два варианта родителя: с .WebHome и без 8 +#set($pWith = $full) 9 +#if(!$full.endsWith(".WebHome")) 10 + #set($pWith = $full + ".WebHome") 9 9 #end 10 -</ul> 12 +#set($pBare = $full) 13 +#if($full.endsWith(".WebHome")) 14 + #set($pBare = $full.substring(0, $full.length() - 8)) 15 +#end 11 11 12 -#if($categories.isEmpty()) 13 - <p>Не найдено ни одной категории или нет блог-постов.</p> 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)) 28 +#if($p < 1) #set($p = 1) #end 29 +#set($offset = ($p - 1) * $PERPAGE) 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)) 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()) 14 14 #end 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()) 54 +#end 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 80 +#end 15 15 {{/velocity}}