Skip to content
Permalink
Browse files

Initial commit.

  • Loading branch information...
jfendler committed Feb 20, 2016
1 parent 915875b commit 798e5c61dd94374128fe494c29376ec2c7c63d9c
@@ -10,3 +10,4 @@

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
/target/
168 pom.xml
@@ -0,0 +1,168 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.jensfendler</groupId>
<artifactId>ninja-sitemap</artifactId>
<packaging>jar</packaging>
<name>Ninja Sitemap Module</name>
<version>0.0.1-SNAPSHOT</version>
<description>Sitemap Generator Module for the Ninja Web Framework</description>
<url>http://www.jensfendler.com/</url>

<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>9</version>
</parent>

<properties>
<ninja.version>5.3.0</ninja.version>
<jetty.version>9.2.10.v20150310</jetty.version>
<jsitemapgenerator.version>2.1</jsitemapgenerator.version>
</properties>

<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>

<scm>
<url>https://github.com/FendlerConsulting/ninja-sitemap</url>
<connection>scm:git://github.com/FendlerConsulting/ninja-sitemap.git</connection>
<developerConnection>scm:git:git@github.com:jfendler/ninja-sitemap.git</developerConnection>
<tag>HEAD</tag>
</scm>

<developers>
<developer>
<id>1</id>
<name>Jens Fendler</name>
<email>jf@jensfendler.com</email>
</developer>
</developers>

<issueManagement>
<system>GitHub</system>
<url>https://github.com/FendlerConsulting/ninja-sitemap/issues</url>
</issueManagement>

<mailingLists>
<mailingList>
<name>Ninja Web Framework Users</name>
<post>ninja-framework@googlegroups.com</post>
<archive>http://groups.google.com/group/ninja-framework</archive>
</mailingList>
</mailingLists>


<dependencies>
<dependency>
<groupId>org.ninjaframework</groupId>
<artifactId>ninja-standalone</artifactId>
<version>${ninja.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.ninjaframework</groupId>
<artifactId>ninja-test-utilities</artifactId>
<version>${ninja.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<!-- Sitemap generation from https://github.com/jirkapinkas/jsitemapgenerator -->
<groupId>cz.jiripinkas</groupId>
<artifactId>jsitemapgenerator</artifactId>
<version>${jsitemapgenerator.version}</version>
</dependency>

</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

<profiles>
<!-- Do a license check by running : mvn -P license license:check -->
<!-- Update the license check by running : mvn -P license license:format -->
<profile>
<id>license</id>
<build>
<plugins>
<plugin>
<groupId>com.mycila.maven-license-plugin</groupId>
<artifactId>maven-license-plugin</artifactId>
<version>1.6.0</version>
<configuration>
<quiet>false</quiet>
<header>src/main/resources/LICENSE-2.0.txt</header>
<aggregate>true</aggregate>
<includes>
<include>**/src/**</include>
<include>**/pom.xml</include>
</includes>
<excludes>
<!-- ignore files produced during a build -->
<exclude>**/target/**</exclude>
<exclude>**/WEB-INF/classes/**</exclude>
<exclude>**/site/**</exclude>
<exclude>**/.DS_Store</exclude>

<!-- ignore binary files -->
<exclude>**/assets/**</exclude>
<exclude>**/views/**</exclude>
</excludes>
<useDefaultExcludes>false</useDefaultExcludes>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
@@ -0,0 +1,41 @@
/*
* Copyright 2016 Fendler Consulting cc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jensfendler.ninjasitemap;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.inject.AbstractModule;
import com.google.inject.Singleton;

/**
* @author Jens Fendler
*
*/
public class NinjaSitemapModule extends AbstractModule {

static final Logger LOG = LoggerFactory.getLogger(NinjaSitemapModule.class);

/**
* @see com.google.inject.AbstractModule#configure()
*/
@Override
protected void configure() {
LOG.info("Initialising Ninja Sitemap.");
bind(SitemapRouteDetails.class).toProvider(SitemapRouteDetailsProvider.class).in(Singleton.class);
}

}
@@ -0,0 +1,47 @@
/*
* Copyright 2016 Fendler Consulting cc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jensfendler.ninjasitemap;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.jensfendler.ninjasitemap.controller.NinjaSitemapController;

import ninja.Router;
import ninja.application.ApplicationRoutes;
import ninja.utils.NinjaProperties;

/**
* @author Jens Fendler
*
*/
public class NinjaSitemapRoutes implements ApplicationRoutes {

private static final Logger LOG = LoggerFactory.getLogger(NinjaSitemapRoutes.class);

@SuppressWarnings("unused")
private NinjaProperties ninjaProperties;

/**
* @see ninja.application.ApplicationRoutes#init(ninja.Router)
*/
@Override
public void init(Router router) {
LOG.info("Installing Ninja Sitemap routes.");
router.GET().route("/sitemap.xml").with(NinjaSitemapController.class, "getSitemapXml");
}

}
@@ -0,0 +1,70 @@
/*
* Copyright 2016 Fendler Consulting cc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jensfendler.ninjasitemap;

import java.util.Date;

import com.jensfendler.ninjasitemap.annotations.Sitemap;

import ninja.Route;

/**
* Classes like this one (implementing the {@link SitemapRouteDetails}
* interface) can be provided by the developer to determine some parameters of
* the sitemap generation programmatically at runtime.
*
* To do this, developers should bind their own implementation to this
* interface, after installing the NinjaSitemapModule().
*
* @author Jens Fendler
*
*/
public class SimpleSitemapRouteDetails implements SitemapRouteDetails {

public SimpleSitemapRouteDetails() {
}

/**
* @see com.jensfendler.ninjasitemap.SitemapRouteDetails#getLastModifiedDateForRoute(com.jensfendler.ninjasitemap.annotations.Sitemap,
* ninja.Route)
*/
@Override
public Date getLastModifiedDateForRoute(Route route, Sitemap sitemapAnnotation) {
// assume the page has just been updated
return new Date();
}

/**
* @see com.jensfendler.ninjasitemap.SitemapRouteDetails#getPriorityForRoute(ninja.Route,
* com.jensfendler.ninjasitemap.annotations.Sitemap)
*/
@Override
public double getPriorityForRoute(Route route, Sitemap sitemap) {
// always use the default priority
return Sitemap.DEFAULT_PRIORITY;
}

/**
* @see com.jensfendler.ninjasitemap.SitemapRouteDetails#getChangeFrequencyForRoute(ninja.Route,
* com.jensfendler.ninjasitemap.annotations.Sitemap)
*/
@Override
public int getChangeFrequencyForRoute(Route route, Sitemap sitemap) {
// always use the default frequency
return Sitemap.DEFAULT_CHANGE_FREQUENCY;
}

}

0 comments on commit 798e5c6

Please sign in to comment.
You can’t perform that action at this time.