Preview only show first 10 pages with watermark. For full document please download
1. Gadget Developer Documentation
-
Rating
-
Date
November 2018 -
Size
541.6KB -
Views
5,303 -
Categories
Transcript
1. Gadget Developer Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1 Gadget Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.1 Getting Started with Gadget Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.2 Writing an Atlassian Gadget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.2.1 Creating your Gadget XML Specification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.2.1.1 Example of Gadget XML Specification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.2.2 Using Substitution Variables and Directives in your Gadget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.2.3 Allowing Configuration Options in your Gadget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.2.4 Including Features into your Gadget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.2.5 Packaging your Gadget as an Atlassian Plugin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.2.6 Internationalising your Gadget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.2.7 Using Web Resources in your Gadget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.2.8 Using Atlassian REST APIs in your Gadget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.2.9 Providing User Authentication for Gadgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.2.10 Using the Atlassian Gadgets JavaScript Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.2.10.1 Gadget Object API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.2.10.2 Creating a Gadget JavaScript Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.2.10.3 Gadget Developers' JavaScript Cookbook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.2.11 Managing Caching for your Gadget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.3 Gadget Containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.4 Examples of Gadgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.5 Tutorials on Writing a Gadget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.5.1 Tutorial Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.5.1.1 Template for Plugin Gadget Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.5.1.2 Template for Standalone Gadget Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.6 Gadgets and JIRA Portlets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1.7 Gadgets and Dashboards Version Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2 Development Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2.1 Reference Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2.2 Development FAQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2.2.1 Finding Known Issues and Workarounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2.2.2 Developing Standalone or Plugin Gadgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2.2.3 Hints for Developing in iGoogle Sandbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3 Gadgets and Dashboards Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.1 Application Programming Interface or API (Glossary Entry) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.2 Atlassian Gadgets (Glossary Entry) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.3 Atlassian Gadgets Support Level or AGSL (Glossary Entry) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.4 Container (Glossary Entry) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.5 Dashboard (Glossary Entry) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.6 Directive (Glossary Entry) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.7 Directory (Glossary Entry) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.8 Gadget (Glossary Entry) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.9 Gadget Publisher Plugin (Glossary Entry) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.10 Gadget Renderer Plugin (Glossary Entry) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.11 Host Application (Glossary Entry) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.12 OAuth (Glossary Entry) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.13 OpenSocial (Glossary Entry) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.14 OpenSocial Plugin (Glossary Entry) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.15 Plugin Exchange Manager (Glossary Entry) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.16 Plugin Framework 2 (Glossary Entry) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.17 Reference Implementation (Glossary Entry) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.18 REST Plugin Manager (Glossary Entry) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.19 Service Provider Interface or SPI (Glossary Entry) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.20 Shared Access Layer or SAL (Glossary Entry) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.21 Shindig (Glossary Entry) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.22 Trusted Application Authentication (Glossary Entry) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.3.23 Universal Plugin Manager (Glossary Entry) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 3 4 5 5 10 12 13 14 19 21 22 24 24 24 26 30 42 50 50 51 51 51 51 56 58 59 60 60 61 61 62 63 63 65 65 65 65 65 65 65 65 65 66 66 66 66 66 66 66 66 66 67 67 67 67 67 Gadget Developer Documentation Getting Started At heart, Atlassian gadgets are Google gadgets. Atlassian gadgets use the new Google gadgets.* API defined by the OpenSocial specification. In addition, you will probably want to use some of the Atlassian extensions to the gadget specification. You will also want to package your gadget as an Atlassian plugin, along with plugin modules that allow your gadget to interact with the Atlassian applications such as JIRA and Confluence. Read our introduction to gadget development. Then follow a tutorial or jump right into writing a gadget. Main Topics Gadget XML Specification See how to define your gadget via an XML file. Atlassian Gadgets JavaScript Framework Use our JavaScript libraries to create your gadget, extract data from an Atlassian application and display it in the gadget UI. Atlassian Plugin SDK Many gadgets go hand-in-hand with Atlassian plugins. Get started with developing an Atlassian plugin. Atlassian Development Hubs Developer Network Plugin Framework Gadgets REST APIs Confluence JIRA GreenHopper Bamboo Crowd FishEye/Crucible JIRA Mobile Connect Resources The big list of Atlassian gadgets Version matrix of gadgets and applications Javadoc Plugin Exchange Gadget user's and administrator's guide Help Gadget development FAQ Answers from the community Mailing lists at my.atlassian.com Atlassian Partners Feature requests and bug reports Atlassian developer blog Atlassian Developer Blog The road to HAMS 3.0 - Transaction boundaries Make your plugin sizzle with new Plugin Exchange enhancements Testing's In Session AtlasCamp 2011 Let the Developer Party Begin: AtlasCamp 2011 Save the Date JavaScript Cookbook Adding a Chart to the Issue Navigator Adding a Reload Option to your Gadget Adding Something to your Gadget Footer Adjusting the Gadget Height when the Window is Resized Making Ajax Calls Making your Gadget Reload when Resized Restricting Edit Permissions on your Gadget Preferences Showing the Config Screen on Initial Load Only Specifying Required Features for the Framework Specifying Required Resources for the Framework Theming your Gadget Dynamically Using Authentication in your Gadget Using Cookies in your Gadget Using Special UserPrefs for the Framework Gadget Development At heart, Atlassian gadgets are Google gadgets. Atlassian gadgets use the new Google gadgets.* API defined by the OpenSocial specification. In addition, you will probably want to use some of the Atlassian extensions to the gadget specification. You will also want to package your gadget as an Atlassian plugin, along with plugin modules that allow your gadget to interact with the Atlassian applications such as JIRA and Confluence. Gadget Development Table of Contents Getting Started with Gadget Development Writing an Atlassian Gadget Creating your Gadget XML Specification Example of Gadget XML Specification Using Substitution Variables and Directives in your Gadget Allowing Configuration Options in your Gadget Including Features into your Gadget Packaging your Gadget as an Atlassian Plugin Internationalising your Gadget Using Web Resources in your Gadget Using Atlassian REST APIs in your Gadget Providing User Authentication for Gadgets Using the Atlassian Gadgets JavaScript Framework Gadget Object API Creating a Gadget JavaScript Object Field Definitions REST Resource for Validating Gadget Configuration Gadget Developers' JavaScript Cookbook Adding a Chart to the Issue Navigator Adding a Reload Option to your Gadget Adding Something to your Gadget Footer Adjusting the Gadget Height when the Window is Resized Making Ajax Calls Making your Gadget Reload when Resized Restricting Edit Permissions on your Gadget Preferences Showing the Config Screen on Initial Load Only Specifying Required Features for the Framework Specifying Required Resources for the Framework Theming your Gadget Dynamically Using Authentication in your Gadget Copy of Using Authentication in your Gadget Using Cookies in your Gadget Using Special UserPrefs for the Framework Managing Caching for your Gadget Gadget Containers Examples of Gadgets Tutorials on Writing a Gadget Tutorial Templates Template for Plugin Gadget Tutorial Template for Standalone Gadget Tutorial Gadgets and JIRA Portlets Gadgets and Dashboards Version Matrix RELATED TOPICS Reference Documents Gadgets and Dashboards Documentation Getting Started with Gadget Development At heart, Atlassian gadgets are Google gadgets. Atlassian gadgets use the new Google gadgets.* API defined by the OpenSocial specification. In addition, you will probably want to use some of the Atlassian extensions to the gadget specification. You will also want to package your gadget as an Atlassian plugin, along with plugin modules that allow your gadget to interact with the Atlassian applications such as JIRA and Confluence. Introducing Gadgets, Containers, Plugins and Applications A gadget is essentially an XML file containing the gadget specification. You will use recognised XML elements to define the following: 1. 2. 3. 4. 5. Gadget characteristics, such as the author's name (your name), the gadget title and description, preferred sizing, etc. A screenshot and/or thumbnail image that containers can display to show users what your gadget looks like. Required features that containers must provide for your gadget. User preferences, where your gadget can allow its users to customise certain aspects of the gadget display. The content section, where you use define the content that your gadget will display. This is where you add the HTML and JavaScript functions that produce your gadget's output. As the gadget developer, you create the static XML file and make it available on a server. The dashboard or other container will pull the XML file from the server or plugin where it resides, and render it. The container may, for example, display the gadget inside an iframe on a dashboard. Or the container may display the gadget on a web page via a wiki macro. Here is an overview of how gadgets, containers, plugins and applications interact with each other: Google gadgets that support the OpenSocial specification will run on OpenSocial containers. A simple Google gadget will run on an Atlassian container, including the dashboard of any Atlassian application that supports gadgets. In principle, an Atlassian gadget will run on an OpenSocial container. You can customise your Atlassian gadget to interface in funky ways with your Atlassian applications, via the Atlassian Plugin Framework. See Packaging your Gadget as an Atlassian Plugin. Writing a Simple Gadget If you have never written a gadget before, you can start by writing a simple Google gadget: 1. Become familiar with Google gadgets. There are two Google gadget developer guides, one for the earlier 'legacy' version of the Google gadget API and one for the new version which supports OpenSocial. Make sure you use the new guide. 2. Take a look at our hints for developing in iGoogle sandbox, compiled from our own experiences with Google gadgets. 3. Read the guide to getting started with OpenSocial. Writing an Atlassian Gadget Now move on to write an Atlassian Gadget. RELATED TOPICS Gadget Developer Documentation Writing an Atlassian Gadget To write an Atlassian gadget, you can use the Atlassian extensions to the gadget specification: 1. 2. 3. 4. Take a look at our example gadgets. See the Atlassian gadget XML specification Write your gadget, referring to the advanced topics below. Deploy your gadget on a container. More Advanced Topics Creating your Gadget XML Specification Using Substitution Variables and Directives in your Gadget Allowing Configuration Options in your Gadget Including Features into your Gadget Packaging your Gadget as an Atlassian Plugin Internationalising your Gadget Using Web Resources in your Gadget Using Atlassian REST APIs in your Gadget Providing User Authentication for Gadgets Using the Atlassian Gadgets JavaScript Framework Managing Caching for your Gadget RELATED TOPICS Gadget Developer Documentation Creating your Gadget XML Specification This is the reference guide for the XML file you will write to define your Atlassian gadget. On this page: Overview Atlassian Gadgets and Google Gadgets Example of an Atlassian Gadget XML Specification Module Element ModulePrefs Element Require Element Optional Element Param Element Preload Element Icon Element Locale Element Link Element OAuth Element and its Children UserPref Element Enum Element Content Element Overview A gadget is essentially an XML file containing the gadget specification. You will use recognised XML elements to define the following: 1. 2. 3. 4. 5. Gadget characteristics, such as the author's name (your name), the gadget title and description, preferred sizing, etc. A screenshot and/or thumbnail image that containers can display to show users what your gadget looks like. Required features that containers must provide for your gadget. User preferences, where your gadget can allow its users to customise certain aspects of the gadget display. The content section, where you use define the content that your gadget will display. This is where you add the HTML and JavaScript functions that produce your gadget's output. Atlassian Gadgets and Google Gadgets When writing an Atlassian gadget you may use additional XML elements, attributes and features that extend the Google gadgets XML specification. On the page below, we give an overview of elements in the standard Google gadget specification that are supported by Atlassian gadgets. In cases where the Atlassian gadget specification differs from Google, we have added a comment like this: (Comment about the difference in Atlassian gadgets.) Example of an Atlassian Gadget XML Specification Below is a truncated example of a gadget specification. You can also take a look at a longer example of a real gadget. Hello, world
]]> __MSG_gadget.favourite.filters.no.favourites__
"); } else { var list = AJS.$("An example of a custom field
"; } }, ... /* Other fields */ ]
Where: label — The label to display next to the field. description — (Optional.) The description of the field. type — Value must be "custom" for this type of field. template – A function that returns a string to inject into the form. Callback Builder
This is the most powerful and flexible type of field for configuration. The callback enables you to construct any HTML and attach event listeners to it.
fields: [ { id: "my-callback-field", label: gadget.getMsg("gadget.common.builder.label"), description:gadget.getMsg("gadget.common.builder.description"), type: "callbackBuilder", callback: function(parentDiv){ parentDiv.append( AJS.$("").attr({ id: "call-back-hidden-field", type: "hidden", name: userpref }).val(gadget.getPref("myCallback)) ); } }, ... /* Other fields */ ]
Where: id — The id given to the div that is passed into the builder. label — The label to display next to the field. description — (Optional.) The description of the field. type — Value must be "callbackBuilder" for this type of field. callback — A function that takes in a JQuery wrapped div. You can then manipulate the contents of that div and attach event handlers, e.g. click handlers. RELATED TOPICS Using the Atlassian Gadgets JavaScript Framework Writing an Atlassian Gadget Gadget Developer Documentation
REST Resource for Validating Gadget Configuration The REST resource that is used to validate the configuration parameters of a gadget should simply return a 200 OK status if the parameters are valid. If the configuration is not valid, the REST resource should return a 400 Bad Request status with a JSON format body containing error messages. Error messages may either be general (e.g. pointing out an inter-field consistency problem) or specific to the value of a particular field. { "errorMessages": { "start.date.before.end.date", "some.other.error" } "errors": { "field": "bugzillaUrl", "error": "gadget.bugzilla.invalid.url" } }
Here's an example of Java JAXB annotated classes which produce suitable JSON:
@XmlRootElement public class ErrorCollection { /** * Generic error messages */ @XmlElement private Collection