19 package org.turro.elephant.sitemap;
21 import java.io.IOException;
22 import java.util.Collection;
23 import java.util.logging.Level;
24 import java.util.logging.Logger;
25 import org.apache.commons.io.output.FileWriterWithEncoding;
26 import org.apache.commons.text.StringEscapeUtils;
27 import org.turro.elephant.context.ElephantContext;
28 import org.turro.elephant.impl.util.Files;
36 private final FileWriterWithEncoding writer;
45 }
catch (IOException ex) {
54 writeEntry(link.getUrl(), link.getImages());
60 private void writeEntry(String url, Collection<String> imgs)
throws IOException {
61 url = StringEscapeUtils.escapeHtml4(url);
65 if(imgs !=
null)
for(String img : imgs) {
66 img = StringEscapeUtils.escapeHtml4(img);
70 " <image:caption>" +
Files.
file(img).getName() +
"</image:caption>\n" +
73 writer.write(
" </url>\n");
76 private void writeHeader() throws IOException {
78 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
79 "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" \n" +
80 " xmlns:image=\"http://www.google.com/schemas/sitemap-image/1.1\" \n" +
81 " xmlns:video=\"http://www.google.com/schemas/sitemap-video/1.1\">\n");
84 private void writeFooter() throws IOException {
85 writer.write(
"</urlset>");
static String getRealPath(String path)
static String getServerBase(String scheme)
static String logMsg(String msg)
static File file(IConstructor constructor, String file)
static void generateSitemap()
static Collection< SitemapLink > getSitemapLinks()