diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..f61581c --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: java $JAVA_OPTS -jar ./target/spark-basic-structure-1.0-SNAPSHOT-jar-with-dependencies.jar diff --git a/pom.xml b/pom.xml index df42fd7..6c5c0a9 100644 --- a/pom.xml +++ b/pom.xml @@ -12,11 +12,34 @@ org.apache.maven.plugins maven-compiler-plugin + 3.7.0 1.8 1.8 + + maven-assembly-plugin + + + package + + single + + + + + + + jar-with-dependencies + + + + app.Application + + + + org.codehaus.mojo exec-maven-plugin @@ -27,6 +50,20 @@ + + com.heroku.sdk + heroku-maven-plugin + 1.2.2 + + 1.8 + + target/spark-basic-structure-1.0.BUILD-SNAPSHOT.jar + + + java -jar ./target/spark-basic-structure-1.0.BUILD-SNAPSHOT.jar + + + @@ -54,7 +91,7 @@ org.projectlombok lombok - 1.16.6 + 1.16.18 com.fasterxml.jackson.core @@ -76,6 +113,16 @@ jbcrypt 0.3m + + com.heroku.sdk + heroku-maven-plugin + 1.2.2 + - + + + projectlombok.org + http://projectlombok.org/mavenrepo + + diff --git a/src/main/java/app/Application.java b/src/main/java/app/Application.java index 521b35d..30c3b36 100644 --- a/src/main/java/app/Application.java +++ b/src/main/java/app/Application.java @@ -21,7 +21,7 @@ public static void main(String[] args) { userDao = new UserDao(); // Configure Spark - port(4567); + port(getHerokuAssignedPort()); staticFiles.location("/public"); staticFiles.expireTime(600L); enableDebugScreen(); @@ -37,11 +37,19 @@ public static void main(String[] args) { get(Path.Web.LOGIN, LoginController.serveLoginPage); post(Path.Web.LOGIN, LoginController.handleLoginPost); post(Path.Web.LOGOUT, LoginController.handleLogoutPost); + get(Path.Web.HOME, IndexController.serveIndexPage); get("*", ViewUtil.notFound); //Set up after-filters (called after each get/post) after("*", Filters.addGzipHeader); } + static int getHerokuAssignedPort() { + ProcessBuilder processBuilder = new ProcessBuilder(); + if (processBuilder.environment().get("PORT") != null) { + return Integer.parseInt(processBuilder.environment().get("PORT")); + } + return 4567; //return default port if heroku-port isn't set (i.e. on localhost) + } } diff --git a/src/main/java/app/util/Path.java b/src/main/java/app/util/Path.java index 32b7f66..49c6474 100644 --- a/src/main/java/app/util/Path.java +++ b/src/main/java/app/util/Path.java @@ -12,6 +12,7 @@ public static class Web { @Getter public static final String LOGOUT = "/logout/"; @Getter public static final String BOOKS = "/books/"; @Getter public static final String ONE_BOOK = "/books/:isbn/"; + @Getter public static final String HOME = "/"; } public static class Template { diff --git a/src/main/resources/localization/messages_de.properties b/src/main/resources/localization/messages_de.properties index 92504d6..d890e23 100644 --- a/src/main/resources/localization/messages_de.properties +++ b/src/main/resources/localization/messages_de.properties @@ -2,14 +2,14 @@ COMMON_TITLE=Ze Spark Library COMMON_FOOTER_TEXT=Ze application uses OpenLibrary vor images. COMMON_NAV_ALLBOOKS=View all ze books -COMMON_NAV_LOGIN=Innlogg -COMMON_NAV_LOGOUT=Auslogg +COMMON_NAV_LOGIN=Anmelden +COMMON_NAV_LOGOUT=Abmelden ERROR_406_NOT_ACCEPTABLE=No zuitable content found. Please zpecify eizer 'html/text' or 'application/json'. ERROR_404_NOT_FOUND=Ve cannot find ze page you are looking for (error 404) ## Index -INDEX_HEADING=Velcome to ze Spark Library +INDEX_HEADING=Willkommen in den Spark Bibliothek! INDEX_REGISTERED_USERS=Zere are currently {0} users registered: INDEX_PASSWORD_INFO=It seems zey have all chosen ze password "password" for some reason. Hov silly. INDEX_BOOK_OF_THE_DAY_TEXT=Ze book of ze day is: @@ -17,14 +17,14 @@ INDEX_BOOK_OF_THE_DAY_LINK={0} von {1} ## Login -LOGIN_HEADING=Innlogg -LOGIN_INSTRUCTIONS=Please enter dein username und password.
(Zee ze index page if you need a hint)
-LOGIN_AUTH_SUCCEEDED=You''re logged in as ''{0}''. +LOGIN_HEADING=Anmelden +LOGIN_INSTRUCTIONS=Bitte die Zugangsdaten eingeben!
(Zee ze index page if you need a hint)
+LOGIN_AUTH_SUCCEEDED=Sie sind als ''{0}'' angemeldet. LOGIN_AUTH_FAILED=Ze login informazion you zuplied vas incorrect. LOGIN_LOGGED_OUT=You have been logged aus. -LOGIN_LABEL_USERNAME=Username -LOGIN_LABEL_PASSWORD=Password -LOGIN_BUTTON_LOGIN=Innlogg +LOGIN_LABEL_USERNAME=BenutzerIn +LOGIN_LABEL_PASSWORD=Passwort +LOGIN_BUTTON_LOGIN=Anmelden ## Books