Created
April 13, 2011 15:36
-
-
Save steren/917767 to your computer and use it in GitHub Desktop.
Create a controller and a generator to create your sitemap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package controllers; | |
public class Sitemap extends Controller { | |
public static void generate() { | |
List<User> users = User.findAll(); | |
throw new RenderSitemap(users); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment