public
Last active

Create a controller and a generator to create your sitemap

  • Download Gist
RenderSitemap.java
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
package helpers;
 
public class RenderSitemap extends RenderSitemapXml {
public RenderSitemap(List<User> users) {
super(getDocument(users));
}
 
private static Document getDocument(List<User> users) {
 
Document doc = createSiteMapDocument();
Element root = doc.getDocumentElement();
addAnnotatedActions(doc);
for(User u : users) {
Map<String, Object> args = new HashMap<String, Object>();
args.put("userName", u.userName);
String loc = Router.getFullUrl("Application.showUser", args);
root.appendChild(createUrl(doc, loc, "weekly", 0.7));
}
 
return doc;
}
 
}
Sitemap.java
Java
1 2 3 4 5 6 7 8
package controllers;
 
public class Sitemap extends Controller {
public static void generate() {
List<User> users = User.findAll();
throw new RenderSitemap(users);
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.