Add new attachment

Only authorized users are allowed to upload new attachments.

This page (revision-26) was last changed on 27-Mar-2009 15:09 by Janne Jalkanen  

This page was created on 30-May-2003 16:49 by JanneJalkanen

Only authorized users are allowed to rename pages.

Only authorized users are allowed to delete pages.

Difference between version and

At line 1 changed one line
''This page still under construction''
[{TableOfContents}]
At line 3 changed one line
Current known JSPWiki embedders:
!!How does it all work?
At line 5 changed one line
* [Roller blogger|http://www.rollerweblogger.org/page/roller/20030528]. [Sample code|http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/roller/roller/src/org/roller/presentation/velocity/plugins/jspwiki/WikiPlugin.java?rev=1.2&content-type=text/vnd.viewcvs-markup]
To utilize the JSPWiki rendering code (i.e. the TranslatorReader), you need three things:
At line 7 changed one line
!How to use the TranslatorReader?
# __A WikiEngine instance.__ It contains all of the configuration, PageProviders, etc.
# __A WikiContext.__ The WikiContext tells the TranslatorReader things like the current page name, version, stores some WikiVariables, etc.
# __A TranslatorReader.__ This is the heavy lifter that does all of the translating.
At line 11 added 112 lines
!!How to get a WikiEngine?
{{{
public WikiEngine getEngine( HttpServletRequest request )
{
ServletConfig config = request.getSession().getServletContext().getServletConfig();
WikiEngine my_engine = WikiEngine.getInstance( config );
return my_engine;
}
}}}
You can instantiate a WikiEngine through
{{{
Properties properties = new Properties();
// set properties
WikiEngine my_engine = new WikiEngine( properties );
}}}
but this is not recommended, since WikiEngines should really be singletons across your application (or context - if you have different applications running in the same JVM).
After you have created a WikiEngine, you can then reuse this object all over again. Note that there is a significant penalty in creating a WikiEngine, so you definitely want to cache this object.
!!How do I get a WikiContext?
Simple. If you have a HttpServletRequest handy, you can just go
{{{
WikiContext wikiContext = myWikiEngine.createContext( request, WikiContext.VIEW );
}}}
Another option is to create one for yourself with:
{{{
WikiPage page = myWikiEngine.getPage( "SamplePage" );
WikiContext wikiContext = new WikiContext( my_engine, page );
wikiContext.setRequestContext( WikiContext.VIEW );
}}}
Alternatively, you can use the WikiPage constructor -method to get the WikiPage. This is not recommended, however, because using getPage() gives you the benefits of the built-in caches.
The WikiContext holds the current rendering context. The WikiContext is created at the beginning of the request, and discarded after the response has been sent back to the client program. It is probably not a good idea to reuse this object.
!!How to get rendered page data?
If your page data is stored inside a JSPWiki repository, you can use the JSPWiki rendering code directly via the method ~WikiEngine.getHTML():
{{{
String rendereddata = myWikiEngine.getHTML( wikiContext, page );
}}}
The reason why you need to respecify the WikiPage you want to render is that in some occasions you may want to render a page within the context of another page, for example, the LeftMenu wants the ReferringPagesPlugin to get the referring pages of the page are viewing, not LeftMenu.
!!How to use the TranslatorReader?
If you have just a chunk of WikiMarkup, you don't want to store it in the Wiki page repository, but you want to render it directly. This can be accomplished by directly accessing a TranslatorReader. After you have the WikiContext, you can simply create a new TranslatorReader by using
{{{
TranslatorReader my_reader = new TranslatorReader( wikiContext,
new StringReader( my_page_data );
}}}
Now you can use the TranslatorReader just as if you were using any other {{java.io.Reader}}.
See the {{~FileUtil.copyContents( Reader in, Writer out)}} if you don't want to copy it all manually.
%%note
Note: You will need to call any PageFilters manually, if you are directly accessing the TranslatorReader, as normally this is done by the WikiEngine.
%%
!!How can I vary the rendering?
Take a look at the Javadoc of TranslatorReader to get the most up-to-date information, but here are some things you can do. You can control some features by setting variables in the WikiContext before rendering, and some others by directly accessing the TranslatorReader.
!Switching off the plugin rendering
Say
{{{
wikiContext.setVariable( TranslatorReader.PROP_RUNPLUGINS, "false" );
}}}
Alternatively, use
{{{
translatorReader.enablePlugins( false );
}}}
!Turn off image inlining
No matter what jspwiki.properties says, this turns off any image inlining.
{{{
translatorReader.enableImageInlining( false );
}}}
!!What other information can I get from the TranslatorReader?
TranslatorReader has a bunch of places where you can hook. I'm calling them hooks, because, well, I'm an old Amiga guy, and that word just sits better with me than "Listener". (This is a stub, more info needed.)
!Modifying link text
Hook to {{{ addLinkTransmutator() }}}
!Collecting local links
Add a listener with {{{addLocalLinkHook()}}}.
!Collecting external hyperlinks
Add a listener with {{{addExternalLinkHook()}}}.
!Collecting attachment links
Add a listener with {{{addAttachmentLinkHook()}}}.
!!What libraries (Jars) do I need?
At line 11 changed one line
!What libraries (Jars) do I need?
!!How do I make JSPWiki's logging play nice with my app's Log4j setup?
At line 128 added 9 lines
;:''BTW, I am not very adept at [log4j] config, so if someone else can help me out here, it would be cool. --[JanneJalkanen].''
!!!Current known JSPWiki embedders:
* [Roller Weblogger|http://rollerweblogger.org/wiki/Wiki.jsp?page=RollerWikiPlugin]. [Sample code|http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/roller/roller/src/org/roller/presentation/velocity/plugins/jspwiki/WikiPlugin.java?rev=1.4&content-type=text/vnd.viewcvs-markup]
* [JabberMessageArchiving]
* [The Ceryle Project|http://purl.org/ceryle/]
Version Date Modified Size Author Changes ... Change note
26 27-Mar-2009 15:09 5.52 kB Janne Jalkanen to previous Please don't post questions in the middle, they are very confusing to others.
25 27-Mar-2009 04:00 5.763 kB 69.26.32.67 to previous | to last
24 21-Jan-2009 10:42 5.52 kB 80.62.161.39 to previous | to last Fixed typo in code example.
23 18-Apr-2007 09:51 5.519 kB David Au to previous | to last restored; please use the Sandbox for testing
22 18-Apr-2007 07:54 5.519 kB 202.144.61.68 to previous | to last
21 18-Apr-2007 07:53 5.523 kB 202.144.61.68 to previous | to last
« This page (revision-26) was last changed on 27-Mar-2009 15:09 by Janne Jalkanen