文档更改Home

Yang Sheng 于 2025-02-42,18:57 最后修改

从版本 145.1
Yang Sheng编辑
在2025-02-42,01:18上
修改评论: 该版本没有评论
到版本
Yang Sheng编辑
在2025-02-42,17:49上
修改评论: 该版本没有评论

摘要

细节

页面属性
内容
... ... @@ -15,77 +15,50 @@
15 15  === 近期更新 ===
16 16  
17 17  {{velocity}}
18 -## 定义链接列表
19 -#set($topLevelPages = ["Home", "AI For Service", "AIO知识库", "脚本&自动化"])
18 +## 定义页面显示名称列表
19 +#set($displayTitles = ["Knowledge", "AI", "Automatic"])
20 20  
21 -## 定义需要忽略的页面标题列表
22 -#set($ignoreTitles = ["页面管理", "脚本&自动化"])
21 +#foreach($displayTitle in $displayTitles)
22 + ## 获取页面的实际路径
23 + #set($query = $services.query.hql("select doc.space from XWikiDocument doc where doc.title = :displayTitle or doc.fullName = :displayTitle"))
24 + #set($query = $query.bindValue("displayTitle", $displayTitle))
25 + #set($results = $query.execute())
23 23  
24 -{{html clean="false" wiki="false"}}
25 -<style>
26 - .recent-updates h4 {
27 - margin: -5px 0 !important; /* 强制覆盖其他样式 */
28 - padding: 0 !important;
29 - }
30 - .recent-updates h2 {
31 - margin-bottom: 5px !important; /* 减少与下一个元素间的间距 */
32 - }
33 - .recent-updates ul {
34 - margin: 5px 0 !important; /* 控制列表的上下间距 */
35 - padding-left: 20px !important; /* 确保列表有适当的缩进 */
36 - }
37 - .recent-updates ul li {
38 - margin: 3px 0 !important; /* 控制列表项的上下间距 */
39 - }
40 -</style>
41 -<div class="recent-updates">
42 -{{/html}}
27 + ## 如果找到页面路径
28 + #if($results.size() > 0)
29 + #set($actualSpace = $results.get(0))
30 + ==== $displayTitle (实际路径: $actualSpace) ====
43 43  
44 -## 输出结果
45 -#foreach($topPage in $topLevelPages)
46 - ## 查询每个一级链接下所有子页面的最近更新
47 - #set($hqlQuery = "select doc.fullName from XWikiDocument doc where doc.fullName like :spacePattern and doc.fullName not like '%:WebPreferences' and doc.fullName not like '%:WebHome' and doc.fullName not like '%:WebSearch' and doc.fullName not like '%:WebRss' and doc.fullName not like '%:WebStatistics' order by doc.date desc")
48 - #set($query = $services.query.hql($hqlQuery))
49 - #set($query = $query.bindValue("spacePattern", "${topPage}.%"))
50 - #set($query = $query.setLimit(3))
51 - #set($recentDocs = $query.execute())
32 + ## 查询实际路径下的子页面
33 + #set($hqlQuery = "select doc.fullName from XWikiDocument doc where doc.fullName like :spacePattern and doc.name != 'WebPreferences' order by doc.date desc")
34 + #set($query = $services.query.hql($hqlQuery))
35 + #set($query = $query.bindValue("spacePattern", "${actualSpace}.%"))
36 + #set($query = $query.setLimit(10))
37 + #set($recentDocs = $query.execute())
52 52  
53 - #set($hasUpdates = false)
54 - #foreach($docFullName in $recentDocs)
55 - #set($document = $xwiki.getDocument($docFullName))
56 - #if($document)
57 - #set($docTitle = $document.getDisplayTitle())
58 - ## 仅当用户有查看权限时显示
59 - #if($xwiki.hasAccessLevel('view', $xcontext.user, $document.getFullName()))
60 - ## 检查页面标题是否在忽略列表中
61 - #if(!$ignoreTitles.contains($docTitle))
62 - #if($docTitle == '')
63 - #set($docTitle = "Untitled Document")
64 - #end
65 - #if(!$hasUpdates)
66 - {{html clean="false" wiki="false"}}
67 - <h4>$topPage</h4>
68 - <ul>
69 - {{/html}}
70 - #set($hasUpdates = true)
71 - #end
72 - {{html clean="false" wiki="false"}}
73 - <li><a href="${document.getExternalURL('view')}" target="_blank">${docTitle}</a></li>
74 - {{/html}}
75 - #end
76 - #end
39 + ## 输出调试信息
40 + 查询语句: $hqlQuery
41 + 绑定值: ${actualSpace}.%
42 + 找到 $recentDocs.size() 个子页面。
43 +
44 + ## 遍历子页面
45 + #foreach($docFullName in $recentDocs)
46 + #set($document = $xwiki.getDocument($docFullName))
47 + * [[${document.getDisplayTitle()}>>${document.getExternalURL('view')}]]
77 77   #end
49 +
50 + ## 如果没有找到子页面
51 + #if($recentDocs.size() == 0)
52 + 没有找到更新的页面或没有权限查看这些页面。
53 + #end
54 + #else
55 + ==== $displayTitle ====
56 + 未找到与显示名称匹配的页面路径。
78 78   #end
79 - #if($hasUpdates)
80 - {{html clean="false" wiki="false"}}
81 - </ul>
82 - {{/html}}
83 - #end
84 84  #end
59 +{{/velocity}}
85 85  
86 -{{html clean="false" wiki="false"}}
87 -</div>
88 -{{/html}}
89 89  
90 -{{/velocity}}
62 +
63 +
91 91  )))