__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 &quot;no links&quot;. 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):

; [About] : TextFormattingRules
; [Main] : About, SandBox, Project Tattooine, WikiEtiquette, TextFormattingRules, JSPWikiTips, JSPWikiFAQ, System
; [Project Tattooine|OneMinuteWiki] : %%(color:#880000) __~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 &quot;OMIT&quot; (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=&quot;all|broken&quot;\\
 Lists all or only the broken links. Default is &quot;all&quot;.
*the listed pages are sorted and multiple occurrences are marked with a number (only when dir=&quot;out&quot;):\\
 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=&quot;broken&quot; together with dir=&quot;in&quot; displayed nonbroken links as well
*new parameter: dirstring=&quot;[text string]&quot;\\
 For displaying the link direction (like &quot;&lt;&lt;&lt; &quot; for dir=&quot;in&quot;)\\
 Default is &quot;&quot;.
* 2006-05-25: updated to remove security risk on permitting raw HTML in parameters. In the [current version|http://www.jspwiki.org/attach/LinkIndexPlugin/LinkIndexPlugin.java-20060525] any markup entered into the ''dirstring'' and ''nolinktext'' parameters is escaped.

!Example:
{{{
links to undefined pages:
[{LinkIndexPlugin dir='out' dirstring='&gt;&gt;&gt; ' view='broken' nolinktext='OMIT'}]
}}}
!Result looks like:
links to undefined pages:
;[About]:&gt;&gt;&gt; [undefinedPage1], [undefinedPage2], [undefinedPage3](2)
;[Main]:&gt;&gt;&gt; [undefinedPage1], [undefinedPage2](3), [undefinedPage3]

!Things that would be nice:
*multiple occurring pages should be marked with a number when dir=&quot;in&quot;
*listing links out of the wiki (mailto, http, ...). But this seems to be not easy.

--[Frank_Fischer], 2005-08-28