make it runnable
This commit is contained in:
		
					parent
					
						
							
								8cbbaca653
							
						
					
				
			
			
				commit
				
					
						5c87e3d86d
					
				
			
		
					 3 changed files with 25 additions and 6 deletions
				
			
		| 
						 | 
					@ -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
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue