| Name | Include Random Macro |
|---|---|
| Vendor | Macadamian Technologies (Website) |
| Authors | Sebastian Jagodzinski, Mark Michaelis |
| Homepage | http://confluence.atlassian.com/display/CONFEXT/Include+Random+Macro |
| Issue Management | http://developer.atlassian.com/jira/browse/RNDM |
| Continuous Integration | n/a |
| Categories | Content Macros |
| Most Recent Version | 2.1.2 |
| Availability | Confluence v2.0 to v2.10 |
| State | Stable |
| Support |
|
| License | Freeware / Open Source (BSD) |
| Price | Free |
| Release Docs | http://confluence.atlassian.com/display/CONFEXT/Include+Random+Macro |
| Java API Docs | n/a |
| Download Source | https://svn.atlassian.com/svn/public/contrib/confluence/include-random-plugin/tags/v2.1.2 |
| Download JAR | include-random-plugin-2.1.2.jar |
Overview
| This plugin is accessible through the Confluence Repository Client. |
Description
The include-random macro allows Confluence users to include an excerpt (see the excerpt macro) from a random child page. The child pages should have a block of text marked by {excerpt} tags. These excerpts may be hidden, if you wish. If the macro gets a page without an excerpt on it, the macro tries up to 10 more times to find a page with an excerpt.
This can be used for random quotes, tip of the day, things like that.
Plugin Versions
| Version | Date | State | License | Price |
|
|
12 Apr 2006 | Stable | Freeware / Open Source (BSD) | Free |
|
|
05 Apr 2006 | Stable | Freeware / Open Source (BSD) | Free |
|
|
15 Aug 2005 | Stable | Freeware / Open Source (BSD) | Free |
Features
To make this macro, I combined elements of the {children} macro with the {include-excerpt} macro. These are also described in the notation guide. Except in 1.3.5, the {children} macro did not support going across spaces, but this macro does (yes, it does check permissions).
If no parent page is specified and no arguments are used, ie. just {include-random}, then it searches below the current page.
Note: If you use any arguments in the macro, then you must specify the parent page when using the macro (even if it is the current page).
- space: The space parameter can be used if the parent page is in another space by specifying a space Key. When going across spaces, a user may not have permissions to view that space, in which case the user gets an error that the space does not exist.
- nopanel: If the value "nopanel" is present, or nopanel=true, then the excerpt will be drawn without its surrounding panel.
- link: If the value "link" is present, or link=true, the macro will include a 'more info' link to the page where the excerpt was retrieved from. This is useful because you can include more information on the page itself.
- path: If the value "path" is present, or path=true, the macro will include the hierarchy to the page where the excerpt was retrieved from. For example: Macadamian Space > Macros Page > ParentPage, where the excerpt is taken from a child of ParentPage. The path is a prefix for the 'more info' link, if both are included.
- all: Include the value "all", or all=true, to choose from all descendants of this page.
- depth: Use parameter depth=x (where x is any number > 0) to search that many levels of descendants. The default depth is 1.
Notation Examples
For nopanel, all and link parameters you can just include the values, instead of nopanel=true, I like this better. (It works both ways).
{include-random}
{include-random:Parent Page}
{include-random:Home|space=KEY}
{include-random:Home|nopanel}
{include-random:Home|link}
{include-random:Home|path}
{include-random:Home|all=true}
{include-random:Home|depth=2}
"Screenshots"
{include-random}
"This is the excerpt from one of the child pages." - Mr. Quoted
{include-random:Home|link|path|nopanel}
No panel this time, but there is a link & path. The excerpt did not have quotation marks this time.
Page Specified in Macro > Parent > more info
Known Bugs
255 Character Limit
There was a 255 character limit imposed on the {include-excerpt} macro macro that affects this macro as well.
Downloading & Installing
Confluence 1.3
- Download macros-include-random-1.3.jar
- Drop into the 'WEB-INF/lib' directory of your Confluence installation.
- Restart Confluence.
Source Code: include-random-src-1.3.zip
Confluence 1.4, 1.5, 2.0, 2.1
- Download macros-include-random-1.4.jar
- Upload using the Plugin Administration section.
Source Code: include-random-src-1.4.zip
Release Notes
Version 2.1.2
New Features
- RNDM-1 – Make panel configurable
You can now add options to the panel around the included content. All arguments prefixed with panel will be handed to the panel as argument. Thus panelTitle=MyTitle will set the title of the panel to MyTitle (and overrides the default which is to add the title of the included page) - RNDM-2 – Make panel type configurable
You may now also use info, warning and even your User Macros to embed the included content. New argument is macro. In addition (and required for this change) you may change the argument name to use as title argument with title-argument and you may even switch off the (default) title: notitle. See Notation Guide for more information.


