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