Mailto Link in Confluence User Macro

In response to this tweet:

 

here’s how to create a Confluence User Macro which will create a “mailto” link which dynamically has the page title as the subject of the email and the page title and URL of the page in the body of the email.

1. Log in to Confluence as a Confluence Administrator

2. Select Browse -> Confluence Admin -> User Macros

3. Create a new User Macro:

Create Mailto Macro

Template:

## Macro title: Mail To
## Macro has a body: N
## Body processing: Selected body processing option
## Output: Selected output option
##
## Developed by: Andrew Frayling
## Date created: 26/01/2012
## Installed by: My Name
## Simple Mail to macro which constructs a <a href=mailto:> link
## with the page title as the subject and the page title and URL of
## the page as the body
## @param email:title=Email Address|type=string|required=true
<a href="mailto:$paramemail?subject=Page Title: $renderContext.getPageTitle()&body=This is the page I am mailing you from: $renderContext.getPageTitle() - $action.getGlobalSettings().getBaseUrl()$content.getUrlPath()">Click to Email Me</a>

The variables in the template are:

@param email:title=Email Address|type=string|required=true – prompts the user for an email address that they would like the mailto link to send the email to

$renderContext.getPageTitle() - retrieves the title of the page that the macro is inserted into

$action.getGlobalSettings().getBaseUrl() – retrieves the base URL of the Confluence install

$content.getUrlPath() – retrieves the URL path of the page that the macro is inserted into

Therefore the full URL of the page is $action.getGlobalSettings().getBaseUrl()$content.getUrlPath()

4. Save the user macro

Now when you edit a page you can use the wiki markup:

{mailto:email=joebloggs@example.com}

where joebloggs@example.com is the email address of  where you would like the mailto link to send the email, or select the macro from Insert -> Other Macros

Insert Mailto Macro

Which will give you the following link on a page:

View Page

Clicking the link will result in an email being composed in your default email client:

Compose Email

I did spend some time trying to get the URL in the email to be rendered as a clickable <a href> link, but a URL within a URL didn’t want to play ball.

Highlighting External Links in Confluence with JQuery

I’ve been playing around with JQuery as a bit of a learning exercise and have knocked up a simple script to automatically add an image (External Link) after any links inserted into Confluence that reference external sites to indicate to the user that the link goes to an external site. To add this script to Confluence:

1. Log in to Confluence as a Confluence Administrator

2. Select Browse -> Confluence Admin -> Look and Feel -> Custom HTML

3. Edit the “At the end of the HEAD” section and insert the following Javascript:

<script type="text/javascript">
AJS.toInit(function(){
 AJS.$("a[class='external-link']").after(' <img src="<url of the image you wish to use>" alt="External Link">');
});
</script>

replacing “<url of the image you wish to use>” with a valid image URL, e.g “/download/attachments/1081346/external.png”

4. Click Save

The script simply looks for any <a> tags that have a class of “external-link” (the CSS class that Confluence automatically adds to external links when a user inserts a link in the editor) and appends an image (External Link) after the link.

E.g.

Confluence External Links Screenshot

I did also play with adding a target=”_blank” attribute to make external links open in a browser window:

<script type="text/javascript">
 AJS.toInit(function(){
 AJS.$("a[class='external-link']").attr("target","_blank").after(' <img src="/download/attachments/1081346/external.png" alt="External Link">');
});
</script>

which did work, but I removed .attr(“target”,”_blank”) before I got attacked by the accessibility police :-)

 

Adding IBM Connections Search to Safari

The eagle-eyed among you may have noticed that Safari was missing from my previous post about Adding IBM Connections Search to Your Browser, but Safari users can now join the party thanks to this tweet from David Simpson:

Instructions

1. Download and install Safari OmniBar from http://hackemist.com/SafariOmnibar/
2. Launch Safari, select any text in the address bar and right-click to select Edit OmniBar Search Providers

Edit OmniBar Search Providers

3. Click the (+) button to add a new search provider and enter values for Search Provider, Keyword and URL, e.g.

Search Provider: Greenhouse Connections
Keyword: green
URL: https://greenhouse.lotus.com/search/web/search?personalOnly=false&components=&component=&query={searchTerms}&tag=&nonperson=&person=&fieldvalue=

NB: The value for the query parameter is {searchTerms} as this is the value that Safari OmniBar will substitute for the search term you enter when you use the search.

NB: After you have entered values for Search Provider, Keyword and URL hit <ENTER> before clicking Done as otherwise OmniBar doesn’t save the URL value.

