LinkIndexPlugin provides an index of inbound or outbound links for one, several, or all pages on the wiki. On outbound links this will also highlight any broken links (i.e., links to nonexistent wiki pages).
Parameters#
- dir='in|out'
- The direction of the link index, inbound ("in") or outbound ("out"). The default is "out".
- dirstring='text string'
- For displaying the link direction (like "<<< " for dir="in"). Default is "". Any markup characters are escaped.
- nolinktext='text'
- When a page has no links, this is the descriptive text. The default is "no links". Any markup characters are escaped. [1]
- page='pagename'
- When this parameter is absent, a link index of all wiki pages is returned. If a page parameter is supplied, only the links of that page are returned. More than one page can be specified when separated by whitespace. There is no default.
Examples#
Some valid examples:
[{LinkIndexPlugin}] [{LinkIndexPlugin page='Main' dir='in'}] [{LinkIndexPlugin page='Main About OneMinuteWiki' nolinktext='OMIT'}] [{LinkIndexPlugin page='Main' nolinktext='this page has no links'}]
The output will be a definition list having a class attribute value of 'linkindex', with a term and definition pair per wiki page. The term will contain the wiki page name as a link to the page, with the definition containing the list of links, with links to nonexistent pages in bold.
A typical output (as from the third line in the above example):
- Main
- About, SandBox, Project Tattooine, WikiEtiquette, TextFormattingRules, JSPWikiTips, JSPWikiFAQ, System
- Project Tattooine
- ThisPageDoesNotExist, TextFormattingRules
Installation#
This plugin is currently targeted as part of the JSPWiki core plugins, hence the Java file LinkIndexPlugin.java should be placed in src/com/ecyrd/jspwiki/plugin/ directory, and then the JSPWiki.jar is built and installed as normal.
Two minor modifications to com.ecyrd.jspwiki.WikiEngine are required: the getRefersTo() and getReferredBy() methods in WikiEngine are both currently protected; these must both be made public so that the plugin can get access to these two Maps.
You may want to additionally add something akin to the following to your jspwiki.css stylesheet:
dl.linkindex { margin-left: 2em; } dl.linkindex dt { font-size: 120%; } dl.linkindex dd b { color: #800000; } .pluginerror { color: red; }
Notes#
[#1] If the nolinktext parameter contains the special value "OMIT" (case insensitive), pages that have no links will be omitted from the index.
This plugin was developed and tested against JSPWiki 2.2.28.
Future Possibilities#
It might be nice to have a feature that only lists broken links. It wouldn't be that hard to add, and was (in actuality) the reason this plugin was first developed. It just grew into a full link index plugin because that was just as easy...
Comments#
Please let me know if there are any bugs with this. -- MurrayAltheim
getRefersTo() and getReferredBy() are in com.ecyrd.jspwiki.ReferenceManager (and not in WikiEngine).
--Frank_Fischer, 2005-08-25
Here is an updated version: LinkIndexPlugin.java-[Frank_Fischer-2005-08-27]#
Changes:#
- all listed pages are links
(dl.linkindex dd b is no longer used; broken links are covered with A.editpage) - added new parameter: view="all|broken"
Lists all or only the broken links. Default is "all". - the listed pages are sorted and multiple occurrences are marked with a number (only when dir="out"):
JanneJalkanen(4) means four links to JanneJalkanen - fixed java.lang.NullPointerException on rare occassions:
col in Collection col = (Collection)map.get(key); was not always != null
--Frank_Fischer, 2005-08-27
Another update: LinkIndexPlugin.java-[Frank_Fischer-2005-08-28]
#
Tested with: JSPWiki v2.3.15-cvs
Changes:#
- fixed: view="broken" together with dir="in" displayed nonbroken links as well
- new parameter: dirstring="text string"
For displaying the link direction (like "<<< " for dir="in")
Default is "". - 2006-05-25: updated to remove security risk on permitting raw HTML in parameters. In the current version
any markup entered into the dirstring and nolinktext parameters is escaped.
Example:#
links to undefined pages: [{LinkIndexPlugin dir='out' dirstring='>>> ' view='broken' nolinktext='OMIT'}]
Result looks like:#
links to undefined pages:Things that would be nice:#
- multiple occurring pages should be marked with a number when dir="in"
- listing links out of the wiki (mailto, http, ...). But this seems to be not easy.
--Frank_Fischer, 2005-08-28
Add new attachment
List of attachments
Kind | Attachment Name | Size | Version | Date Modified | Author | Change note |
---|---|---|---|---|---|---|
java |
LinkIndexPlugin.java | 8.1 kB | 1 | 23-Aug-2005 19:10 | 137.108.145.12 | |
java-20060525 |
LinkIndexPlugin.java-20060525 | 10.8 kB | 1 | 25-May-2006 04:27 | 210.55.131.59 | |
java-frankfischer-2005-08-27 |
LinkIndexPlugin.java-FrankFisc... | 30.7 kB | 3 | 09-Mar-2006 08:52 | 60.48.194.135 | |
java-frankfischer-2005-08-28 |
LinkIndexPlugin.java-FrankFisc... | 10.1 kB | 1 | 28-Aug-2005 10:55 | FrankFischer |