|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.clapper.curn.output.FileOutputHandler
org.clapper.curn.output.freemarker.FreeMarkerOutputHandler
public class FreeMarkerOutputHandler
Provides an output handler that uses the
FreeMarker
template engine to generate output. In addition to the configuration
parameters supported by the FileOutputHandler base class, this
handler supports the following additional configuration variables, which
must be specified in the handler's configuration section.
| Parameter | Explanation | Default |
|---|---|---|
| AllowEmbeddedHTML | Whether or not to pass embedded HTML to the FreeMarker template | false |
| MimeType | The MIME type of the document produced by the template. (See TemplateFile, below.) Required for all template types except "builtin". | None |
| TOCItemThreshold | The total number of items (not feeds, but individual items) that must be displayed before curn will generate a table of contents header. A value of 0 means "generate a table of contents regardless of how many items are displayed." The FreeMarker template is not obligated to honor this parameter. (Note, though, that the default FreeMarker HTML template does honor it.) | infinite (i.e., no table of contents is generated) |
| Title | Document title to pass to the template. | "RSS Feeds" |
| TemplateFile | Specifies the location of the FreeMarker template file.
The location is specified with two white space-delimited
fields:
Note:file c:\curn\html.ftl url http://localhost/html.ftl classpath org/clapper/curn/output/freemarker/HTML.ftl builtin html
|
"RSS Feeds" |
This handler builds a FreeMarker data model; each call to
displayChannel() adds the data for a channel
to the data structure. When the flush() method is invoked,
this handler loads the FreeMarker template and feeds it the
FreeMarker data model, producing the output. The FreeMarker template
can produce any kind of document; this handler doesn't care.
This handler builds the following FreeMarker data model tree.
Tree Description
(root)
|
+-- curn
| |
| +-- showToolInfo (boolean) whether or not
| | to display curn information
| | in the output
| |
| +-- version version of curn
| |
| +-- buildID curn's build ID
|
+-- totalItems total items for all channels
|
+-- dateGenerated date generated
|
+-- extraText extra text, from the config
|
+-- encoding encoding, from the config
|
+-- tableOfContents hash of TOC data
| |
| +-- needed whether a TOC is needed
| |
| +-- channels sequence of channel TOC
| | items
| |
| +-- (channel) TOC entry for one channel
| |
| +-- title channel title
| |
| +-- url channel URL (from the XML)
| |
| +-- configuredURL channel/feed URL from the
| | config file
| |
| +-- totalItems total items in channel
| |
| +-- channelAnchor HTML anchor for channel
|
+-- channels sequence of channel data
|
+-- (channel) hash for a single channel
|
+-- index channel's index in list
|
+-- totalItems total items in channel
|
+-- title channel title
|
+-- anchorName HTML anchor for channel
|
+-- url channel's URL
|
+-- date channel's last-modified date
| (might be missing)
|
+-- items sequence of channel items
|
+-- (item) entry for one item
|
+-- index item's index in channel
|
+-- title item's title
|
+-- url item's unique URL
|
+-- date the date
| (might be missing)
|
+-- author the author (might be missing)
|
+-- description description/summary
In addition, the data model provides (at the top level) the following methods:
(root) | +-- wrapText (string[, indentation[, lineLength]]) | +-- indentText (string, indentation) | +-- stripHTML (string)
OutputHandler,
FileOutputHandler,
Curn,
RSSChannel| Field Summary | |
|---|---|
static TemplateLocation |
BUILTIN_HTML_TEMPLATE
Built-in HTML template. |
static TemplateLocation |
BUILTIN_SUMMARY_TEMPLATE
Built-in summary template |
static TemplateLocation |
BUILTIN_TEXT_TEMPLATE
Built-in text template |
static java.lang.String |
CFG_BUILTIN_HTML_TEMPLATE
Configuration keyword: Built-in HTML template |
static java.lang.String |
CFG_BUILTIN_SUMMARY_TEMPLATE
Configuration keyword: Built-in summary template |
static java.lang.String |
CFG_BUILTIN_TEXT_TEMPLATE
Configuration keyword: Built-in text template |
static java.lang.String |
CFG_EXTRA_TEXT
Configuration variable: extra text |
static java.lang.String |
CFG_TEMPLATE_FILE
Configuration variable: template file |
static java.lang.String |
CFG_TEMPLATE_LOAD_BUILTIN
Configuration keyword for built-in template |
static java.lang.String |
CFG_TEMPLATE_LOAD_FROM_CLASSPATH
Configuration keyword for template loading from classpath |
static java.lang.String |
CFG_TEMPLATE_LOAD_FROM_FILE
Configuration keyword for template loading from file |
static java.lang.String |
CFG_TEMPLATE_LOAD_FROM_URL
Configuration keyword for template loading from URL |
static java.lang.String |
CFG_TITLE
Configuration variable: title |
static java.lang.String |
CFG_TOC_ITEM_THRESHOLD
Configuration variable: table-of-contents item threshold |
| Fields inherited from class org.clapper.curn.output.FileOutputHandler |
|---|
CFG_ENCODING, CFG_SAVE_AS, CFG_SAVE_ONLY, CFG_SAVED_BACKUPS, CFG_SHOW_CURN_INFO |
| Constructor Summary | |
|---|---|
FreeMarkerOutputHandler()
Construct a new FreeMarkerOutputHandler. |
|
| Method Summary | |
|---|---|
void |
displayChannel(RSSChannel channel,
FeedInfo feedInfo)
Display the list of RSSItem news items to whatever output is defined for the underlying class. |
void |
flush()
Flush any buffered-up output. |
java.lang.String |
getContentType()
Get the content (i.e., MIME) type for output produced by this output handler. |
void |
initOutputHandler(CurnConfig config,
ConfiguredOutputHandler cfgHandler)
Initializes the output handler for another set of RSS channels. |
| Methods inherited from class org.clapper.curn.output.FileOutputHandler |
|---|
displayToolInfo, getGeneratedOutput, getName, getOutputEncoding, getOutputFile, hasGeneratedOutput, init, openOutputFile, savingOutputOnly, setName, setOutputEncoding |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String CFG_EXTRA_TEXT
public static final java.lang.String CFG_TITLE
public static final java.lang.String CFG_TOC_ITEM_THRESHOLD
public static final java.lang.String CFG_TEMPLATE_FILE
public static final java.lang.String CFG_TEMPLATE_LOAD_BUILTIN
public static final java.lang.String CFG_BUILTIN_HTML_TEMPLATE
public static final java.lang.String CFG_BUILTIN_TEXT_TEMPLATE
public static final java.lang.String CFG_BUILTIN_SUMMARY_TEMPLATE
public static final java.lang.String CFG_TEMPLATE_LOAD_FROM_CLASSPATH
public static final java.lang.String CFG_TEMPLATE_LOAD_FROM_URL
public static final java.lang.String CFG_TEMPLATE_LOAD_FROM_FILE
public static final TemplateLocation BUILTIN_HTML_TEMPLATE
public static final TemplateLocation BUILTIN_TEXT_TEMPLATE
public static final TemplateLocation BUILTIN_SUMMARY_TEMPLATE
| Constructor Detail |
|---|
public FreeMarkerOutputHandler()
| Method Detail |
|---|
public void initOutputHandler(CurnConfig config,
ConfiguredOutputHandler cfgHandler)
throws org.clapper.util.config.ConfigurationException,
CurnException
initOutputHandler in class FileOutputHandlerconfig - the parsed curn configuration datacfgHandler - the ConfiguredOutputHandler wrapper
containing this object; the wrapper has some useful
metadata, such as the object's configuration section
name and extra variables.
org.clapper.util.config.ConfigurationException - configuration error
CurnException - some other initialization error
public void displayChannel(RSSChannel channel,
FeedInfo feedInfo)
throws CurnException
flush() can pass all the channels to the
script.
displayChannel in interface OutputHandlerdisplayChannel in class FileOutputHandlerchannel - The channel containing the items to emit. curn
will pass a copy of the actual RSSChannel
object, so the output handler can edit its contents,
if necessary, without affecting other output
handlers.feedInfo - Information about the feed, from the configuration
CurnException - unable to write output
public void flush()
throws CurnException
flush in interface OutputHandlerflush in class FileOutputHandlerCurnException - unable to write outputpublic java.lang.String getContentType()
getContentType in interface OutputHandlergetContentType in class FileOutputHandlerOutputHandler.hasGeneratedOutput(),
OutputHandler.getGeneratedOutput()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||