Now if you type green followed by a <SPACE> in your Safari address bar the bar will change to:

Safari Greenhouse Search

and you can type your search term and hit <ENTER> to search Greenhouse Connections content without having to visit Connections first. E.g. green<SPACE>test<ENTER> will search Greenhouse for all Connections content containing the word test.

You can use whatever you want for the Keyword in your Safari OmniBar search preferences and if you have access to more than one Connections implementation you can add as many search engines as you wish, just using a unique Keyword for each implementation and changing the URL to match the relevant implementation, e.g.:

https://my.connections.com/search/web/search?personalOnly=false&components=&component=&query={searchTerms}&tag=&nonperson=&person=&fieldvalue=

 

Lotusphere 2012 Apps

For those of your lucky enough to be heading to Lotusphere 2012 in January you may find it useful to keep track of sessions while you’re on the move by downloading some of the mobile apps that are available.

iPhone

Lotusphere 2012 Session Database – by The Turtle Partnership

iPad

Lotusphere 2012 Session Database – by The Turtle Partnership

Android

Lotusphere 2012 Session Journal – by QKom.net and flexdomino.net

Blackberry

Again from The Turtle Partnership either search for “LSMobile” on the Blackberry App Store or download directly for Bolds & keyboard devices or for Torches & touchscreen devices.

If you find yourself with some free time – which if you do, you’re not doing Lotusphere properly ;-) – you could also check out Mousewait for iPhone and Android for attraction waiting times, restaurants, menus, park guides, etc.

Hope you all have fun at Lotusphere just don’t hog the mic at Kimonos :-)

Adding IBM Connections Search to Your Browser

I’ve been playing around with IBM Connections search recently and discovered that you can add the ability to search for content stored in IBM Connections directly from your browser by using the URL that IBM Connections uses for Advanced Search:

https://<your connections url>/search/web/search?personalOnly=false&components=&component=&query=<your query>&tag=&nonperson=&person=&fieldvalue=

e.g.

https://greenhouse.lotus.com/search/web/search?personalOnly=false&components=&component=&query=test&tag=&nonperson=&person=&fieldvalue=

Instructions for Chrome

1. Select Chrome -> Preferences -> Basic -> Search -> Manage Search Engines
2. Scroll to the bottom of your Other search engines list and enter values for the Description, Keyword and Search URL, e.g.

Description: Greenhouse
Keyword: green
URL: https://greenhouse.lotus.com/search/web/search?personalOnly=false&components=&component=&query=%s&tag=&nonperson=&person=&fieldvalue=

NB: the value for the query parameter is %s as this is the value that Chrome will substitue for the search term you enter when you use the search.

Now if you type green followed by a <SPACE> in your Chrome address bar the bar will change to:

Greenhouse Search

and you can type your search term and hit <ENTER> to search Greenhouse Connections content without having to visit Connections first. E.g. green<SPACE>test<ENTER> will search Greenhouse for all Connections content containing the word test.

You can use whatever you want for the Keyword in your Chrome search preferences and if you have access to more than one Connections implementation you can add as many search engines as you wish, just using a unique Keyword for each implementation and changing the URL to match the relevant implementation, e.g.:

https://my.connections.com/search/web/search?personalOnly=false&components=&component=&query=%s&tag=&nonperson=&person=&fieldvalue=

Instructions for Firefox

In theory you should be able just log in to Connections and right-click in the Connections search box to select “Add a Keyword for this Search” and/or “Add to Search Bar”, but while these do add options for searching Connections to Firefox, for some reason the searches never return any results. Fortunately adding these options in manually does work and here’s how to add them:

Adding Connections to the Firefox Search Box

The most reliable way I found of adding Connections search to the Firefox search box and have it return results was to create an OpenSearch description file and install this in Firefox’s searchplugins folder. An OpenSearch description file is an XML file that is used to describe a search engine so that it can be used by client search applications and an example of a description file for searching IBM Connections on Greenhouse is given below:

<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>Connections Search</ShortName>
<Description>Greenhouse IBM Connections Search</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16" type="image/png">data:image/png;base64,imageData...</Image>
<Url type="text/html" method="post" template="https://greenhouse.lotus.com/search/web/search">
<Param name="personalOnly" value="false"/>
<Param name="components" value=""/>
<Param name="component" value=""/>
<Param name="tag" value=""/>
<Param name="nonperson" value=""/>
<Param name="person" value=""/>
<Param name="fieldvalue" value=""/>
<Param name="query" value="{searchTerms}"/>
<Param name="ei" value="UTF-8"/>
</Url>
<moz:SearchForm>https://greenhouse.lotus.com/search/web/search</moz:SearchForm>
</OpenSearchDescription>

