如何在JIRA小工具中使用CSS文件和JavaScript库
今天,我有两个关于开发JIRA小工具的问题: 1。CSS 如何为我的小工具包含.css文件。我有一些桌子,那些应该有一些风格。 .css文件已包含在atlassian-plugin.xml中,如下所示:如何在JIRA小工具中使用CSS文件和JavaScript库,javascript,css,jira,jira-plugin,Javascript,Css,Jira,Jira Plugin,今天,我有两个关于开发JIRA小工具的问题: 1。CSS 如何为我的小工具包含.css文件。我有一些桌子,那些应该有一些风格。 .css文件已包含在atlassian-plugin.xml中,如下所示: <web-resource key="Web-resources" name="My Web Resources"> <dependency>com.atlassian.auiplugin:ajs</dependency> <reso
<web-resource key="Web-resources" name="My Web Resources">
<dependency>com.atlassian.auiplugin:ajs</dependency>
<resource type="download" name="MyCSS.css" location="/css/MyCSS.css"/>
<context>jira.general</context>
<context>The_Context</context>
</web-resource>
- resources/
- gadgets/
- css/
- example.css
- html/
- example.html
- js/
- example.js
- examaple-gadget.xml
- atlassian-plugin.xml
com.atlassian.auiplugin:ajs
吉拉将军
语境
但是我如何在我的小工具中使用这个样式表呢?我需要什么
2。JavaScript库
我还想包括这个库,它也包含在atlassian-plugin.xml中。
但是如何在小工具中使用它呢 在gadget.xml文件中,您必须通过项目键和gadget键包含资源,并且您定义了这些资源。 -在您的案例中,gadget键是“Web资源”(我建议您将其重命名为mygadget资源) -项目密钥在atlassian-plugin.xml文件中定义为元素
在元素内容内CDATA部分的gadget.xml文件中,首先需要资源,然后包括它们:
<Content type="html" view="profile">
<![CDATA[
#requireResource("your-project-key:Web-resources")
#includeResources()
]]>
</Content>
之后,您可以使用MyCss.css中的任何css样式,如果您为JS文件添加另一个资源标记,这也将包括在内
那会让你开始的 对于我的小工具,我将所有XML、HTML、JavaScript和CSS从
atlassian plugin.XML
中分离出来
最初的设置比较复杂,但一旦你做到了这一点,关注点的分离比将所有内容都放入atlassian plugin.xml
文件要好得多
另一方面,相对路径确实看起来很疯狂
我的文件系统如下所示:
<web-resource key="Web-resources" name="My Web Resources">
<dependency>com.atlassian.auiplugin:ajs</dependency>
<resource type="download" name="MyCSS.css" location="/css/MyCSS.css"/>
<context>jira.general</context>
<context>The_Context</context>
</web-resource>
- resources/
- gadgets/
- css/
- example.css
- html/
- example.html
- js/
- example.js
- examaple-gadget.xml
- atlassian-plugin.xml
在/resources/atlassian plugin.xml
中:
<!-- add our web resources -->
<web-resource key="${project.artifactId}-resources" name="${project.artifactId} Web Resources">
<dependency>com.atlassian.auiplugin:ajs</dependency>
<resource type="download" name="example-gadgets/" location="/gadgets"/>
<context>immersive-for-connections</context>
</web-resource>
<gadget name="Example JIRA Gadget" i18n-name-key="example-jira-gadget.name" key="example-jira-gadget" location="gadgets/example-gadget.xml">
<!-- hosted at: /rest/gadgets/1.0/g/${project.groupId}.${project.artifactId}:example-gadgets/gadgets/example-gadget.xml -->
<description key="jira-query-gadget.description">The JIRA Query Gadget Plugin</description>
</gadget>
在/resources/gadgets/html/example.html
(用正确的值替换${project.artifactId}
&${project.groupId}
):
...
...
JIRA开发人员文档说明了什么?非常。。。但我什么都不懂。。。(,等等)我也发现了这一点,但我不理解第一个答案,第二个答案不起作用(?)。