Java Code Examples for com.redfin.sitemapgenerator.WebSitemapGenerator#addUrl()

The following examples show how to use com.redfin.sitemapgenerator.WebSitemapGenerator#addUrl() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StubbornJavaSitemapGenerator.java    From StubbornJava with MIT License 6 votes vote down vote up
private static List<String> genRecommendations() throws MalformedURLException {
    WebSitemapGenerator wsg = new WebSitemapGenerator(HOST);
    List<String> recommendations = Lists.newArrayList(
        "java-libraries"
        , "best-selling-html-css-themes-and-website-templates"
    );
    for (String recommendation : recommendations) {
        String url = HttpUrl.parse(HOST)
                            .newBuilder()
                            .addPathSegment(recommendation)
                            .build()
                            .toString();
        wsg.addUrl(url);
    }
    return wsg.writeAsStrings();
}
 
Example 2
Source File: StubbornJavaSitemapGenerator.java    From StubbornJava with MIT License 6 votes vote down vote up
private static List<String> genRecommendations() throws MalformedURLException {
    WebSitemapGenerator wsg = new WebSitemapGenerator(HOST);
    List<String> recommendations = Lists.newArrayList(
        "java-libraries"
        , "best-selling-html-css-themes-and-website-templates"
    );
    for (String recommendation : recommendations) {
        String url = HttpUrl.parse(HOST)
                            .newBuilder()
                            .addPathSegment(recommendation)
                            .build()
                            .toString();
        wsg.addUrl(url);
    }
    return wsg.writeAsStrings();
}
 
Example 3
Source File: AnnotationUrlProvider.java    From play-sitemap-module.edulify.com with Apache License 2.0 6 votes vote down vote up
@Override
public void addUrlsTo(WebSitemapGenerator generator) {
  String baseUrl = configuration.getString("sitemap.baseUrl");

  ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
  Reflections reflections = new Reflections("controllers", new MethodAnnotationsScanner());

  Set<Method> actions = reflections.getMethodsAnnotatedWith(SitemapItem.class);
  for(Method method : actions) {
    String actionUrl = actionUrl(classLoader, method);
    SitemapItem annotation = method.getAnnotation(SitemapItem.class);
    if(annotation != null) {
      WebSitemapUrl url = webSitemapUrl(baseUrl, actionUrl, annotation);
      generator.addUrl(url);
    }
  }
}
 
Example 4
Source File: StubbornJavaSitemapGenerator.java    From StubbornJava with MIT License 5 votes vote down vote up
private static List<String> genPosts() throws MalformedURLException {
    WebSitemapGenerator wsg = new WebSitemapGenerator(HOST);
    List<String> slugs = Posts.getAllSlugs();
    for (String slug: slugs) {
        String url = HttpUrl.parse(HOST)
                            .newBuilder()
                            .addPathSegment("posts")
                            .addPathSegment(slug)
                            .build()
                            .toString();
        wsg.addUrl(url);
    }
    return wsg.writeAsStrings();
}
 
Example 5
Source File: StubbornJavaSitemapGenerator.java    From StubbornJava with MIT License 5 votes vote down vote up
private static List<String> genGuides() throws MalformedURLException {
    WebSitemapGenerator wsg = new WebSitemapGenerator(HOST);
    List<GuideTitle> guides = Guides.findTitles();
    for (GuideTitle guide : guides) {
        String url = HttpUrl.parse(HOST)
                            .newBuilder()
                            .addPathSegment("guides")
                            .addPathSegment(guide.getSlug())
                            .build()
                            .toString();
        wsg.addUrl(url);
    }
    return wsg.writeAsStrings();
}
 
Example 6
Source File: StubbornJavaSitemapGenerator.java    From StubbornJava with MIT License 5 votes vote down vote up
private static List<String> genTags() throws MalformedURLException {
    WebSitemapGenerator wsg = new WebSitemapGenerator(HOST);
    List<Tag> tags = Tags.getTags();
    for (Tag tag : tags) {
        String url = HttpUrl.parse(HOST)
                            .newBuilder()
                            .addPathSegment("tags")
                            .addPathSegment(tag.getName())
                            .addEncodedPathSegment("posts")
                            .build()
                            .toString();
        wsg.addUrl(url);
    }
    return wsg.writeAsStrings();
}
 