Comments (20)
Aug 11, 2005
Guy Fraser says:
Sounds like an awesome macro, but I'm all confused now as the 1.4 download links...Sounds like an awesome macro, but I'm all confused now as the 1.4 download links seem to be removed / broken?
Aug 15, 2005
Sebastian Jagodzinski says:
Hi Guy, I have now implemented the changes required to render the macro properly...Hi Guy,
I have now implemented the changes required to render the macro properly in 1.4.
Enjoy!
Sep 19, 2005
Tom Davies says:
This macro will need to be modified for 1.5 as it implements the Macro interface...This macro will need to be modified for 1.5 as it implements the Macro interface, which has changed. It's safer to extend BaseMacro.
Sep 29, 2005
Mark Michaelis says:
There is a bug if you have arguments but want to use the current page as parent ...There is a bug if you have arguments but want to use the current page as parent page:
{info:title=Tip Of The Day} {include-random:nopanel=true|link=true|all=true} {info}This will try to get the children of the page '' (i. e. empty string) instead of using the current page. Of course the workaround is to name the current page as first argument.
Oct 05, 2005
Sebastian Jagodzinski says:
Yes, you're right. If there are any arguments, then you must specify the page na...Yes, you're right. If there are any arguments, then you must specify the page name first (even if it's the current page). eg:
It only takes from the current page by default if you do not specify arguments. ie: {include-random}
Thanks, that should have been made clear.
Oct 05, 2005
Sebastian Jagodzinski says:
I will not be working on this macro anymore. If anyone wants to fix bugs or upd...I will not be working on this macro anymore.
If anyone wants to fix bugs or update this macro to make sure it works in confluence 1.5 (having it extend BaseMacro, as mentioned) then the source code is available! (see attachments)
Feel free to create new versions and add them to this page.
Mar 24, 2006
Mark Michaelis says:
It's sad that you won't work on this macro any longer I liked it but it does no...It's sad that you won't work on this macro any longer
I liked it but it does not work for me anymore in Confluence 2.1. When using the space-argument you will get:
Anyone who would like to fix this? Would be great.
Mar 27, 2006
Mark Michaelis says:
Ok, as I like this macro very much (I use it as Tip of The Day Macro on the Dash...Ok, as I like this macro very much (I use it as Tip of The Day Macro on the Dashboard to introduce new users to Confluence) I hacked a little bit on the weekend and finally got:
It's not been tested carefully. It just is tested to prevent the problem mentioned above. The only change to the sources where to implement the Wysiwig methods. So nothing dramatically changed.
Regards,
Mark
Mar 27, 2006
Bob Swift says:
Mark, thanks for doing this. I was also going to try doing a "tip of the day" t...Mark, thanks for doing this. I was also going to try doing a "tip of the day" thing but never got to it. Any chance you can export your tips pages and attach here?
Mar 28, 2006
Mark Michaelis says:
There is a chance... but I don't think they are of general interest. I collect u...There is a chance... but I don't think they are of general interest. I collect usage problems and place the answers (if I think they are of general interest) into the "Tips of the Day". Currently it mainly faces User Macros I wrote. E. g. I have one Tip of the Day where I announce new User Macros. Another TOD points to a Test Space which might be used by new users or a link to a page "First Steps" which describes in short the first navigation and editing tasks a new user might stumble upon. Even this page is focused on our internal needs and only parts of them will be of general interest.
It might be also interesting to know that from my experience most users simply don't notice the "Notation Guide" to the right while editing. That's way another TOD explicitly mentions this and thanks to the Linking Macros it also offers a direct link to the notation guide.
But thanks for the idea. Perhaps, if the database of TODs grows bigger I will add some common TODs here.
Apr 03, 2006
Mark Michaelis says:
Hello, if noone else likes to take the job, I'll do it. I am currently converti...Hello,
if noone else likes to take the job, I'll do it. I am currently converting the macro to use e. g. BaseMacro as proposed by Tom Davies and add some other things.
Regards
Apr 03, 2006
Jonathan Nolen says:
That would be terrific, Mark. If you need any help, let me know. And if you wou...That would be terrific, Mark. If you need any help, let me know. And if you would like to host this in our Subversion repository, I can set that up for you.
Cheers,
Jonathan
Apr 04, 2006
Mark Michaelis says:
Thanks for your offer, Jonathan. Indeed a subversion repository would be great. ...Thanks for your offer, Jonathan. Indeed a subversion repository would be great. And help is always welcome, as this is the first plugin I am working on.
Kind Regards,
Mark
Apr 05, 2006
Jonathan Nolen says:
You're all set. Check your email for details. Thanks again, JonathanYou're all set. Check your email for details.
Thanks again,
Jonathan
Apr 05, 2006
Mark Michaelis says:
For the impatient (like me): I just finished the first version of the Include Ra...For the impatient (like me): I just finished the first version of the Include Random Macro based on the BaseMacro. I completely refactored the whole thing but in addition I wrote some JUnit tests so hopefully everything is fine (although not every part of the macro is tested yet). I still need to learn how to add sources to subversion and to the repository plugin but it will follow soon as well as an update for this page.
Download: macros-include-random-2.1.jar
Here is a short overview of what has visibly changed:
Oct 10, 2007
Andy Jones says:
Hi Has the behaviour of this macro changed recently? Specifically, it seems th...Hi
Has the behaviour of this macro changed recently?
Specifically, it seems that hyperlinks are being stripped from the the text which is randomly included.
To explain, we have a page (named QandA) which has a half a dozen child pages.
Each child page has the basic format
{excerpt:hidden=true} [Name of the current page] {excerpt}
A whole bunch of text which is shown when this page is visited....
NB: the square brackets to make a link to the current page.
On our main pages, we use the code:
{include-random:QandA|space=spacename|nopanel|link=false}
So, the include-random macro picks a random child page, and shows the text within that page's {excerpt} macro.
Since this text also contains a hyperlink, if the user clicks on it, they go to the randomly picked child page.
I could be wrong, but I thought that that this used to work, and now it doesn't. We recently upgraded from 2.5.2 to 2.5.7, but I can't say for certain when I thought it definitely worked.
Currently, the random text is showing, but the hyperlink on it seems to be being stripped.
So it no longer works as a randomised teaser to a page.
cheers
Andy
Oct 10, 2007
David Peterson [CustomWare] says:
Actually, it's the behaviour of the {excerpt} macro who's behaviour has changed....Actually, it's the behaviour of the {excerpt} macro who's behaviour has changed. In 2.6 (and possibly even 2.5.6) it stopped allowing links and other wiki markup to be rendered inside the {excerpt} macro. Not only that, there seems to be an upgrade process which actually escapes any wiki markup already stored in the database for the excerpt, although that may simply be a side-effect of the indexing process.
Oct 14, 2007
Andy Jones says:
Hi David Thanks for the reply. There seem to be some bugs lodged against this n...Hi David
Thanks for the reply. There seem to be some bugs lodged against this new behaviour, so I've added my 2c worth.
Hopefully the fix will not be to update the doco to say that it strips tags, but rather, to revert to the "non-stripping" behaviour, or at least make it configurable via an optional parameter.
cheers
andy
Oct 11, 2007
Hank Szeto says:
In Confluence 2.5.7, it appears that excerpts that surround images do not work p...In Confluence 2.5.7, it appears that excerpts that surround images do not work properly, resulting in an error message in the random macro. This is what has been working prior to the upgrade to 2.5.7:
{excerpt}[!download:Images^someimage.jpg!|A Page Name]{excerpt}Now, this is the error that we get:
"include-random: Unable to find valid child page of page info:bottom left banner (no children, access denied or (if specified as content to render) excerpt missing.)."Is this related to the links and Wiki markup problem described above? When the image is removed and plain text is used, there is no error message. Also, when the link on the image is removed, it still gives an error.
Is there another way to randomly retrieve and display a linked image?
Thanks, Hank.
Oct 19, 2007
Martin Blazek says:
Great macro. We use it to rotate user quotes - works really well. There are som...Great macro. We use it to rotate user quotes - works really well.
There are some downsides however so I thought I'd mention it here:
It would be great if a future version allow all that.
Thanks for developing it!