make it runnable
This commit is contained in:
parent
8cbbaca653
commit
5c87e3d86d
3 changed files with 25 additions and 6 deletions
|
@ -20,15 +20,28 @@ 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();
|
||||
|
||||
if (createExamplePage) {
|
||||
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, "Talkpages", "ambiguous for [TalkPages]");
|
||||
addPage(account, "TP", "@TalkPages");
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void addPage(Account account, String title, String content) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -1,2 +1,10 @@
|
|||
talkpages.homePage=/
|
||||
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
|
Loading…
Reference in a new issue