Is it possible to manipulate a web resource in runtime?

Svante Gustafsson Björkegren
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.
December 19, 2013

Hi,

I am playing around with a small plugin for an idea I have and am almost there!

Unfortunately I have run into a minor wall at the moment and hope there may be some ideas here to get.

This is my use-case:

I have created a plugin with a configuration UI. In this UI you can set/update a field to a value. This value is persisted in a configuration resource with REST. (all according to the great tutorials available) So far so good.

In the plugin you will be able to change some look and feel elements and I have managed to make that happen also but only in the context of the plugin. I want this configuration change to apply for more contexts.

Before I had created the config UI I just added a web resource (css) that made my change and this resource is possible to define contexts for

<web-resource key="custom-css-override" name="CSS overrides">
   <resource type="download" name="custom-overrides.css" location="css/custom-overrides.css"/>
   <context>atl.general</context>
   <context>atl.admin</context>
</web-resource>

This worked as expected but way too static. I need to be able to change the configuration. I think that maybe it is possible to manipulate the css defined in the web-resource and then get the contexts automatically. Or is there another way to make this css-change to apply to both the atl.general and the atl.admin context.

Looking forward to hear any ideas!

// Svante

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Keiei Tanto _Vivid_ October 4, 2016

Look into the <web-resource-transformer> element of atlassian-plugin.xml; you can use it to specify a class that implements WebResourceTransformer to transform your CSS however you like.

0 votes
Aseem Parikh
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.
December 20, 2013

The JIRA issue collector plugin does something similar to this. Once an issue collector is created, a script tag is generated for users to embed into a page. If the user wishes to modify the collector, they need only update the collector and the JS is updated dynamically to reflect this.

Unfortunately, the issue collector is no longer open source. Rich Manalang's repo is still open on bitbucket, however the code is a little outdated: https://bitbucket.org/rmanalan/jira-issue-collector-plugin

Still, you should be able to learn something useful from this approach.

I don't think this is quite the answer your looking for, but hopefully it'll get you started in the right direction.

TAGS
AUG Leaders

Atlassian Community Events