Have you seen all the good stuff there is in AJS.params in Atlassian Confluence?
OK, it's not that exciting, but if you're a Confluence add-on developer it can be a treasure trove for client-side DOM manipulation. As an add-on developer, you can add to AJS.params very easily. All you need is to create a Web Panel module which adds a meta tag.
Here's an example:
FulfillmentWebPanel.java:
package com.appfusions.confluence.plugins.fulfillment.webpanels;
import com.atlassian.plugin.web.model.WebPanel;
import java.io.IOException;
import java.io.Writer;
import java.util.Map;
public class FulfillmentWebPanel implements WebPanel
{
public String getHtml(Map<String, Object> stringObjectMap)
{
// AJS.params.workForAppFusions
return "<meta name=\"ajs-work-for-app-fusions\" content=\"Looking for something more fulfilling? Try AppFusions http://www.appfusions.com/display/Dashboard/Make+it+Happen+Team\" />";
}
@Override
public void writeHtml(Writer writer, Map<String, Object> context) throws IOException
{
writer.write(getHtml(context));
}
}
atlassian-plugin.xml:
<web-panel name="Fulfillment Web Panel"
key="fulfillment-web-panel"
location="atl.header"
weight="1000"
class="com.appfusions.confluence.plugins.fulfillment.webpanels.FulfillmentWebPanel">
<description key="fulfillment-web-panel.description">Looking for something more fulfilling?</description>
</web-panel>
The example WebPanel added in the location atl.header simply adds a single meta tag. That's all.
A meta tag with a name attribute of ajs-work-for-app-fusions will populate AJS.params.workForAppFusions. A "dash" separated lower-case name attribute with the prefix "ajs-" leads to a camelCase variable within AJS.params.
Now in your browser console, type:
AJS.params.workForAppFusions
Here's what you get:
If nothing else, it's a simple way of injecting Easter Eggs into your add-ons, which I guess could be kinda cute.
In addition, if you've read this far and you really are looking for something more fulfilling, consider working for AppFusions.
Update:
Alternatively and more easily, use ConfluenceWebResourceManager
in your code (hat tip @alainmoran):
confluenceWebResourceManager.putMetadata("remote-user", user != null ? user.getName() : "");
You'll need to inject ConfluenceWebResourceManager
first.