/* * [AmanuensisMenuItem.java] * * Summary: Generate a menu item, three columns, image/short/long description for an Applet. * * Copyright: (c) 2009-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.8 2009-02-06 include go package in ZIP bundle. * docs, download */ package com.mindprod.htmlmacros.macro; import com.mindprod.fastcat.FastCat; import com.mindprod.htmlmacros.support.BuildImage; import com.mindprod.htmlmacros.support.ImageAlignment; import com.mindprod.htmlmacros.support.Tools; import com.mindprod.prices.AppCat; import java.io.File; import static com.mindprod.htmlmacros.macro.Global.configuration; import static java.lang.System.*; /** * Generate a menu item, three columns, image/short/long description for an Applet. * * @author Roedy Green, Canadian Mind Products * @version 1.8 2009-02-06 include go package in ZIP bundle. * docs, download * @see com.mindprod.htmlmacros.WebStartMenuItem * @see ApplicationMenuItem * @since 2009 */ @SuppressWarnings( { "UnusedDeclaration" } ) public final class AmanuensisMenuItem extends Macro { /** * used to separate a click able link from its neighbours to make it stand out. light vertical bar. * If it won't render, will just give a little extra while space. */ private static final String LINK_SEP = " ❘ "; // &VerticalSeparator in HTML 5 private static final String TAG_TAIL = configuration.getTagTail(); /** * how to use the macro */ private static final String USAGE = "\nAmanuensisMenuItem macro needs targetFile page image shortDesc longDesc"; /** * guts to Generate reference to an AmanuensisMenuItem reference * * @param targetFile name of file to jump to * @param page page number in downloads. * @param image image representing the file. * @param shortDesc short description * @param longDesc long description * * @return expand lines table followed by divider line */ private String expand( String targetFile, String page, String image, String shortDesc, String longDesc ) { // get base by chopping .html final String base = targetFile.substring( 0, targetFile.length() - ".html".length() ); final String ucBase = base.toUpperCase(); final String manualLink; final String manualFilename = base + ".manual.html"; if ( new File( ( configuration.getLocalWebrootWithSlashes() + "/" + AppCat.APPLET.getJarDir() ).replace( '/', File.separatorChar ), manualFilename ) .exists() ) { manualLink = LINK_SEP + " " + Tools.completeLink( AppCat.APPLET.getJarDir() + '/' + manualFilename, "manual", "manual", fileBeingDistributed ); } else { manualLink = ""; } final String runHtmlFile = AppCat.APPLET.getJarDir() + '/' + targetFile; final FastCat sb = new FastCat( 36 ); sb.append( "" ); sb.append( "" ); sb.append( Tools.completeLink( runHtmlFile, BuildImage.buildImgTag( image, shortDesc, ImageAlignment.none, null, fileBeingDistributed ), "plain", fileBeingDistributed ) ); sb.append( "" ); sb.append( Tools.completeLink( runHtmlFile, shortDesc, "plain", fileBeingDistributed ) ); sb.append( "\n" ); sb.append( "" ); sb.append( longDesc ); sb.append( ' ' ); sb.append( Updated.expand( true, runHtmlFile /* decorated */ ) ); sb.append( "\n" ); sb.append( "" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "
" ); sb.append( shortDesc ); sb.append( "
" ); sb.append( Tools.completeLink( AppCat.getPrecisDir() + '/' + base + ".txt", "precis", "precis", fileBeingDistributed ) ); sb.append( " " ); sb.append( manualLink ); sb.append( " of current version
" ); sb.append( Tools.completeLink( runHtmlFile, "run", "applet", fileBeingDistributed ) ); sb.append( " online as an Applet without installing
" ); sb.append( Tools.completeLink( "products" + page + ".html#" + ucBase, "download", "zip", fileBeingDistributed ) ); sb.append( " source and executable
" ); sb.append( "\n" ); sb.append( "" ); sb.append( " \n" ); sb.append( " \n" ); sb.append( "" ); sb.append( configuration.getHr() ); sb.append( "\n" ); return sb.toString(); } /** * Generate Amanuensis MenuItem to jump to a file. * * @param parms parms[0] targetFile name of file to jump to, relative to webRoot parms[3] image * representing the file. parms[1] shortDesc short description parms[2] longDesc long * description * @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( "A" ); } if ( parms.length != 5 ) { throw new IllegalArgumentException( USAGE ); } final String targetFile = parms[ 0 ]; final String page = parms[ 1 ]; final String image = parms[ 2 ]; final String shortDesc = parms[ 3 ]; final String longDesc = parms[ 4 ]; return expand( targetFile, page, image, shortDesc, longDesc ); } }