NIFI-814 - Introduce hidden header with name of Processor to allow those arriving to site via direct reference to know the name of the processor

This closes #1624.

Signed-off-by: Aldrin Piri <aldrin@apache.org>
This commit is contained in:
Andre F de Miranda 2017-03-26 21:42:39 +11:00 committed by Aldrin Piri
parent f0a1c14f02
commit a26689318d
No known key found for this signature in database
GPG Key ID: 531AEBAA4CFE5D00
1 changed files with 25 additions and 1 deletions

View File

@ -94,8 +94,14 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
xmlStreamWriter.writeAttribute("href", "/nifi-docs/css/component-usage.css");
xmlStreamWriter.writeAttribute("type", "text/css");
xmlStreamWriter.writeEndElement();
xmlStreamWriter.writeEndElement();
xmlStreamWriter.writeStartElement("script");
xmlStreamWriter.writeAttribute("type", "text/javascript");
xmlStreamWriter.writeCharacters("window.onload = function(){if(self==top) { " +
"document.getElementById('nameHeader').style.display = \"inherit\"; } }" );
xmlStreamWriter.writeEndElement();
}
/**
@ -123,6 +129,7 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
final XMLStreamWriter xmlStreamWriter, final boolean hasAdditionalDetails)
throws XMLStreamException {
xmlStreamWriter.writeStartElement("body");
writeHeader(configurableComponent, xmlStreamWriter);
writeDescription(configurableComponent, xmlStreamWriter, hasAdditionalDetails);
writeTags(configurableComponent, xmlStreamWriter);
writeProperties(configurableComponent, xmlStreamWriter);
@ -134,6 +141,23 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
xmlStreamWriter.writeEndElement();
}
/**
* Write the header to be displayed when loaded outside an iframe.
*
* @param configurableComponent the component to describe
* @param xmlStreamWriter the stream writer to use
* @throws XMLStreamException thrown if there was a problem writing the XML
*/
private void writeHeader(ConfigurableComponent configurableComponent, XMLStreamWriter xmlStreamWriter)
throws XMLStreamException {
xmlStreamWriter.writeStartElement("h1");
xmlStreamWriter.writeAttribute("id", "nameHeader");
// Style will be overwritten on load if needed
xmlStreamWriter.writeAttribute("style", "display: none;");
xmlStreamWriter.writeCharacters(getTitle(configurableComponent));
xmlStreamWriter.writeEndElement();
}
/**
* Write the description of the Stateful annotation if provided in this component.
*