/* * [CoChapter.java] * * Summary: Produce the header for a Cherokee Obama Chapter. * * Copyright: (c) 2010-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.0 2010-01-23 initial version, cloned from Living Love Head.. */ package com.mindprod.htmlmacros.macro; import com.mindprod.common18.EIO; import com.mindprod.common18.ST; import com.mindprod.fastcat.FastCat; import com.mindprod.htmlmacros.support.ConfigurationForCherokeeObama; import com.mindprod.htmlmacros.support.GoogleAdSense; import com.mindprod.htmlmacros.support.Indexing; import static com.mindprod.entities.DeEntifyStrings.stripHTMLTags; import static com.mindprod.htmlmacros.macro.Global.configuration; import static java.lang.System.*; /** * Produce the header for a Cherokee Obama Chapter. * * @author Roedy Green, Canadian Mind Products * @version 1.0 2010-01-23 initial version, cloned from Living Love Head. * @since 2010-01-23 */ public final class CoChapter extends Head { // declarations private static final String SYNOPSIS = ConfigurationForCherokeeObama.getSynopsis(); /** * how to use the macro */ private static final String USAGE = "\nCoChapter macro needs {chapter#} {chapterName} [keywords]"; // /declarations // methods /** * build a simplified header used by kindle * * @param description long description, (might contain entities and tags). not null. for head meta Description. * @param chapterNumber chapter number * @param chapterName title for chapter * @param keywords indexing keywords. * @param icon16 for title bar * * @return HTML for header and simplified title. */ private String buildKindleHead( final int chapterNumber, final String chapterName, final String keywords, final String description, final String icon16 ) { final String title = "Chapter " + chapterNumber + " : " + chapterName; final int firstCopyrightYear = configuration.getFirstCopyrightYear( fileBeingDistributed ); final String copyrightHolderForPage = configuration.getCopyrightHolderForPage( fileBeingDistributed ); final FastCat sb = new FastCat( 8 ); // header sb.append( configuration.getDoctypeDefault( fileBeingDistributed ) ); sb.append( buildInvisHead( title, chapterNumber + " : " + chapterName, stripHTMLTags( description ), keywords, icon16, firstCopyrightYear, copyrightHolderForPage ) ); // append body, TOP anchor, CONFIG sb.append( "

" ); sb.append( title ); sb.append( "

\n" ); return sb.toString(); } // /method /** * Produce the header for an Produce the header for a Cherokee Obama Chapter * * @param parms parameters from macro command line. parms[0] = title description of fragment. parms[1] * = description parms[2] = keywords * @param quiet true if want output suppressed. * @param verbose @return expanded macro HTML */ public String expandMacro( String[] parms, final boolean quiet, final boolean verbose ) { if ( !quiet ) { out.print( "C" ); } if ( !( 2 <= parms.length && parms.length <= 3 ) ) { throw new IllegalArgumentException( USAGE ); } final int chapterNumber = Integer.parseInt( parms[ 0 ] ); final int totalChapters = ConfigurationForCherokeeObama.SECTIONS_IN_CHAPTER.length - 1; if ( !( 1 <= chapterNumber && chapterNumber <= totalChapters ) ) { throw new IllegalArgumentException( "macro CoChapter chapter number " + chapterNumber + " must be in " + "range 1.." + totalChapters ); } final String chapterName = parms[ 1 ]; final String keywords = "science fiction, Cherokee O’Bama, Dreaming Gods of Gaia, " + "witchcraft" + ( parms.length > 2 ? "," + parms[ 2 ] : "" ); final String hereBreadcrumbTitle = "Chapter " + chapterNumber; // make sure macro matches file name. // should be in dgg/dgg99/dgg99.html final String chapterNN = ST.toLZ( chapterNumber, 2 ); if ( !EIO.getCanOrAbsPath( fileBeingDistributed ).replace( '\\', '/' ).endsWith( "dgg/dgg" + chapterNN + "/dgg" + chapterNN + ".html" ) ) { throw new IllegalArgumentException( "CoChapter chapter number does not match implied filename chapter." ); } final String description = "Dreaming Gods of Gaia : Chapter " + chapterNumber + " : " + chapterName; final String longTitle = "

Dreaming Gods of Gaia

" + SYNOPSIS + "

Chapter " + chapterNumber + " : " + chapterName + "

"; final String icon16 = "icon16/seagull.png"; final String relUpLink = "./"; // jump do index.html in root if ( configuration.isKindle() ) { return buildKindleHead( chapterNumber, chapterName, keywords, description, icon16 ); } else { return generalHead( longTitle, description, description, hereBreadcrumbTitle, "cochapter", keywords, icon16, null, null, null, null, null, null, null, null, null, null, relUpLink, "chapter summary", Indexing.NONE, GoogleAdSense.NONE, null, null ); } } // /method // /methods }