added theme

This commit is contained in:
Sebastian Sdorra
2011-09-13 14:50:01 +02:00
parent 38699d802c
commit 29539eb22b
10 changed files with 1298 additions and 133 deletions

View File

@@ -77,7 +77,10 @@ public class ScmBackendModule extends ServletModule
public static final String FILE_CONFIG = "config.xml";
/** Field description */
public static final String PATTERN_API = "/*";
public static final String PATTERN_API = "/api/*";
/** Field description */
public static final String PATTERN_PAGE = "/page/*";
//~--- methods --------------------------------------------------------------
@@ -118,7 +121,7 @@ public class ScmBackendModule extends ServletModule
params.put(PackagesResourceConfig.PROPERTY_PACKAGES,
"sonia.scm.plugin.rest");
serve(PATTERN_API).with(GuiceContainer.class, params);
serve(PATTERN_API, PATTERN_PAGE).with(GuiceContainer.class, params);
}
/**

View File

@@ -48,10 +48,11 @@ import com.sun.jersey.api.view.Viewable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletContext;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
@@ -63,18 +64,21 @@ import javax.ws.rs.core.Response.Status;
* @author Sebastian Sdorra
*/
@Path("/detail/{groupId}/{artifactId}.html")
public class DetailResource
public class DetailResource extends ViewableResource
{
/**
* Constructs ...
*
*
*
* @param context
* @param backend
*/
@Inject
public DetailResource(PluginBackend backend)
public DetailResource(ServletContext context, PluginBackend backend)
{
super(context);
this.backend = backend;
}
@@ -104,9 +108,10 @@ public class DetailResource
Collections.sort(pluginVersions, PluginInformationComparator.INSTANCE);
pluginVersions = filterSameVersions(pluginVersions);
Map<String, Object> vars = new HashMap<String, Object>();
PluginInformation latest = pluginVersions.get(0);
Map<String, Object> vars = createVarMap(latest.getName());
vars.put("latest", pluginVersions.get(0));
vars.put("latest", latest);
vars.put("versions", pluginVersions);
return new Viewable("/detail", vars);

View File

@@ -47,10 +47,11 @@ import com.sun.jersey.api.view.Viewable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletContext;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
@@ -59,18 +60,21 @@ import javax.ws.rs.Path;
* @author Sebastian Sdorra
*/
@Path("/index.html")
public class OverviewResource
public class OverviewResource extends ViewableResource
{
/**
* Constructs ...
*
*
*
* @param context
* @param backend
*/
@Inject
public OverviewResource(PluginBackend backend)
public OverviewResource(ServletContext context, PluginBackend backend)
{
super(context);
this.backend = backend;
}
@@ -86,7 +90,7 @@ public class OverviewResource
public Viewable overview()
{
List<PluginInformation> plugins = getPluginOverview();
Map<String, Object> vars = new HashMap<String, Object>();
Map<String, Object> vars = createVarMap("Plugin Overview");
vars.put("plugins", plugins);

View File

@@ -74,7 +74,7 @@ import javax.ws.rs.core.Response;
* @author Sebastian Sdorra
*/
@Singleton
@Path("api/{version}/plugins")
@Path("{version}/plugins")
public class PluginResource implements PluginBackendListener
{

View File

@@ -0,0 +1,85 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.plugin.rest;
//~--- JDK imports ------------------------------------------------------------
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletContext;
/**
*
* @author Sebastian Sdorra
*/
public class ViewableResource
{
/**
* Constructs ...
*
*
* @param context
*/
public ViewableResource(ServletContext context)
{
this.contextPath = context.getContextPath();
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
*
* @param title
* @return
*/
protected Map<String, Object> createVarMap(String title)
{
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("contextPath", contextPath);
vars.put("title", title);
return vars;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private String contextPath;
}