Merge pull request #28 from gregorko/master

Added ability to specify a custom sitemap index file
This commit is contained in:
Matthias Kurz 2018-07-05 14:49:16 +02:00 committed by GitHub
commit d4bc63c582
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 5 deletions

View File

@ -162,7 +162,7 @@ abstract class SitemapGenerator<U extends ISitemapUrl, THIS extends SitemapGener
}
/** Write out remaining URLs; this method can only be called once. This is necessary so we can keep an accurate count for {@link #writeSitemapsWithIndex()}.
*
*
* @return a list of files we wrote out to disk
*/
public List<File> write() {
@ -208,14 +208,25 @@ abstract class SitemapGenerator<U extends ISitemapUrl, THIS extends SitemapGener
sb.append("</urlset>");
}
/** After you've called {@link #write()}, call this to generate a sitemap index of all sitemaps you generated.
*
/**
* After you've called {@link #write()}, call this to generate a sitemap index of all sitemaps you generated.
* The sitemap index is written to {baseDir}/sitemap_index.xml
*/
public void writeSitemapsWithIndex() {
if (!finished) throw new RuntimeException("Sitemaps not generated yet; call write() first");
File outFile = new File(baseDir, "sitemap_index.xml");
SitemapIndexGenerator sig;
sig = new SitemapIndexGenerator.Options(baseUrl, outFile).dateFormat(dateFormat).autoValidate(autoValidate).build();
writeSitemapsWithIndex(outFile);
}
/**
* After you've called {@link #write()}, call this to generate a sitemap index of all sitemaps you generated.
*
* @param outFile the destination file of the sitemap index.
*/
public void writeSitemapsWithIndex(File outFile) {
if (!finished) throw new RuntimeException("Sitemaps not generated yet; call write() first");
SitemapIndexGenerator sig;
sig = new SitemapIndexGenerator.Options(baseUrl, outFile).dateFormat(dateFormat).autoValidate(autoValidate).build();
sig.addUrls(fileNamePrefix, fileNameSuffix, mapCount).write();
}