mirror of
https://github.com/ethauvin/rife2-bld-hello.git
synced 2025-04-28 10:08:13 -07:00
Initial bld bootstrap template
This commit is contained in:
parent
01dc74fdb0
commit
0c13c8b968
30 changed files with 647 additions and 0 deletions
42
src/bld/java/hello/AppBuild.java
Normal file
42
src/bld/java/hello/AppBuild.java
Normal file
|
@ -0,0 +1,42 @@
|
|||
package hello;
|
||||
|
||||
import rife.bld.WebProject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static rife.bld.dependencies.Repository.*;
|
||||
import static rife.bld.dependencies.Scope.*;
|
||||
import static rife.bld.operations.TemplateType.*;
|
||||
|
||||
public class AppBuild extends WebProject {
|
||||
public AppBuild() {
|
||||
pkg = "hello";
|
||||
name = "App";
|
||||
mainClass = "hello.AppSite";
|
||||
uberJarMainClass = "hello.AppSiteUber";
|
||||
version = version(0,1,0);
|
||||
archiveBaseName = "hello";
|
||||
|
||||
downloadSources = true;
|
||||
autoDownloadPurge = true;
|
||||
|
||||
repositories = List.of(MAVEN_CENTRAL, RIFE2_RELEASES);
|
||||
scope(compile)
|
||||
.include(dependency("com.uwyn.rife2", "rife2", version(1,5,22)));
|
||||
scope(test)
|
||||
.include(dependency("org.jsoup", "jsoup", version(1,15,4)))
|
||||
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5,9,2)))
|
||||
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1,9,2)));
|
||||
scope(standalone)
|
||||
.include(dependency("org.eclipse.jetty", "jetty-server", version(11,0,15)))
|
||||
.include(dependency("org.eclipse.jetty", "jetty-servlet", version(11,0,15)))
|
||||
.include(dependency("org.slf4j", "slf4j-simple", version(2,0,7)));
|
||||
|
||||
precompileOperation()
|
||||
.templateTypes(HTML);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new AppBuild().start(args);
|
||||
}
|
||||
}
|
16
src/main/java/hello/AppSite.java
Normal file
16
src/main/java/hello/AppSite.java
Normal file
|
@ -0,0 +1,16 @@
|
|||
package hello;
|
||||
|
||||
import rife.engine.*;
|
||||
|
||||
public class AppSite extends Site {
|
||||
public void setup() {
|
||||
var hello = get("/hello", c -> c.print(c.template("hello")));
|
||||
get("/", c -> c.redirect(hello));
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new Server()
|
||||
.staticResourceBase("src/main/webapp")
|
||||
.start(new AppSite());
|
||||
}
|
||||
}
|
11
src/main/java/hello/AppSiteUber.java
Normal file
11
src/main/java/hello/AppSiteUber.java
Normal file
|
@ -0,0 +1,11 @@
|
|||
package hello;
|
||||
|
||||
import rife.engine.Server;
|
||||
|
||||
public class AppSiteUber extends AppSite {
|
||||
public static void main(String[] args) {
|
||||
new Server()
|
||||
.staticUberJarResourceBase("webapp")
|
||||
.start(new AppSiteUber());
|
||||
}
|
||||
}
|
11
src/main/resources/templates/hello.html
Normal file
11
src/main/resources/templates/hello.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title><!--v title-->Hello App<!--/v--></title>
|
||||
<link rel="stylesheet" href="{{v webapp:rootUrl/}}css/style.css?{{v context:paramRandom/}}">
|
||||
</head>
|
||||
<body>
|
||||
<p>Hello World App</p>
|
||||
</body>
|
||||
</html>
|
18
src/main/webapp/WEB-INF/web.xml
Normal file
18
src/main/webapp/WEB-INF/web.xml
Normal file
|
@ -0,0 +1,18 @@
|
|||
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
|
||||
version="4.0">
|
||||
<filter>
|
||||
<filter-name>RIFE2</filter-name>
|
||||
<filter-class>rife.servlet.RifeFilter</filter-class>
|
||||
<init-param>
|
||||
<param-name>rifeSiteClass</param-name>
|
||||
<param-value>hello.AppSite</param-value>
|
||||
</init-param>
|
||||
</filter>
|
||||
|
||||
<filter-mapping>
|
||||
<filter-name>RIFE2</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</filter-mapping>
|
||||
</web-app>
|
21
src/main/webapp/css/style.css
Normal file
21
src/main/webapp/css/style.css
Normal file
|
@ -0,0 +1,21 @@
|
|||
:root {
|
||||
/* fonts */
|
||||
--main-font: sans-serif;
|
||||
|
||||
/* font sizes */
|
||||
--main-font-size: 18px;
|
||||
|
||||
/* colors */
|
||||
--main-background-color: #0d0d0d;
|
||||
--main-text-color: #d0d0d0;
|
||||
|
||||
/* margins and padding */
|
||||
--content-padding: 2em;
|
||||
}
|
||||
body {
|
||||
background: var(--main-background-color);
|
||||
font-family: var(--main-font);
|
||||
font-style: var(--main-font-size);
|
||||
color: var(--main-text-color);
|
||||
padding: var(--content-padding);
|
||||
}
|
21
src/test/java/hello/AppTest.java
Normal file
21
src/test/java/hello/AppTest.java
Normal file
|
@ -0,0 +1,21 @@
|
|||
package hello;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import rife.test.MockConversation;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class AppTest {
|
||||
@Test
|
||||
void verifyRoot() {
|
||||
var m = new MockConversation(new AppSite());
|
||||
assertEquals(m.doRequest("/").getStatus(), 302);
|
||||
}
|
||||
|
||||
@Test
|
||||
void verifyHello() {
|
||||
var m = new MockConversation(new AppSite());
|
||||
assertEquals("Hello App", m.doRequest("/hello")
|
||||
.getTemplate().getValue("title"));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue