make it runnable

This commit is contained in:
Minecon724 2024-09-11 16:10:22 +02:00
parent 8cbbaca653
commit 5c87e3d86d
Signed by: Minecon724
GPG key ID: 3CCC4D267742C8E8
3 changed files with 25 additions and 6 deletions

View file

@ -20,14 +20,27 @@ public class Startup {
@ConfigProperty(name = "talkpages.systemUser.name") @ConfigProperty(name = "talkpages.systemUser.name")
private String username; private String username;
@ConfigProperty(name = "talkpages.createExamplePage")
private boolean createExamplePage;
@Transactional @Transactional
public void examplePage(@Observes StartupEvent ignoredEvent) { 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 account = new Account(username);
//account.id = 0L;
account.persistAndFlush(); account.persistAndFlush();
addPage(account, "TalkPages", "<p>A website where the users collaboratively create content</p><ul><li><a href=\"https://git.m724.eu/Minecon724/talkpages\">Source code</a></li></ul>"); if (createExamplePage) {
addPage(account, "Talkpages", "ambiguous for [TalkPages]"); addPage(account, "TalkPages", "<p>A website where the users collaboratively create content</p><ul><li><a href=\"https://git.m724.eu/Minecon724/talkpages\">Source code</a></li></ul>");
addPage(account, "TP", "@TalkPages"); addPage(account, "Talkpages", "ambiguous for [TalkPages]");
addPage(account, "TP", "@TalkPages");
}
} }
@Transactional @Transactional

View file

@ -37,7 +37,6 @@ public class PageResource {
@GET @GET
@Path("/{pageId}") @Path("/{pageId}")
public Response viewPage(@PathParam("pageId") String pageId, @QueryParam("revision") Integer revisionId, @QueryParam("redirectFrom") String redirectFrom) { public Response viewPage(@PathParam("pageId") String pageId, @QueryParam("revision") Integer revisionId, @QueryParam("redirectFrom") String redirectFrom) {
System.out.println(pageId);
Page page = Page.findByTitle(pageId); Page page = Page.findByTitle(pageId);
if (page == null) { if (page == null) {
@ -57,7 +56,6 @@ public class PageResource {
} }
return Response.ok().entity(Templates.page(page, page.latestRevision, false)).build(); return Response.ok().entity(Templates.page(page, page.latestRevision, false)).build();
} else { } else {
System.out.printf("History for page: %s %d\n", page.title, page.latestRevision.index);
PageRevision revision = PageRevision.findByIndex(page, revisionId); PageRevision revision = PageRevision.findByIndex(page, revisionId);
if (revision != null) { if (revision != null) {
return Response.ok().entity(Templates.page(page, revision, true)).build(); return Response.ok().entity(Templates.page(page, revision, true)).build();

View file

@ -1,2 +1,10 @@
talkpages.homePage=/ talkpages.homePage=/
talkpages.systemUser.name=System 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