To adapt the description file for your Connections implementation just change the values in bold to the relevant values for your implementation and save the file with a meaningful filename (e.g. connections-search.xml) in your <Firefox Installation Directory>/searchplugins/ folder. Examples of default installation directories on various operating systems can be found at http://kb.mozillazine.org/Installation_directory

A complete OpenSearch description file for searching IBM Connections on Greenhouse, including base64 data for a thumbnail image, can be downloaded here. Save the connections-search.xml file to your <Firefox Installation Directory>/searchplugins/ folder and restart Firefox.

After installing the OpenSearch descriptor file into your copy of Firefox you should now have an option for searching Connections from your Firefox search box:

Firefox Connections Search

You can also make OpenSearch descriptor files available for users to easily add to their Firefox browsers by uploading the XML to the web and adding an embedded link to the <head> of your web page:

<link rel="search" type="application/opensearchdescription+xml" title="<searchTitle>" href="http://www.example.com/Provider.xml">

 Adding Connections Search as a Keyword

This used to be easier to add in earlier versions of Firefox when you were given an option to provide a Keyword when you bookmarked a page, but that option seems to have disappeared in favour of adding tags to your bookmarks. You can still add Keywords to use as search shortcuts, but it now takes a few extra steps:

1. Copy the following URL into your Firefox address bar, substituting greenhouse.lotus.com for the Connections implementation you wish to add as a search:

https://greenhouse.lotus.com/search/web/search?personalOnly=false&components=&component=&query=test&tag=&nonperson=&person=&fieldvalue=

2.  Select Bookmarks -> Bookmark This Page and give it a meaningful name, e.g. Greenhouse Connections Search
3. Select Bookmarks -> Show All Bookmarks -> Recently Bookmarked and select the bookmark you just added
4. Edit the URL and replace “query=test” with “query=%s”, e.g.

https://greenhouse.lotus.com/search/web/search?personalOnly=false&components=&component=&query=%s&tag=&nonperson=&person=&fieldvalue=

5. If the Keyword field is not shown click the Down button to the bottom left of the Tags field to display the Keyworld field
6.  Enter a relevant Keyword that you wish to use as a shortcut for this search, e.g. green

Greenhouse Firefox Search

Now you should be able to enter your Keyword followed by a <SPACE> and your search term directly in the Firefox address bar, e.g. green<SPACE>test<ENTER>:

Greenhouse Address Bar Search

Instructions for Internet Explorer

Internet Explorer also uses OpenSearch to add search engines to its search providers, but it’s a little bit fussier than Firefox about the format of the file you provide. An example of an OpenSearch descriptor file for Connections on Greenhouse is:

<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>Connections Search</ShortName>
<Description>Greenhouse IBM Connections Search</Description>
<Url type="text/html" template="https://greenhouse.lotus.com/search/web/search?personalOnly=false&amp;components=&amp;component=&amp;query={searchTerms}&amp;tag=&amp;nonperson=&amp;person=&amp;fieldvalue=" />
</OpenSearchDescription>

Note that you provide all of the URL parameters directly in the <Url> element rather than providing separate <Param> elements and because all of the parameters are now provided in the <Url> element they need to be escaped with &amp; Internet Explorer also does not like the method=”post” attribute as part of the <Url> parameter, but it works without this attribute. Again you substitute the values in bold for the values that are relevant for the Connections implementation that you wish to add as a provider.

Once you have created your OpenSearch descriptor file (an example is available for you to download here) you can make it available for users to install by uploading your XML file to the web and either:

Creating a button

<INPUT TYPE="button" VALUE="Add Greenhouse Connections Search Provider" onClick='window.external.AddSearchProvider("http://www.example.com/Provider.xml");'>

Clicking the button below in Internet Explorer will add a search provider using the OpenSearch descriptor file available at http://www.networkedcollaboration.com/connections-search-ie.xml

 

or

Adding an embedded link element within the <head> of a web page

<link title="My Provider Name" rel="search" type="application/opensearchdescription+xml" title="<searchTitle>" href="http://www.example.com/provider.xml">

After installing the search provider into Internet Explorer you should now have an option to search Connections from IE’s search bar:

IE Search

Providing ways for users to add Connections search to their browsers should make it easier for people to search and engage with content that is stored in your Connections implementations so I hope you find this useful. If you have any other tips or shortcuts for adding search to different browsers please feel free to drop me a line via the comments.

Related links: