Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How do you add JavaScript resources to the JIRA login page?

David at David Simpson Apps
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
November 24, 2011

JIRA's Web Resource Plugin Module documentation suggests that using the jira.general context "Applies to every page in JIRA"

But this doesn't work for the login page http://localhost:2990/jira/login.jsp

Ideas?

8 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

5 votes
Answer accepted
Dennis Kromhout van der Meer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 23, 2012

Hello gents, I've tested this by creating two plugins; one for JIRA 4 and one for JIRA 5. In JIRA 4 it works, but in JIRA 5 it does not, sorry about that. Right now there is no solution to include your web-resource on the login.jps page. I used the following to test:

atlassian-plugin.xml

<?xml version="1.0" encoding="UTF-8"?>

<atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2">
  <plugin-info>
    <description>${project.description}</description>
    <version>${project.version}</version>
    <vendor name="${project.organization.name}" url="${project.organization.url}"/>
  </plugin-info>
  <web-resource name="My Web Resource" i18n-name-key="my-web-resource.name" key="my-web-resource">
    <description key="my-web-resource.description">The My Web Resource Plugin</description>
    <resource name="test.js" type="download" location="/templates/test.js"/>
    <context>atl.general</context>
  </web-resource>
  <resource type="i18n" name="i18n" location="atlassian-plugin"/>
</atlassian-plugin>

/templates/test.js:

alert("hey jira!");

There has been a lot of work done between JIRA 4 and JIRA 5 with the decorators, so this bug probably just sneaked in there. Therefore I raised a bug ticket here: JRA-27960

I recommend to vote on this ticket and watch it to get updates on the progress.

David at David Simpson Apps
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
April 25, 2012

I think you're right. It's a bug. I've only tried with JIRA 5. If what you've discovered is correct, it'll be worth updating the JIRA Web Resource Plugin Module documentation too.

I'm still going to hang back and wait a couple of days in case anyone has a better suggestion :)

Dennis Kromhout van der Meer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 25, 2012

I found out how you can probably fix this for now. You need to add the following to your login.jsp, above any of the html document:

<%@ page import="com.atlassian.plugin.webresource.WebResourceManager" %>
<%
    WebResourceManager webResourceManager = ComponentManager.getComponent(WebResourceManager.class);
    webResourceManager.requireResourcesForContext("atl.general");
    webResourceManager.requireResourcesForContext("jira.general");
%>

Dennis Kromhout van der Meer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 8, 2012

Hi David, is there anything else you need for this question?

David at David Simpson Apps
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
May 15, 2012
Yes. It would be really cool if that bug was fixed ;) In the meantime, I suppose I might mark your answer as correct.
3 votes
Radu Dumitriu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 23, 2012

The dirty hack, which has the advantage to work for creating new pages as well:

1) Place your modified login.jsp as a resource in the plugin

2) On the plugin boot (osgi starup hook), check if the login is the one you have packed in your plugin; if not, copy the login.jsp over it (rename it prior to that)

3) Ha ha !

Radu Dumitriu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 23, 2012

of course, a more nice stuff would be to patch the existing, but you will have to define insertion points ... anyway, that's the general idea.

David at David Simpson Apps
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
April 25, 2012

Nice plan, but <sob>I just want it to work properly</sob>

2 votes
RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 18, 2012
David at David Simpson Apps
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
April 18, 2012

Sure. Thanks. The gadget is not really an issue, but the login page is completely separate.

I'm talking about this page: https://jira.atlassian.com/login.jsp

Mizan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 23, 2012

I guess javascript is restricted on login.jsp , its a guess :)

you can even have a look at atlassian-jira/includes/loginform.jsp for a better idea

1 vote
David at David Simpson Apps
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
May 23, 2012

@Matt Doar suggests using a jira-footer module - it's seemingly an undocumented module type, but example syntax is available in system-footer-plugin.xml:

&lt;atlassian-plugin name='JIRA Footer' key='jira.footer' i18n-name-key="footer.plugin.name"&gt;
    &lt;plugin-info&gt;
        &lt;description key="footer.plugin.desc"&gt;This plugin renders the content of the footer in JIRA.&lt;/description&gt;
        &lt;vendor name="Atlassian" url="http://www.atlassian.com"/&gt;
        &lt;application-version min="3.12" max="4.3"/&gt;
        &lt;version&gt;1.0&lt;/version&gt;
    &lt;/plugin-info&gt;

    &lt;jira-footer key="standard-footer" i18n-name-key="footer.plugin.standard.name" name="Standard Footer"
            class="com.atlassian.jira.plugin.navigation.DefaultPluggableFooter"&gt;
        &lt;resource type="velocity" name="view" location="templates/plugins/footer/footer.vm"/&gt;
        &lt;order&gt;10&lt;/order&gt;
    &lt;/jira-footer&gt;
&lt;/atlassian-plugin&gt;

...I wonder whether this works with JIRA 5.x

1 vote
Viðar Svansson
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 18, 2012

I think I answered this already but I can't find it.

Last time I checked then there is no context defined on the login page. Not even atl.general/jira.general.

0 votes
RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 23, 2012

if your using jira 5.0 add ur javascrip in

JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {		
ur javascript here.....
}):

and include as webresource.

if ur using old version try with page load or document .ready

David at David Simpson Apps
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
April 23, 2012

But how do you get the web resource to appear on the login page?

0 votes
David at David Simpson Apps
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
April 23, 2012
0 votes
David at David Simpson Apps
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
April 18, 2012

It would be really cool if this was documented somewhere :)

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events