confluence - 在蓝图开发的模板中添加当前用户和当前日期
问题描述
我完成了 Atlassian https://developer.atlassian.com/server/confluence/tutorials-and-guides/的简单、中级和高级蓝图教程。
目前,我有一个用于蓝图向导页面的 soy 文件和一个 js 文件;一个 Java 文件作为上下文提供者,一个 xml 文件作为模板。
我很容易将当前日期添加到标题中。我还想在发送用户进行编辑之前将当前日期和当前用户(页面创建者)插入页面。(例如;默认会议记录蓝图)。但是我找不到如何在模板中设置这些值。
在 xml 模板中,当前日期应为以下格式:
<time datetime="2021-02-17"/>
所以,我不能为日期时间值添加类似“<at:var>”的东西。所以,我不能从上下文提供者类中改变它。
此外,我尝试通过 Javascript 和 JQuery 设置此值,但是我只能更改有关向导页面的内容。我未能操作实际的模板页面。
页面创建者的问题几乎相同。我应该按以下格式添加用户:
<ri:user ri:userkey="2c9680f7405147ee0140514c26120003"/>
但是,我无法通过 Java 设置用户密钥,也无法获取页面创建者值。
因此;
- 如何将当前日期添加到模板页面?
- 如何将用户提及添加到模板页面?
- 如何获取页面的创建者?
已经感谢您的所有兴趣。
祝你今天过得愉快!
解决方案
The answer is coming from me, too.
In template's xml, we are adding two variables for the date and the user with enabled XHTML support:
<at:var at:name="currentDate" rawxhtml=true />
<at:var at:name="currentUser" rawxhtml=true />
In the context provider class, we will set these variables with html tags:
context.put("currentDate", "<time datetime=\" + sdf.format(new Date()) + "\"/>");
context.put("currentDate", "<ri:user ri:userkey=\" + AuthenticatedUserThreadLocal.get().getKey() + "\"/>");
where the context
is the context map for blueprint and sdf
is the instance of SimpleDateFormat
class with a pre-defined date (not date-time) format.
推荐阅读
- swiftui - 滑动时,SwiftUI onChange() 事件在 TabView 上不起作用
- javascript - 反应来自另一个组件的访问状态
- react-native - yAxis 中的 react-native-charts-wrapper yOffset 不起作用
- firebase - 使用 Jetpack Paging 3 进行 Firestore 分页 - startBefore 未加载正确的页面
- node-red - 节点红色。将多个输入发送到同一个 exec 节点
- c++ - 我需要这个程序首先打印出数量最多的单词数。然后将列表限制为仅插入的前 20 个单词
- javascript - 如何在可滚动的 div 中获取以像素为单位的滚动距离
- android - 我在 Google Play 控制台中使用了错误的包名
- python - 如何仅打印嵌套字典 [Python] 中特定键的值的总和?
- python - 如何阻止 x 轴值重叠