Page MenuHomec4science

Composing an URL to pre-fill an image.sc forum post
Updated 1,141 Days AgoPublic

Why pre-filing information in a forum post ?

For Fiji or QuPath plugins (as in any documentation), it can be useful to provide an easy way for a user to ask for help in the image.sc forum. It can occur that the user ask for help but forgets to put some basic information in its post.

One way to limit this issue is to compose a URL to the image.sc forum populated with pre-filled information, thus facilitating both the sharing of information as well as its correct tagging in forum categories.

Pre-filling a forum post by providing information in the URL

The default link to the image.sc forum is https://forum.image.sc/.
Adding information in a forum post is done is done by adding elements in the URL after a new-topic? prefix, each element being separated by the character &:

new-topic?title=your title
&body=your body
&category=usage-issues
&tags=fiji, anothertag

New lines characters to fill in the body with a multiline message is done by adding the new line character: %0D%0A; spaces have to be replaced by %20. Other special characters need special encoding, see https://www.w3schools.com/tags/ref_urlencode.ASP.

Composed url example (please don't post!):

https://forum.image.sc/new-topic?title=your%20title&body=your%20body&category=usage-issues&tags=fiji,anothertag

Opening an forum.image.sc URL with a scijava ImageJ/Fiji Command

A source code example of such a command can be found in the ABBA project : https://github.com/BIOP/ijp-imagetoatlas/blob/master/src/main/java/ch/epfl/biop/atlas/aligner/commands/ABBAForumHelpCommand.java

Code broken down:

  • In an ImageJ2 command, one first needs to get a PlatformService using a scijava @Paramater annotation:
@Parameter
PlatformService ps;
  • The url string for the URL can be built and opened like this:
String nl = "%0D%0A"; // new line code in url GET method

// Image Sc URL 
String imageScForumUrl = "https://forum.image.sc/";

// Fill the title
String title = "Help for ABBA in Fiji: [your question here]";

// Fill the body
String body = "[Detail your issue here]"+nl;
body += nl;
body += "---"+nl;
body += nl;
body += "OS and Dependencies Info"+nl;
body +="```"+nl;
body +="OS "+ System.getProperty("os.name")+nl;
body +="ImageJ "+ VersionUtils.getVersion(ImageJ.class)+nl;
body +="IJ "+ VersionUtils.getVersion(IJ.class)+nl;
body +="ABBA "+ VersionUtils.getVersion(ABBALaunch.class)+nl;
... // Add any dependency you would like to get the version to
body +="```"; // End of the post

String fullUrl = imageScForumUrl+"new-topic?"
        +"title="+title+"&"
        +"body="+body+"&"
        +"category=usage-issues&" //
        +"tags=myawesomeplugin,fiji"; // Replace with tags relevant for your use case

ps.open(new URL(fullUrl)); // Actually opens the post in the user's default navigator
NOTE: the System.getProperty("os.name") field which can be used to mention the OS (mac, win, etc.).
NOTE: the way to gather dependencies versions VersionUtils.getVersion(AClassContainedInThePackage.class), accessible if you import org.scijava.util.VersionUtils
NOTE: new lines are ignored by default and should be replaced by "%0D%0A", see nl variable.

Here's how this the ABBA forum post is opened in the navigator when launched by the user:

More information

More information on the discourse forum : https://meta.discourse.org/t/compose-a-new-pre-filled-topic-via-url/28074

Last Author
chiarutt
Last Edited
Mar 11 2021, 13:59

Event Timeline

chiarutt created this document.Mar 11 2021, 12:40
chiarutt edited the content of this document. (Show Details)
chiarutt edited the content of this document. (Show Details)Mar 11 2021, 12:58
chiarutt edited the content of this document. (Show Details)Mar 11 2021, 13:02
chiarutt changed the title from How to set a URL to pre-fill an image.sc forum post to Composing an URL to pre-fill an image.sc forum post.Mar 11 2021, 13:17
chiarutt edited the content of this document. (Show Details)
chiarutt edited the content of this document. (Show Details)
chiarutt edited the content of this document. (Show Details)
chiarutt edited the content of this document. (Show Details)Mar 11 2021, 13:19
chiarutt edited the content of this document. (Show Details)
chiarutt edited the content of this document. (Show Details)Mar 11 2021, 13:23
chiarutt edited the content of this document. (Show Details)
chiarutt edited the content of this document. (Show Details)Mar 11 2021, 13:59