summaryrefslogtreecommitdiff
path: root/src/com/p4square/grow/frontend/GrowFrontend.java
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2013-08-04 16:09:29 -0700
committerJesse Morgan <jesse@jesterpm.net>2013-08-04 16:09:29 -0700
commit52539d7aaba96b7997a3c5a07e4a1ad234af7d04 (patch)
tree2686f56bc37656c0824a05e28472f7334ed39028 /src/com/p4square/grow/frontend/GrowFrontend.java
parent69e2512750dd75fce43a21226979996c3cd7da1d (diff)
Committing everything since its long overdue.
Diffstat (limited to 'src/com/p4square/grow/frontend/GrowFrontend.java')
-rw-r--r--src/com/p4square/grow/frontend/GrowFrontend.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/com/p4square/grow/frontend/GrowFrontend.java b/src/com/p4square/grow/frontend/GrowFrontend.java
index 226929d..74cd704 100644
--- a/src/com/p4square/grow/frontend/GrowFrontend.java
+++ b/src/com/p4square/grow/frontend/GrowFrontend.java
@@ -4,8 +4,14 @@
package com.p4square.grow.frontend;
+import java.io.File;
+import java.io.IOException;
+
+import org.restlet.Application;
import org.restlet.Component;
+import org.restlet.Restlet;
import org.restlet.data.Protocol;
+import org.restlet.resource.Directory;
import org.restlet.routing.Router;
import org.apache.log4j.Logger;
@@ -71,6 +77,8 @@ public class GrowFrontend extends FMFacade {
final Router accountRouter = new Router(getContext());
accountRouter.attach("/assessment/question/{questionId}", SurveyPageResource.class);
accountRouter.attach("/assessment", SurveyPageResource.class);
+ accountRouter.attach("/training/{chapter}", TrainingPageResource.class);
+ accountRouter.attach("/training", TrainingPageResource.class);
final LoginAuthenticator accountGuard =
new LoginAuthenticator(getContext(), false, loginPage);
@@ -88,6 +96,17 @@ public class GrowFrontend extends FMFacade {
final Component component = new Component();
component.getServers().add(Protocol.HTTP, 8085);
component.getClients().add(Protocol.HTTP);
+ component.getClients().add(Protocol.FILE);
+
+ // Static content
+ try {
+ component.getDefaultHost().attach("/images/", new FileServingApp("./build/images/"));
+ component.getDefaultHost().attach("/scripts", new FileServingApp("./build/scripts"));
+ component.getDefaultHost().attach("/style.css", new FileServingApp("./build/style.css"));
+ } catch (IOException e) {
+ cLog.error("Could not create directory for static resources: "
+ + e.getMessage(), e);
+ }
// Setup App
GrowFrontend app = new GrowFrontend();
@@ -119,4 +138,17 @@ public class GrowFrontend extends FMFacade {
cLog.fatal("Could not start: " + e.getMessage(), e);
}
}
+
+ private static class FileServingApp extends Application {
+ private final String mPath;
+
+ public FileServingApp(String path) throws IOException {
+ mPath = new File(path).getAbsolutePath();
+ }
+
+ @Override
+ public Restlet createInboundRoot() {
+ return new Directory(getContext(), "file://" + mPath);
+ }
+ }
}