/* * [Moved.java] * * Summary: Generate the macro Moved file redirect. * * 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. */ package com.mindprod.htmlmacros.macro; import com.mindprod.common18.ST; import com.mindprod.fastcat.FastCat; import com.mindprod.htmlmacros.support.Tools; import java.io.File; import static com.mindprod.htmlmacros.macro.Global.configuration; import static java.lang.System.*; /** * Generate the macro Moved file redirect. * * @author Roedy Green, Canadian Mind Products * @version 1.8 2009-02-06 include go package in ZIP bundle. * @since 2009 */ @SuppressWarnings( { "WeakerAccess" } ) public final class Moved extends Macro { // declarations /** * how to use the macro */ private static final String USAGE = "\nMoved macro needs uPath newName"; // /declarations // methods /** * guts to Generate macro Moved redirect, this document moved. * * @param newName relative to E:\mindprod * * @return complete html document to do a redirect. */ private String expand( String newName ) { // delay to linger on redir screen. HTML Validator says < 10 may be ignored. final int delay = 10 /* seconds */; final String cmp = configuration.getCompanyNameFancyHtml(); final int firstCopyrightYear = configuration.getFirstCopyrightYear( fileBeingDistributed ); final String copyrightHolderForPage = configuration.getCopyrightHolderForPage( fileBeingDistributed ); final FastCat sb = new FastCat( 43 ); sb.append( configuration.getDoctypeDefault( fileBeingDistributed ) ); sb.append( "\n" ); Head headDelegate = new Head(); headDelegate.setFileBeingProcessedAndFileBeingDistributed( fileBeingProcessed, fileBeingDistributed ); sb.append( Head.buildInvisHeaderMetaTags( "Document Moved", "Moved", configuration.getCompanyName() + ", invalid document, moved.", configuration.getCompanyName() + ", moved documents", firstCopyrightYear, copyrightHolderForPage ) ); sb.append( "\n" ); sb.append( headDelegate.buildInvisHeaderLinks( null ) ); { final String screen = configuration.getStylesheetForUsual(); final String handheld = ST.chopTrailingString( screen, ".css" ) + "h.css"; sb.append( headDelegate.buildStylesheetLink( screen, "screen" ) ); sb.append( headDelegate.buildStylesheetLink( handheld, "handheld" ) ); } { final String screen = configuration.getStylesheetForJDisplay(); final String handheld = ST.chopTrailingString( screen, ".css" ) + "h.css"; sb.append( headDelegate.buildStylesheetLink( screen, "screen" ) ); sb.append( headDelegate.buildStylesheetLink( handheld, "handheld" ) ); } sb.append( "\n" ); sb.append( "\n" ); sb.append( "

" ); sb.append( cmp ); sb.append( "

\n" ); sb.append( "

Document " ); sb.append( Tools.basicNameWithExtension( fileBeingDistributed ) ); sb.append( " has moved permanently.

\n" ); sb.append( "

The document you requested " ); sb.append( Tools.serverQualifiedURLWithSlashes( fileBeingDistributed ) ); sb.append( "" ); sb.append( configuration.getBr() ); sb.append( "is now called \n" ); sb.append( "" ); sb.append( Tools.serverQualifiedURLWithSlashes( new File( configuration.getLocalWebrootWithSlashes(), newName ) ) ); sb.append( ". Please update your links.

\n" ); sb.append( "

If you don’t hit your browser’s back button now, " + "you\n" ); sb.append( "should be taken there automatically in " ); sb.append( delay ); sb.append( " seconds. You can go there manually by\n" ); sb.append( "clicking the correct URL above.

\n" ); sb.append( configuration.getHr() ); sb.append( "\n" ); sb.append( "\n" ); return sb.toString(); } // /method /** * Generate an entire document-moved file . * * @param parms parm[0] newname, where get redirected to without lead http://mindprod.com/ * LOCAL_WEBROOT_WITH_BACKSLASHES relative * @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( 'M' ); } if ( parms.length != 1 ) { throw new IllegalArgumentException( USAGE ); } final String newName = parms[ 0 ]; return expand( newName ); } // /method // /methods }