.. .
*
* @param title title of the document
* @param description sentence describing the contents of the web page.
* @param keywords indexing keywords
* @param icon16 for title bar, icon16/xxx..png
* @param firstCopyrightYear year this document was first copyrighted
*
* @return expanded HTML
* @see CarolHead
*/
String buildInvisHead( final String title,
final String shortTitle,
final String description,
final String keywords,
final String icon16,
final int firstCopyrightYear,
final String copyrightHolderForPage )
{
final FastCat sb = new FastCat( 23 );
// build header
sb.append( "\n" );
// put title first as recommended by HTMLValidator
// handle title, description keyword headers
sb.append( buildInvisHeaderMetaTags( title,
shortTitle,
description,
keywords,
firstCopyrightYear,
copyrightHolderForPage
)
);
// arrange links to style sheets
if ( configuration.includeStylesheetForUsual( fileBeingDistributed ) )
{
final String screen = configuration.getStylesheetForUsual(); /* e.g. mindprod.css */
final String handheld = ST.chopTrailingString( screen, ".css" ) + "h.css";
sb.append( buildStylesheetLink( screen, "screen" ) );
sb.append( buildStylesheetLink( handheld, "handheld" ) );
}
if ( configuration.includeStylesheetForJDisplay( fileBeingDistributed ) )
{
final String screen = configuration.getStylesheetForJDisplay(); /* e.g. jdisplay.css */
final String handheld = ST.chopTrailingString( screen, ".css" ) + "h.css";
sb.append( buildStylesheetLink( screen, "screen" ) );
sb.append( buildStylesheetLink( handheld, "handheld" ) );
}
if ( configuration.includeStylesheetForHome( fileBeingDistributed ) )
{
/* e.g. home.css */
sb.append( buildStylesheetLink( configuration.getStylesheetForHome(), "all" ) );
}
if ( configuration.includeStylesheetForCarols( fileBeingDistributed ) )
{
final String screen = configuration.getStylesheetForCarols(); /* e.g. carol.css */
final String handheld = ST.chopTrailingString( screen, ".css" ) + "h.css";
sb.append( buildStylesheetLink( screen, "screen" ) );
sb.append( buildStylesheetLink( handheld, "handheld" ) );
}
if ( configuration.includeStylesheetForHandbook( fileBeingDistributed ) )
{
final String screen = configuration.getStylesheetForHandbook(); /* e.g. handbook.css */
final String handheld = ST.chopTrailingString( screen, ".css" ) + "h.css";
sb.append( buildStylesheetLink( screen, "screen" ) );
sb.append( buildStylesheetLink( handheld, "handheld" ) );
}
if ( configuration.includeStylesheetForBlurb( fileBeingDistributed ) )
{
final String screen = configuration.getStylesheetForBlurb(); /* e.g. blurb.css */
final String handheld = ST.chopTrailingString( screen, ".css" ) + "h.css";
sb.append( buildStylesheetLink( screen, "screen" ) );
sb.append( buildStylesheetLink( handheld, "handheld" ) );
}
// arrange rest of header links.
sb.append( buildInvisHeaderLinks( icon16 ) );
final String rssLink = configuration.getRSSLink( fileBeingDistributed );/* possible reference to an RSS feed */
if ( rssLink != null )
{
sb.append( rssLink );
}
final String prevRelLink = configuration.calcPrevPage( fileBeingDistributed );
if ( prevRelLink != null )
{
// append prev link
sb.append( "\n" );
}
final String nextRelLink = configuration.calcNextPage( fileBeingDistributed );
if ( nextRelLink != null )
{
// append next link
sb.append( "\n" );
}
sb.append( "\n" );
return sb.toString();
}// /method
/**
* Builds the standard header lines for the link icon16, and the rel links.
*
* @param icon16 unqualified name of icon16 file in images dir, may be null, e.g. icon16/picture.png
*
* @return HTML for header links
*/
String buildInvisHeaderLinks( String icon16 )
{
final FastCat sb = new FastCat( 12 );
// sb.append( "" );
if ( configuration.isRestrictedToAdults( fileBeingDistributed ) )
{
// see http://www.metatags.info/meta_name_rating for details
sb.append( "\n" );
}
// link to home
sb.append( "\n" );
if ( icon16 != null
&& icon16.length() != 0
&& ( !icon16.equals( "null" ) ) )
{
sb.append( "\n" );
}
// link to http://purl.org/dc/terms/ redirects to http://dublincore.org/documents/2012/06/14/dcmi-terms/?v=terms#
sb.append( "\n" );
return sb.toString();
}// /method
/**
* link to http://purl.org/dc/terms/ redirects to http://dublincore.org/documents/2012/06/14/dcmi-terms/?v=terms#
* purl.org is not on Shaw DN
*
* @param prevRelLink previous page in hierarchy.
* @param prevTitleFlattened title for previous link
*
* @return expanded HTML
*/
private String buildNavigationButtons( final String title, final String prevRelLink,
final String prevTitleFlattened,
final String extraNavigation,
final String googleSiteSearchCode )
{
final FastCat sb = new FastCat( 17 );
sb.append( "
\n" );
// append home button
sb.append( buildHomeButton() );
// extraNavigation is created by SectionHead, JglossHead, BGlossHead, JGlossLetterHead, BGlossLetterHead
// etc. and passed down to us through a great chain of calls.
// It may contain the complete HTML for building a couple of buttons, e.g. for cross links between the Java
// and buyer's glossary.
if ( extraNavigation != null )
{
sb.append( extraNavigation );
}
// append the prev button
sb.append( buildPrevButton() );
// append the up button
sb.append( buildUpButton( prevRelLink, prevTitleFlattened ) );
// append the next button
sb.append( buildNextButton() );
// append toBottom button to go to footer
sb.append( buildToBottomButton() );
// google translate button handled in generalHeadGuts
if ( googleSiteSearchCode == null )
{
sb.append( buildGoogleSearchButton( title ) );
}
else
{
sb.append( buildGoogleSiteSearchBox( googleSiteSearchCode ) );
}
sb.append( "\n", buildPinterestVis() );
Global.forBottom.append( "\n", buildPinterestInvis() );
// Google +1 visible part, put and end so excess length and misalignment not so obvious
sb.append( "\n", buildGooglePlus1Vis() );
Global.forBottom.append( "\n", buildGooglePlus1Invis() );
sb.append( "
\n" );
return sb.toString();
}// /method
/**
* Build HTML for a Back/Prev button
*
* the file currently being processed.
*
* @return generated HTML
*/
private String buildNextButton()
{
String nextRelLink = configuration.calcNextPage( fileBeingDistributed );
if ( nextRelLink == null )
{
return "";
}
final FastCat sb = new FastCat( 6 );
sb.append( PLAIN_HREF );
sb.append( "\"", nextRelLink, "\">" );
sb.append( BuildImage.buildImgTag( "navigate/next.png",
"next",
ImageAlignment.middle /* navbar class is not sufficient */,
null/* no cssClass */,
fileBeingDistributed ) );
sb.append( "\n" );
return sb.toString();
}// /method
/**
* Build HTML for a toBottom button
*
* @return generated HTML
*/
private String buildPinterestVis()
{
// see https://developers.pinterest.com/docs/widgets/pin-it/ for simple buttons
final FastCat sb = new FastCat( 3 );
sb.append( "\n" );
sb.append( "\n" );
// gets confused if load icon locally from corplogo/pinterestrect.png. Javascript rewrites markup.
sb.append( "\n" );
// we could upgrade these to rich pins, but that needs many extra header fields. https://developers.pinterest.com/docs/rich-pins/overview/
return sb.toString();
}// /method
/**
* Build HTML for a Prev button
*
* @return generated HTML
*/
private String buildPrevButton()
{
String prevRelLink = configuration.calcPrevPage( fileBeingDistributed );
if ( prevRelLink == null )
{
return "";
}
final FastCat sb = new FastCat( 6 );
sb.append( PLAIN_HREF );
sb.append( "\"", prevRelLink, "\">" );
sb.append( BuildImage.buildImgTag( "navigate/prev.png",
"previous",
ImageAlignment.middle /* navbar class is not sufficient */,
null/* no cssClass */,
fileBeingDistributed ) );
sb.append( "\n" );
return sb.toString();
}// /method
/**
* Build HTML for a toBottom button
*
* @return generated HTML
*/
private String buildToBottomButton()
{
final FastCat sb = new FastCat( 4 );
sb.append( PLAIN_HREF );
sb.append( "\"#BOTTOM\">" );
sb.append( BuildImage.buildImgTag( "navigate/tobottom.png",
"jump to foot of page",
ImageAlignment.middle /* navbar class is not sufficient */,
null/* no cssClass */,
fileBeingDistributed ) );
sb.append( "\n" );
return sb.toString();
}// /method
/**
* Build HTML for a Back/Prev button
*
* @param prevRelLink URL of prev page.
* @param prevTitleFlattened description of previous link without entities
*
* @return generated HTML
*/
private String buildUpButton( String prevRelLink, String prevTitleFlattened )
{
if ( prevRelLink == null )
{
return "";
}
assert prevTitleFlattened != null : "prevTitleFlattened not set.";
final FastCat sb = new FastCat( 6 );
sb.append( PLAIN_HREF, "\"", prevRelLink, "\">" );
sb.append( BuildImage.buildImgTag( "navigate/up.png",
"up",
ImageAlignment.middle /* navbar class is not sufficient */,
null/* no cssClass */,
fileBeingDistributed ) );
sb.append( "\n" );
return sb.toString();
}// /method
/**
* gets of generating a header. It presumes all validation has been done previously. It focuses entirely on
* generating the code.
*
* @param longTitle title of the document (might contain entities and tags)
* @param shortTitle abbreviated version of title. If null, defaults to longTitle.,
* used in meta/title , nav buttons.
* @param description long description, (might contain entities and tags)
* @param hereBreadcrumbTitle a short title for the document, if null,
* will use title. (might contain entities and tags)
* @param titleStyle CSS style to use to render the title, e.g. titlehome
* @param keywords indexing keywords
* @param icon16 for title bar, e.g. icon16/xxx..png
* @param topLeftOfPageRef URL to go to if user clicks upper left image.
* @param imgLeft cooked \n" );
// SSI no longer used "\n" );
// 1 = foot only 2 = both head and foot.
if ( configuration.howManyGoogleAds( fileBeingDistributed ) >= 2 )
{
// top ad
// ad object encode size.
sb.append( ad.getGoogleAdVis( "googlead" /* cssClass for top ad */ ) );
Global.forBottom.append( ad.getGoogleAdInvis() );
}
// append Google Translate button, markup after ad, but renders before ad.
sb.append( buildGoogleTranslateVis() );
Global.forBottom.append( "\n", buildGoogleTranslateInvis() );
sb.append( "\n
\n" );
}
else
{
// handle right hand image with CSS style.
sb.append( " style=\"background-image: url(" );
sb.append( BuildImage.buildImageRootForStyleRef( topRightOfPageImage,
fileBeingDistributed ) );
sb.append( ");background-position:80% center;background-repeat:no-repeat\">\n" );
}
// handle left hand image with classic HTML IMG
if ( !ST.isEmpty( imgLeft ) )
{
if ( !ST.isEmpty( topLeftOfPageRef ) )
{
sb.append( Tools.completeLink( topLeftOfPageRef,
imgLeft /* desc */,
null /* class */,
fileBeingDistributed ) );
}
else
{
sb.append( imgLeft ); // will float left.
}
sb.append( "\n" );
}
final boolean needsH1 = !( longTitle.startsWith( "
" );
}
sb.append( longTitle ); // may contain embedded tags, especially
if ( needsH1 )
{
sb.append( "" );
}
sb.append( "\n" );
// following will flow onto as many lines as needed, keeping each check together. Might fit all on one line.
sb.append( buildNavigationButtons( stripHTMLTags( shortTitle ),
upRelLink,
upTitleFlattened,
extraNavigation,
googleSiteSearchCode ) );
sb.append( ' ' );
// build go to A B C etc index if needed.
sb.append( indexed.buildJumpToIndex() );
sb.append( ' ' );
// do the you-are-here, how we got to this page.
sb.append( buildBreadcrumbs( isHomePage,
sectionRelLink,
sectionBreadcrumbTitle,
SubSectionRelLink,
subsectionBreadcrumbTitle,
subSubSectionRelLink,
subSubsectionBreadcrumbTitle,
hereBreadcrumbTitle
) );
sb.append( ' ' );
// page author
sb.append( buildVisPageAuthor( firstCopyrightYear, copyrightHolderForPage, lastReviewedDate ) );
// get embellishment text for all letters.
final String addendum = Embellishment.buildEmbellishmentAddendumForHeader( fileBeingDistributed );
if ( addendum != null && addendum.length() != 0 )
{
// expand macros in addendum
Include includeDelegate = new Include();
includeDelegate.setFileBeingProcessedAndFileBeingDistributed( fileBeingProcessed, fileBeingDistributed );
sb.append( includeDelegate.includeString( addendum,
"Embellishment",
100,
false
/* no check */,
true
/* quiet */,
false
/* not verbose */ ) );
}
sb.append( " \n" );
sb.append( "\n" );
return sb.toString();
}// /method
/**
* Builds the a link to a given style sheet
*
* @param stylesheetName same of the stylesheet file, webroot relative, e.g. mindprod.css
* might be the footer or main fileBeingDistributed
* @param media who should use this style sheet, e.g. "screen", "handheld"
*
* @return HTML for style sheet links
*/
public String buildStylesheetLink( String stylesheetName, String media )
{
if ( stylesheetName == null )
{
return "";
}
if ( !stylesheetName.endsWith( ".css" ) )
{
throw new IllegalArgumentException( "invalid stylesheet name " + stylesheetName );
}
final FastCat sb = new FastCat( 5 );
sb.append( "\n" ); // could be screen, print
return sb.toString();
}// /method
/**
* Generate the header for a general purpose html document.
*
* @param parms parameters from macro command line.
parm[0] = title of fragment.
*
parm[1] = description of fragment. parm[2] = keywords for fragment.
*
parm[3] = icon
parm[4] = png (may be null, but may not be left out)