GithubHelp home page GithubHelp logo

ajaquet / jsitemapgenerator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jirkapinkas/jsitemapgenerator

0.0 1.0 0.0 72 KB

Java sitemap generator. This library generates a web sitemap and can ping Google that it has changed.

Home Page: http://jsitemapgenerator.jiripinkas.cz/

License: BSD 3-Clause "New" or "Revised" License

Java 100.00%

jsitemapgenerator's Introduction

Java sitemap generator

This library generates a web sitemap and can ping Google that it has changed. This project has been inspired by sitemapgen4j, but is much more focused on traditional web sitemap and ease of use.

Typical usage:

First add this library to classpath:


<dependency>
  <groupId>cz.jiripinkas</groupId>
  <artifactId>jsitemapgenerator</artifactId>
  <version>2.1</version>
</dependency>

If you want to use "ping google / bing" functionality, also add this library to classpath:


<dependency>
  <groupId>org.apache.httpcomponents</groupId>
  <artifactId>httpclient</artifactId>
  <version>4.2.2</version>
</dependency>

How to create a sitemap:


// create web sitemap for web http://www.javavids.com
SitemapGenerator sitemapGenerator = new SitemapGenerator("http://www.javavids.com");
// add some URLs
sitemapGenerator.addPage(new WebPageBuilder().name("index.php")
   .priorityMax().changeFreqNever().lastModNow().build());
sitemapGenerator.addPage(new WebPageBuilder().name("latest.php").build());
sitemapGenerator.addPage(new WebPageBuilder().name("contact.php").build());
// generate sitemap and save it to file /var/www/sitemap.xml
File file = new File("/var/www/sitemap.xml");
sitemapGenerator.constructAndSaveSitemap(file);
// inform Google that this sitemap has changed
sitemapGenerator.pingGoogle();

How to create a sitemap index:


SitemapIndexGenerator sitemapIndexGenerator = new SitemapIndexGenerator("http://javalibs.com");
sitemapIndexGenerator.addPage(new WebPageBuilder().name("sitemap-plugins.xml").build());
sitemapIndexGenerator.addPage(new WebPageBuilder().name("sitemap-archetypes.xml").build());
System.out.println(sitemapIndexGenerator.constructSitemapString());

How to create RSS channel:


RssGenerator rssGenerator = new RssGenerator("http://www.topjavablogs", 
                                             "Top Java Blogs", "Best Java Blogs");
rssGenerator.addPage(new RssItemBuilder().pubDate(new Date()).title("News Title")
                        .description("News Description").name("page-name").build());
System.out.println(rssGenerator.constructRss());

My other projects:

jsitemapgenerator's People

Contributors

jirkapinkas avatar jfendler avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.