/* * [Quotation.java] * * Summary: Macro to generate a random link from a supplied list. * * 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.htmlmacros.support.QuoteAggregate; import static com.mindprod.htmlmacros.macro.Global.configuration; import static java.lang.System.*; /** * Macro to generate a random link from a supplied list. * * @author Roedy Green, Canadian Mind Products * @version 1.8 2009-02-06 include go package in ZIP bundle. * @see com.mindprod.htmlmacros.support.PSA * @see com.mindprod.htmlmacros.support.PSAType * @since 2009 */ public final class Quotation extends Macro { /** * how to use the macro */ private static final String USAGE = "\nQuotation macro takes a category parameter, e.g. animalrights, environment, " + "general, livinglove, misc, politics, religion"; /** * expandNoRef Quotation macro guts. * * @param aggregateCategory Which Aggregate category of quote is desired. * e.g. GENERAL, not the specific Flock e.g. POLITICS. * * @return on of the choice strings, randomly chosen, with macros expanded. */ private String expand( QuoteAggregate aggregateCategory ) { // Selected quote changes every hour, if run ReplaceMindprod at least that frequently with Windows Task // Scheduler. // To place a "random" quotation: // First selects Flock category weighted by weights for that aggregate, // (QuoteAggregate.getRandomQuotationForFile) // then within that Flock a random quote hashed by the file name and the time. (QuoteFlock // .getRandomQuotationForFile) // Authors within the chosen flock get extra weight on their birthday by having the quote appear multiple // times. QuoteFLock.calcWeight // Quotation with marked with get 10 entries in the flock table to give them extra weight. // QuoteFLock.calcWeight // If there is more that one quotation per page, we don't do anything special to avoid a duplicate // other than using a different hash. final String quotationText = aggregateCategory.getRandomQuotationForFile( configuration .getEmbeddedQuotationRotateIntervalInMillis( fileBeingProcessed ), fileBeingDistributed ); if ( quotationText.contains( "