mirror of
https://github.com/sismics/docs.git
synced 2024-11-14 10:27:55 +01:00
#79: Resource to generate a dynamic CSS
This commit is contained in:
parent
274512a58e
commit
8ad9c529b6
@ -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();
|
||||
}
|
||||
}
|
@ -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 = {
|
||||
|
@ -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 = {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user