#79: Resource to generate a dynamic CSS

This commit is contained in:
jendib 2016-04-09 21:23:55 +02:00
parent 274512a58e
commit 8ad9c529b6
4 changed files with 52 additions and 0 deletions

View File

@ -0,0 +1,29 @@
package com.sismics.docs.rest.resource;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
/**
* Theme REST resources.
*
* @author bgamard
*/
@Path("/theme")
public class ThemeResource extends BaseResource {
/**
* Returns custom CSS stylesheet.
*
* @return Response
*/
@GET
@Path("/stylesheet")
@Produces("text/css")
public Response stylesheet() {
StringBuilder sb = new StringBuilder();
sb.append("body {\n");
sb.append("}");
return Response.ok().entity(sb.toString()).build();
}
}

View File

@ -10,6 +10,7 @@
<link rel="stylesheet" href="style/colorpicker.css" type="text/css" />
<link rel="stylesheet/less" href="style/main.less" type="text/css" />
<!-- endref -->
<link rel="stylesheet" href="../api/theme/stylesheet" type="text/css" />
<!-- ref:remove -->
<script>
less = {

View File

@ -9,6 +9,7 @@
<link rel="stylesheet" href="style/bootstrap.css" type="text/css" />
<link rel="stylesheet/less" href="style/main.less" type="text/css" />
<!-- endref -->
<link rel="stylesheet" href="../api/theme/stylesheet" type="text/css" />
<!-- ref:remove -->
<script>
less = {

View File

@ -0,0 +1,21 @@
package com.sismics.docs.rest;
import org.junit.Test;
/**
* Test the theme resource.
*
* @author bgamard
*/
public class TestThemeResource extends BaseJerseyTest {
/**
* Test the theme resource.
*/
@Test
public void testThemeResource() {
// Get the stylesheet anonymously
String stylesheet = target().path("/theme/stylesheet").request()
.get(String.class);
System.out.println(stylesheet);
}
}