Initial bld bootstrap template

This commit is contained in:
Geert Bevin 2023-04-18 11:53:34 -04:00
parent 01dc74fdb0
commit 0c13c8b968
30 changed files with 647 additions and 0 deletions

View 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);
}
}

View 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());
}
}

View 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());
}
}

View 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>

View 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>

View 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);
}

View 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"));
}
}