/*
* [ConfigurationForCherokeeObama.java]
*
* Summary: This is the customisation implementation of Configuration for cherokeeobama.com.
*
* 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.0 2010-01-23 initial version.
*/
package com.mindprod.htmlmacros.support;
import com.mindprod.common18.Misc;
import com.mindprod.common18.ST;
import com.mindprod.qf.AbstractGlossCustomiser;
import com.mindprod.stores.OnlineStore;
import com.mindprod.stores.StockStatus;
import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* This is the customisation implementation of Configuration for cherokeeobama.com.
*
* You need to write something similar
* that implements the Configuration interface.
* Configuration installed in Replacer command line, or programatically
* by or ReplaceCherokeeObama.
*
* @author Roedy Green, Canadian Mind Products
* @version 1.0 2010-01-23 initial version.
* @since 2010-01-23
*/
public final class ConfigurationForCherokeeObama extends Configuration
{
/**
* how many sections in each chapter. Used to generate next links. 0-based.
*/
public static final int[] SECTIONS_IN_CHAPTER = {
0
/* dummy chapter 0 */,
9,
5,
5,
7,
4,
2
/* ch 6 */,
3,
10,
3,
2,
2,
4
/* ch 12 */,
2,
1,
7,
10,
7,
2
/* ch 18 */ };
private static final String[] HTML_DIRS = new String[] {
"",
"dgg",
"dgg/dgg01",
"dgg/dgg02",
"dgg/dgg03",
"dgg/dgg04",
"dgg/dgg05",
"dgg/dgg06",
"dgg/dgg07",
"dgg/dgg08",
"dgg/dgg09",
"dgg/dgg10",
"dgg/dgg11",
"dgg/dgg12",
"dgg/dgg13",
"dgg/dgg14",
"dgg/dgg15",
"dgg/dgg16",
"dgg/dgg17",
"dgg/dgg18"
}; // "" stands for root, and subdirs of dgg
/**
* cached value of updateThisFooterNow
*/
private static boolean cachedResetFooters;
/**
* true after we have cached the value of updateThisFooterNow
*/
private static boolean resetFootersCached = false;
/**
* CSS assigning configuration
**/
private AssignCSSClasses assignCSSClasses;
/**
* get the novel synopsis text that goes at the top of each page in a box.
*
* @return text include div.../div
*/
public static String getSynopsis()
{
return "
In a timeline where the Confederate States of America is\n" +
"the only free nation left in a world ruled by Commies and Corpses (a/k/a Companies\n" +
"and Corporations), a reporter dabbling in Sex Magick gets more than he bargained for.
\n";
}// /method
/**
* Do we need to regenerate this file even if generated recently successfully and not changed since then.
*
* @param fileBeingDistributed
*
* @return tre if should force regeneration
*/
public boolean alwaysRegenerate( File fileBeingDistributed )
{
return true;
}// /method
// methods
/**
* get URL of corresponding blog for this page, possibly empty.
*
* @param fileBeingDistributed the file currently being processed.
*
* @return Url to blog, or ""
*/
@Override
public String blogForPage( File fileBeingDistributed )
{
return "http://www.dgog.blogspot.ca/";
}// /method
/**
* Figure out which page comes next.
*
* @param fileBeingDistributed the file currently being processed.
*
* @return relative link to the next page.
*/
public String calcNextPage( final File fileBeingDistributed )
{
final String filename = fileBeingDistributed.getName();
if ( filename.equals( "index.html" ) )
{
return "dgg/dgg01/dgg01.html";
}
int chapter = Integer.parseInt( filename.substring( 3, 5 ) ); // dggnn
int section = ( filename.length() == 12 ) ? Integer.parseInt( filename.substring( 5, 7 ) ) : 0;
// dggccss or dggcc
section++;
if ( section > ConfigurationForCherokeeObama.SECTIONS_IN_CHAPTER[ chapter ] )
{
chapter++;
if ( chapter >= ConfigurationForCherokeeObama.SECTIONS_IN_CHAPTER.length )
{
// done, back to home page.
return "./";
}
else
{
// next chapter in next chapter dir dggcc/dggcc.html
return "../dgg" + ST.toLZ( chapter, 2 ) + "/" + "dgg" + ST.toLZ( chapter, 2 ) + ".html";
}
}
else
{
// next section in same chapter. dggccss.html
return "dgg" + ST.toLZ( chapter, 2 ) + ST.toLZ( section, 2 ) + ".html";
}
}// /method
/**
* Figure out which page comes before this one..
*
* @param fileBeingDistributed the file currently being processed.
*
* @return relative link to the next page.
*/
public String calcPrevPage( final File fileBeingDistributed )
{
final String filename = fileBeingDistributed.getName();
if ( filename.equals( "index.html" ) )
{
return "dgg/dgg18/dgg1802.html";
}
int chapter = Integer.parseInt( filename.substring( 3, 5 ) );
int section = ( filename.length() == 12 ) ? Integer.parseInt( filename.substring( 5, 7 ) ) : 0;
section--;
if ( section < 0 )
{
chapter--;
if ( chapter <= 0 )
{
// done, back to home page.
return "./";
}
else
{
// last section in prev chapterr
section = SECTIONS_IN_CHAPTER[ chapter ];
return "../dgg" + ST.toLZ( chapter, 2 ) + "/dgg" + ST.toLZ( chapter, 2 ) + ST.toLZ( section,
2 ) + ".html";
}
}
else
{
if ( section == 0 )
{
// chapter header page.
return "dgg" + ST.toLZ( chapter, 2 ) + ".html";
}
else
{
// prev section in same chapter.
return "dgg" + ST.toLZ( chapter, 2 ) + ST.toLZ( section, 2 ) + ".html";
}
}
}// /method
/**
* get webroot relative url of corresponding feedback page for this page, defaulting to feedback/feedback.html,
* not empty.
*
* @param fileBeingDistributed the file currently being processed.
*
* @return webroot relative corresponding feedback page.
*/
@Override
public String correspondingFeedbackPage( File fileBeingDistributed )
{
return "http://cherokeeobama.wordpress.com/";
}// /method
/**
* @return AllPosters.com affiliate account number, aid, not account number, always an int is string form
*/
@Override
public int getAccountForAllpostersCom()
{
return 1025105019;
}// /method
/**
* @return account number for amazon.ca bookstore, null if none.
*/
@Override
public String getAccountForAmazonCa()
{
return "canadianmin07-20";
}// /method
/**
* @return account number for amazon.cn China bookstore, null if none.
*/
@Override
public String getAccountForAmazonCn()
{
return "canamindprod-23";
}// /method
/**
* @return account number for amazon.com bookstore, null if none.
*/
@Override
public String getAccountForAmazonCom()
{
return "canadianmindprod";
}// /method
/**
* @return account number for amazon.de bookstore, null if none.
*/
@Override
public String getAccountForAmazonDe()
{
return "canadianmin0b-21";
}// /method
/**
* @return account number for amazon.es bookstore, null if none.
*/
@Override
public String getAccountForAmazonEs()
{
return "httpmindprcom-21";
}// /method
/**
* @return account number for amazon.fr bookstore, null if none.
*/
@Override
public String getAccountForAmazonFr()
{
return "canamindprod-21";
}// /method
/**
* @return account number for amazon.it bookstore, null if none.
*/
@Override
public String getAccountForAmazonIt()
{
return "httpmindprc0b-21";
}// /method
/**
* @return account number for amazon.uk bookstore, null if none.
*/
@Override
public String getAccountForAmazonUk()
{
return "canadianmindp-21";
}// /method
/**
* @return Art.com affiliate account number. PID, always an integer in string form
*/
@Override
public int getAccountForArtCom()
{
return 15035854;
}// /method
/**
* @return account number for Barnes and Noble bookstore
*/
@Override
public String getAccountForBarnesAndNoble()
{
return "vSCiQT/Cnuo"; // handled by LinkSys
}// /method
/**
* @return account number, aka PID, for chapters indigo bookstore, null if none.
*/
@Override
public String getAccountForChaptersIndigo()
{
return null; /* was "2358048"; CJ rejected us */
}// /method
/**
* @return Google adSense account number. cmp google account "pub-7275336356867641" Randy Richardson's google
* account
* "pub-3625079171090429" . We use his account in return for free website hosting.
*/
@Override
public String getAccountForGoogleAdsense()
{
return "pub-3625079171090429";
}// /method
/**
* @return Google Custom Search Engine Account#.
*/
public String getAccountForGoogleCSE()
{
return "005260666645288681202";
}// /method
/**
* get junglee.com account #
*
* @return account number for junglee.com (amazon india) bookstore, null if none.
*/
public String getAccountForJungleeCom()
{
return null;
}// /method
/**
* @return account number for Kobo
*/
@Override
public String getAccountForKobo()
{
return "vSCiQT/Cnuo"; // handled by LinkSys
}// /method
/**
* @return account number for Powells bookstore, null if none.
*/
@Override
public String getAccountForPowells()
{
return null;
}// /method
/**
* @return account number for TigerDirect.ca
*/
@Override
public String getAccountForTigerDirectCa()
{
return null;
}// /method
/**
* @return account number for TigerDirect.com
*/
@Override
public String getAccountForTigerDirectCom()
{
return null;
}// /method
/**
* @return account name for WebRing, null if none.
*/
@Override
public String getAccountForWebring()
{
return "roedygr";
}// /method
/**
* @return NCIX affiliate number. PID, always an integer in string form
*/
public String getAccountNCIXCaCom()
{
return "11195336";
}// /method
/**
* @return NCIX affiliate number. PID, always an integer in string form
*/
@Override
public String getAccountNCIXUsCom()
{
return "11195336";
}// /method
/**
* get age in millis of changes to web pages that would be unexpected. When age is longer than this we
* display how the page changed for analysis. Recent changes from edits are expected.
*
* @return age in miliis
*/
public long getAgeOfUnexpectedChanges()
{
return TimeUnit.MINUTES.toMillis( 45 );
}// /method
/**
* get CSS configuring configuration
*/
public AssignCSSClasses getAssignCSSClasses()
{
if ( assignCSSClasses == null )
{
assignCSSClasses = new AssignCSSClassesForCherokeeObama();
}
return assignCSSClasses;
}
/**
* @return default author for web pages
*/
@Override
public String getAuthor()
{
return "Cherokee O’Bama";
}// /method
/**
* @return name of the code signing cert without .cer, possibly self-signed. e.g. "mindprodcert2017rsa";
*/
@Override
public String getCodeSigningCert()
{
return null;
}// /method
/**
* @return *=compactStringStrippingMacrosAndComments, with separate masters
* +=compactStringKeepingMacrosAndComments, classical, expande macros in place.
* -=does nothing
* Q=Quick If first 400 chars contain a double space, compactStringKeepingMacrosAndComments,
* otherwise do nothing
*/
@Override
public char getCompacting()
{
return '+';
}// /method
/**
* convert a webrootroot relative UNL to an absolute URL to the corresponding page on the companion website
*
* @param webrootRelative e.g. bgloss/dsk.html such as would be passed to Link, with /
*
* @return http://mindprod.com/bgloss/dsk.html or null if no equivalent
*/
public String getCompanionURL( final String webrootRelative )
{
return null;
}
/**
* @return corporate logo image file name. Stored in image/logo as .png or .jpg file
*/
@Override
public String getCompanyLogo()
{
return "co.png";
}// /method
/**
* @return company responsible for the web pages, hard coded in
*/
@Override
public String getCompanyName()
{
return "cherokeeobama.com";
}// /method
/**
* @return Company responsible for the web pages
* Prettified as you please with HTML.
*/
@Override
public String getCompanyNameFancyHtml()
{
return "Cherokee O’Bama";
}// /method
/**
* @return phone number of webmaster as a string, no format restrictions.
*/
@Override
public String getCompanyPhone()
{
return "(250) 361-9093";
}// /method
/**
* get name copyright holder for this page
*
* @param fileBeingDistributed the file currently being processed.
*
* @return Case-sensitive name of coppright holder for this page. Might contain some markup or entities.
*/
public String getCopyrightHolderForPage( final File fileBeingDistributed )
{
return "Cherokee Obama";
}// /method
/**
* @return array of Directories containing HTML files with macrcos. Does not include redir, includes, kjv,
* snippets, rss
* since these do not include HTML needing macro expansion.
* All Live in E:\mindprod\
*/
@Override
public List getDirsContainingHTMLMacros()
{
return Collections.unmodifiableList( Arrays.asList( HTML_DIRS ) );
}// /method
/**
* @return include Directories containing HTML files. Distributed. All Live in E:\mindprod\
*/
@Override
public List getDirsContainingIncludes()
{
return Collections.unmodifiableList( Arrays.asList( new String[] { "include" } ) );
}
/**
* get snippet dirs
*
* @return array of Directories containing stippet dirs
*/
public List getDirsContainingSnippets()
{
return Collections.emptyList();
}// /method
/**
* get dirs that need to be seesorted
*
* @return array of Directories that are
* seesortad. All Live in E:\mindprod\
*/
public List getDirsToSeeSort()
{
return Collections.emptyList();
}// /method
/**
* get dirs with hit counts macro expansion
*
* @return array of Directories that have hit counts. Does not include redir, includes, snippets, rss
* includes kjv
* All Live in E:\mindprod\
*/
@Override
public List getDirsWithHitCounts()
{
return Collections.unmodifiableList( Arrays.asList( HTML_DIRS ) );
}// /method
/**
* @param fileBeingDistributed
*
* @return Case-sensitive default doctype+ to got at the top of generated webpages.
*/
@Override
public String getDoctypeDefault( final File fileBeingDistributed )
{
return // "\n"
+ "\n";
}// /method
/**
* @param fileBeingDistributed
*
* @return Case-sensitive frame doctype+ to be used on frames
*/
@Override
public String getDoctypeForFrame( final File fileBeingDistributed )
{
return // "\n"
"\n"
+ "\n";
}// /method
/**
* @param fileBeingDistributed
*
* @return Case-sensitive frame doctype+ for iframe snippets
*/
@Override
public String getDoctypeForIframe( final File fileBeingDistributed )
{
return // "\n"
"\n"
+ "\n";
}// /method
/**
* How frequently do we rotate the a Quotation embedded in a page? Customise frequency of rotation for different
* types of pages on the website.
*
* @param fileBeingDistributed the file currently being processed.
*
* @return rotation interval in milliseconds.
* @see com.mindprod.htmlmacros.Quotation#expand(QuoteAggregate)
*/
@Override
public long getEmbeddedQuotationRotateIntervalInMillis( File fileBeingDistributed )
{
return TimeUnit.MINUTES.toMillis( 30 );
}// /method
/**
* @return first year this page was copyrighted if not otherwise specified
*/
public int getFirstCopyrightYear( File fileBeingDistributed )
{
return 1989;
}// /method
/**
* How frequently do we rotate the PSA ad/quotation on a given page? Customise frequency of rotation for different
* types of pages on the website. Also how often permit flip psa <--> quotation.
*
* @param fileBeingDistributed the file currently being processed.
*
* @return rotation interval in milliseconds.
* @see PSA#psaOrQuoteOrNonMil(QuoteAggregate, java.io.File, java.io.File)
*/
@Override
public long getFooterRotateIntervalInMillis( File fileBeingDistributed )
{
return TimeUnit.DAYS.toMillis( 1 );
}// /method
/**
* get a list of the glossary customisers that need indexing
*
* @return array of AbstractGlossCustomisers
*/
public AbstractGlossCustomiser[] getGlossCustomisers()
{
return new AbstractGlossCustomiser[] {};
}
/**
* @return tallest we allow an image to be to use in a page header
*/
@Override
public int getHeaderImageMaxHeight()
{
return 400;
}// /method
/**
* @return widest we allow an image to be to use in a page header
*/
@Override
public int getHeaderImageMaxWidth()
{
return 400;
}// /method
/**
* get language of the webpages e.g. "en-CA"
*
* @return fr-FR en-CA en-US etc.
*/
public String getLanguage( File fileBeingDistributed )
{
return "en-CA";
}// /method
/**
* @return where the website is stored locally on author's machines. Use local separator conventions e.g. \\ for
* each \ for windows. Uses E:
*/
@Override
public String getLocalWebrootWithBackslashes()
{
return "E:\\co";
}// /method
/**
* @return where the website is stored locally on author's machines. Use local separator conventions using slashes
*/
@Override
public String getLocalWebrootWithSlashes()
{
return "E:/co";
}// /method
/**
* @return preferred line separator in generated files. Normally \n since this is most compact. Possibly set to
* System.getProperty( "line.separator" ); or "\r\n" or "\r".
* If you have compaction turned on, this ignored. The lineSeparator is always \n because it is the most
* compact
* and web-centric.
*/
@Override
public String getPreferredLineSeparator()
{
return System.getProperty( "line.separator", "\r\n" );
}// /method
/**
* get quotation Aggregate category to use an a footer for a given page.
*
* @param footerFile web page where ad will go
*
* @return html to display banner and link
*/
@Override
public QuoteAggregate getQuoteAggregateForFooter( File footerFile )
{
return QuoteAggregate.GENERAL;
}// /method
/**
* @return how many days to keep RSS newsfeed items in the HTML display
*/
@Override
public int getRSSDisplayDays()
{
return 62;
}// /method
/**
* @return how many days to keep RSS newsfeed items in the RSS feed
*/
@Override
public int getRSSKeepDays()
{
return 32;
}// /method
/**
* generate tags.
*/
public boolean isUsingXHTML()
{
return true;
}// /method
/**
* do we give the verbose informational messages?
*
* @return true if want verbose version.
*/
public boolean isVerbose()
{
return true;
}// /method
/**
* does this file need its CSS classes repaired?
*
* @param fileBeingProcessed file in question
*/
public boolean needsCSSRepair( File fileBeingProcessed )
{
return false;
}// /method
/**
* Does this product possibly have a newer version?
* If no, we have checked it out at the new product is not really a replacmenent.
*
* @param productId isbn, sku etc.
*
* @return false if we have researched and their is not really a newer replacement product.
*/
public boolean possiblyNewer( String productId )
{
return true;
}
/*
* as part of your configuring, you will also likely want to use a
* completely different header and footer macro, perhaps giving them different names from mine, e.g.
* Header and Footer. You will want to modify the various header macros and invent your
* own.
*/
/**
* should we recompute footers, even if they have not yet expired?
* This should be true when run shortly after midnight to readjust footers for different birthday weightings.
*
* @param fileBeingDistributed, not the footer itself
*
* @return true if should recompute footers.
*/
public boolean shouldWeUpdateThisFooterNow( final File fileBeingDistributed )
{
if ( !resetFootersCached )
{
// check for set resetfooters=yes
// if parm missing, will be null
cachedResetFooters = Misc.parseBoolean( System.getenv( "resetfooters" ), false );
resetFootersCached = true;
}
return cachedResetFooters;
}// /method
/**
* override the usual stock mechanism because of errors in vendor
* databbase.
*
* @param store
* @param product
*
* @return null if no override, stockStatus if override
*/
public StockStatus stockStatusOverride( OnlineStore store, String product )
{
return null;
}
}