Изменения документа HRlink. Новости об обновлениях
Редактировал(а) HRlink 22.08.2025
Сводка
-
Свойства страницы (1 изменено, 0 добавлено, 0 удалено)
Подробности
- Свойства страницы
-
- Содержимое
-
... ... @@ -1,91 +1,46 @@ 1 +{{blog space="Blog.HRlink.-Novosti-ob-obnovleniiakh-" /}} 1 1 {{velocity}} 2 -## ========== НАСТРОЙКИ ========== 3 -#set($SPACE = "Blog.HRlink.Новости об обновлениях") ## пространство категории 4 -#set($PERPAGE = 10) ## записей на страницу 3 +#set($PERPAGE = 10) 5 5 6 -## ========== ТЕКУЩАЯ СТРАНИЦА ПАГИНАЦИИ ========== 7 -#set($p = $request.get('p')) 8 -#if(!$p) #set($p = 1) #end 9 -#set($p = $numbertool.toInteger($p)) 5 +## префикс ветки, например: Blog.HRlink.-Novosti-ob-obnovleniiakh-. 6 +#set($full = $doc.fullName) 7 +#set($lastDot = $full.lastIndexOf('.')) 8 +#set($PREFIX = $full.substring(0, $lastDot) + ".") 9 + 10 +## пагинация 11 +#set($p = $numbertool.toInteger($!request.get('p') ?: 1)) 10 10 #if($p < 1) #set($p = 1) #end 11 11 #set($offset = ($p - 1) * $PERPAGE) 12 12 13 -## ==========ВСЕГО ЗАПИСЕЙ (для пагинации)==========15 +## всего документов в ветке 14 14 #set($total = $services.query.hql( 15 - "select count(doc.fullName) " + 16 - "from XWikiDocument doc, BaseObject obj " + 17 - "where obj.name = doc.fullName " + 18 - "and obj.className = 'Blog.BlogPostClass' " + 19 - "and doc.space = :space" 20 -).bindValue("space", $SPACE).execute().get(0)) 17 + "select count(doc.fullName) from XWikiDocument doc " + 18 + "where doc.fullName like :prefix" 19 +).bindValue("prefix", $PREFIX + "%").execute().get(0)) 21 21 22 -## ========== ВЫБОРКА ТЕКУЩЕЙ СТРАНИЦЫ ========== 23 -#set($posts = $services.query.hql( 24 - "select doc.fullName " + 25 - "from XWikiDocument doc, BaseObject obj " + 26 - "where obj.name = doc.fullName " + 27 - "and obj.className = 'Blog.BlogPostClass' " + 28 - "and doc.space = :space " + 21 +## текущая страница документов (новые сверху) 22 +#set($docs = $services.query.hql( 23 + "select doc.fullName from XWikiDocument doc " + 24 + "where doc.fullName like :prefix " + 29 29 "order by doc.date desc" 30 -).bindValue(" space", $SPACE).setLimit($PERPAGE).setOffset($offset).execute())26 +).bindValue("prefix", $PREFIX + "%").setLimit($PERPAGE).setOffset($offset).execute()) 31 31 32 -## ========== ОТРИСОВКА ЛЕНТЫ ========== 33 -#macro(renderEntry $fullName) 34 - #set($d = $xwiki.getDocument($fullName)) 35 - <article class="sl-blog-entry"> 36 - <div class="sl-meta">$datetool.format('dd MMM yyyy', $d.date)</div> 37 - <h3 class="sl-title"><a href="$d.getURL('view')">$escapetool.html($d.displayTitle)</a></h3> 38 - <div class="sl-excerpt">$!d.getPlainContent().substring(0, 300)…</div> 28 +#foreach($fn in $docs) 29 + #set($d = $xwiki.getDocument($fn)) 30 + <article style="margin:14px 0; padding-bottom:10px; border-bottom:1px solid #e5e7eb"> 31 + <div style="color:#6b7280; font-size:.9em">$datetool.format('dd MMM yyyy', $d.date)</div> 32 + <h3 style="margin:.2rem 0"><a href="$d.getURL('view')">$escapetool.html($d.displayTitle)</a></h3> 33 + <div>$!d.getPlainContent().substring(0,300)…</div> 39 39 </article> 40 40 #end 41 41 42 -<div class="sl-blog-list"> 43 - #if($posts.isEmpty()) 44 - <p>Записей пока нет.</p> 45 - #else 46 - #foreach($pfull in $posts) 47 - #renderEntry($pfull) 48 - #end 49 - #end 50 -</div> 51 - 52 -## ========== ПАГИНАЦИЯ ========== 53 53 #if($total > $PERPAGE) 54 - #set($pages = ($total + $PERPAGE - 1) / $PERPAGE) ## округление вверх 55 - #set($baseUrl = $doc.getURL('view')) 56 - 57 - <nav class="sl-pager"> 58 - ## Назад 59 - #if($p > 1) 60 - <a class="prev" href="$baseUrl?p=$eval.format('%d', $p-1)">← Назад</a> 61 - #else 62 - <span class="disabled prev">← Назад</span> 63 - #end 64 - 65 - <span class="pageinfo">$p / $eval.format('%d', $pages)</span> 66 - 67 - ## Далее 68 - #if($p < $pages) 69 - <a class="next" href="$baseUrl?p=$eval.format('%d', $p+1)">Далее →</a> 70 - #else 71 - <span class="disabled next">Далее →</span> 72 - #end 38 + #set($pages = ($total + $PERPAGE - 1) / $PERPAGE) 39 + #set($base = $doc.getURL('view')) 40 + <nav style="margin-top:1em; display:flex; gap:1em; align-items:center"> 41 + #if($p > 1)<a href="$base?p=$math.sub($p,1)">← Назад</a>#else<span style="opacity:.5">← Назад</span>#end 42 + <span>Стр. $p / $pages</span> 43 + #if($p < $pages)<a href="$base?p=$math.add($p,1)">Далее →</a>#else<span style="opacity:.5">Далее →</span>#end 73 73 </nav> 74 74 #end 75 - 76 76 {{/velocity}} 77 - 78 -{{html clean="false"}} 79 -<style> 80 -.sl-blog-entry{padding:12px 0;border-bottom:1px solid #e5e7eb} 81 -.sl-blog-entry:last-child{border-bottom:0} 82 -.sl-meta{color:#6b7280;font-size:.9em;margin-bottom:.25rem} 83 -.sl-title{margin:.1rem 0 .35rem} 84 -.sl-title a{text-decoration:none} 85 -.sl-excerpt{color:#374151} 86 -.sl-pager{display:flex;align-items:center;gap:.75rem;margin-top:1rem} 87 -.sl-pager .disabled{opacity:.45} 88 -.sl-pager a{text-decoration:none} 89 -.sl-pager .pageinfo{margin:0 .25rem} 90 -</style> 91 -{{/html}}