diff --git a/src/main/java/eu/m724/talkpages/Startup.java b/src/main/java/eu/m724/talkpages/Startup.java index f1212d2..2e2ccc6 100644 --- a/src/main/java/eu/m724/talkpages/Startup.java +++ b/src/main/java/eu/m724/talkpages/Startup.java @@ -20,14 +20,27 @@ public class Startup { @ConfigProperty(name = "talkpages.systemUser.name") private String username; + @ConfigProperty(name = "talkpages.createExamplePage") + private boolean createExamplePage; + @Transactional public void examplePage(@Observes StartupEvent ignoredEvent) { + if (Account.findById(1) != null) { + // system user exists so assuming this is not the first run + return; + } + + System.out.println("Performing first run setup"); + Account account = new Account(username); + //account.id = 0L; account.persistAndFlush(); - addPage(account, "TalkPages", "

A website where the users collaboratively create content

"); - addPage(account, "Talkpages", "ambiguous for [TalkPages]"); - addPage(account, "TP", "@TalkPages"); + if (createExamplePage) { + addPage(account, "TalkPages", "

A website where the users collaboratively create content

"); + addPage(account, "Talkpages", "ambiguous for [TalkPages]"); + addPage(account, "TP", "@TalkPages"); + } } @Transactional diff --git a/src/main/java/eu/m724/talkpages/page/PageResource.java b/src/main/java/eu/m724/talkpages/page/PageResource.java index 21b720f..6e4eb59 100644 --- a/src/main/java/eu/m724/talkpages/page/PageResource.java +++ b/src/main/java/eu/m724/talkpages/page/PageResource.java @@ -37,7 +37,6 @@ public class PageResource { @GET @Path("/{pageId}") public Response viewPage(@PathParam("pageId") String pageId, @QueryParam("revision") Integer revisionId, @QueryParam("redirectFrom") String redirectFrom) { - System.out.println(pageId); Page page = Page.findByTitle(pageId); if (page == null) { @@ -57,7 +56,6 @@ public class PageResource { } return Response.ok().entity(Templates.page(page, page.latestRevision, false)).build(); } else { - System.out.printf("History for page: %s %d\n", page.title, page.latestRevision.index); PageRevision revision = PageRevision.findByIndex(page, revisionId); if (revision != null) { return Response.ok().entity(Templates.page(page, revision, true)).build(); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 6d0a85c..36dcfc0 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,2 +1,10 @@ talkpages.homePage=/ -talkpages.systemUser.name=System \ No newline at end of file +talkpages.systemUser.name=System +talkpages.createExamplePage=true + +quarkus.hibernate-orm.database.generation=drop-and-create + +quarkus.datasource.db-kind=h2 +quarkus.datasource.username=username-default +quarkus.datasource.jdbc.url=jdbc:h2:mem:default +quarkus.datasource.jdbc.max-size=13 \ No newline at end of file