Example 7
Source File: StubbornJavaSitemapGenerator.java    From StubbornJava with MIT License 5 votes vote down vote up
private static List<String> genLibraries() throws MalformedURLException {
    WebSitemapGenerator wsg = new WebSitemapGenerator(HOST);
    List<JavaLib> libraries = Seq.of(JavaLib.values()).toList();
    for (JavaLib lib : libraries) {
        String url = HttpUrl.parse(HOST)
                            .newBuilder()
                            .addPathSegment("java-libraries")
                            .addPathSegment(lib.getName())
                            .build()
                            .toString();
        wsg.addUrl(url);
    }
    return wsg.writeAsStrings();
}
 
Example 8
Source File: StubbornJavaSitemapGenerator.java    From StubbornJava with MIT License 5 votes vote down vote up
private static List<String> genPosts() throws MalformedURLException {
    WebSitemapGenerator wsg = new WebSitemapGenerator(HOST);
    List<String> slugs = Posts.getAllSlugs();
    for (String slug: slugs) {
        String url = HttpUrl.parse(HOST)
                            .newBuilder()
                            .addPathSegment("posts")
                            .addPathSegment(slug)
                            .build()
                            .toString();
        wsg.addUrl(url);
    }
    return wsg.writeAsStrings();
}
 
Example 9
Source File: StubbornJavaSitemapGenerator.java    From StubbornJava with MIT License 5 votes vote down vote up
private static List<String> genGuides() throws MalformedURLException {
    WebSitemapGenerator wsg = new WebSitemapGenerator(HOST);
    List<GuideTitle> guides = Guides.findTitles();
    for (GuideTitle guide : guides) {
        String url = HttpUrl.parse(HOST)
                            .newBuilder()
                            .addPathSegment("guides")
                            .addPathSegment(guide.getSlug())
                            .build()
                            .toString();
        wsg.addUrl(url);
    }
    return wsg.writeAsStrings();
}
 
Example 10
Source File: StubbornJavaSitemapGenerator.java    From StubbornJava with MIT License 5 votes vote down vote up
private static List<String> genTags() throws MalformedURLException {
    WebSitemapGenerator wsg = new WebSitemapGenerator(HOST);
    List<Tag> tags = Tags.getTags();
    for (Tag tag : tags) {
        String url = HttpUrl.parse(HOST)
                            .newBuilder()
                            .addPathSegment("tags")
                            .addPathSegment(tag.getName())
                            .addEncodedPathSegment("posts")
                            .build()
                            .toString();
        wsg.addUrl(url);
    }
    return wsg.writeAsStrings();
}
 
Example 11
Source File: StubbornJavaSitemapGenerator.java    From StubbornJava with MIT License 5 votes vote down vote up
private static List<String> genLibraries() throws MalformedURLException {
    WebSitemapGenerator wsg = new WebSitemapGenerator(HOST);
    List<JavaLib> libraries = Seq.of(JavaLib.values()).toList();
    for (JavaLib lib : libraries) {
        String url = HttpUrl.parse(HOST)
                            .newBuilder()
                            .addPathSegment("java-libraries")
                            .addPathSegment(lib.getName())
                            .build()
                            .toString();
        wsg.addUrl(url);
    }
    return wsg.writeAsStrings();
}
 
Example 12
Source File: SitemapTest.java    From jakduk-api with MIT License 5 votes vote down vote up
@Test
public void generateSitemap() {
    try {
        WebSitemapGenerator wsg = new WebSitemapGenerator("https://jakduk.com");
        WebSitemapUrl url = new WebSitemapUrl.Options("https://jakduk.com/board/free/1")
                .lastMod(new Date()).priority(1.0).changeFreq(ChangeFreq.DAILY).build();

        wsg.addUrl(url);

        Assert.assertTrue(! ObjectUtils.isEmpty(wsg.writeAsStrings()));

    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
}