Confluence wiki 有一个很好的方法来存储附件,可以将数百个文件上传到一个页面。每个页面就像一个文件夹,页面内容和附件位于文件夹中。可以通过转到"工具>附件"并选择要下载的文件来下载附件。为了使事情变得更容易,有一个选项可以全部下载。这会压缩所有文件并将其发送给将其视为具有随机名称的.zip的用户。
用户在工作时间内下载的包含大量附件的页面存在问题,导致服务器上负载过重。需要一种在工作时间禁用下载功能或禁用在工作时间创建大型zip文件的方法。
编辑confluence/confluence/pages/viewattachments.vm
并更改显示"全部下载"链接的逻辑,使其仅在营业时间之外显示。
要添加的代码:
## Only display Download All link during business hours ##
#set ($tdate = $action.dateFormatter.getCurrentDateTime() ) ## Get todays date
#set ($thour = $tdate.replaceAll(".* ([0-9]+):..", "$1") ) ## Extract the current hour value from the datetime string
#if (!$thour.matches("8|9|10|11|12|13|14"))
#if ($action.latestVersionsOfAttachments.size() > 1)
<a id="download-all-link" href="$req.contextPath/pages/downloadallattachments.action?pageId=$pageId" title="$action.getText('download.all.desc')">$action.getText('download.all')</a>
#end
#else
Download all attachments option only available outside of business hours.
#end ## $thour.matched end
这是要更改的代码块:
#if ($latestVersionsOfAttachments.size() > 0)
#set ($contextPath = "$req.contextPath/pages/viewpageattachments.action?pageId=$pageId&sortBy=$sortBy&")
#set ($sortPathPrefixHtml = "?pageId=$page.id&sortBy=")
#set ($showActions = "true")
#set ($old = "true")
#set ($attachmentHelper = $action)
#parse("/pages/includes/attachments-table.vm")
#if ($action.latestVersionsOfAttachments.size() > 1)
<a id="download-all-link" href="$req.contextPath/pages/downloadallattachments.action?pageId=$pageId" title="$action.getText('download.all.desc')">$action.getText('download.all')</a>
#end
#pagination($action.paginationSupport $contextPath)
#else
$action.getText('currently.no.attachments')
#end
以下是更改,以便"全部下载"链接仅在工作时间之外显示:
#if ($latestVersionsOfAttachments.size() > 0)
#set ($contextPath = "$req.contextPath/pages/viewpageattachments.action?pageId=$pageId&sortBy=$sortBy&")
#set ($sortPathPrefixHtml = "?pageId=$page.id&sortBy=")
#set ($showActions = "true")
#set ($old = "true")
#set ($attachmentHelper = $action)
#parse("/pages/includes/attachments-table.vm")
## Only display Download All link during business hours ##
#set ($tdate = $action.dateFormatter.getCurrentDateTime() ) ## Get todays date
#set ($thour = $tdate.replaceAll(".* ([0-9]+):..", "$1") ) ## Extract the current hour value from the datetime string
#if (!$thour.matches("8|9|10|11|12|13|14"))
#if ($action.latestVersionsOfAttachments.size() > 1)
<a id="download-all-link" href="$req.contextPath/pages/downloadallattachments.action?pageId=$pageId" title="$action.getText('download.all.desc')">$action.getText('download.all')</a>
#end
#else
Download all attachments option only available outside of business hours.
#end ## $thour.matched end