From 1688f4126c911e872e1510e5b8cc7e93723b48b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Wilmsmann?= Date: Mon, 23 Sep 2024 13:15:16 +0200 Subject: [PATCH] https://github.com/BjoernKW/Schematic/issues/82 --- README.md | 16 +++++++++++++-- docker-compose.yml => compose.yaml | 3 +-- pom.xml | 6 ++++++ .../bjoernkw/schematic/IndexController.java | 11 ++++++++-- .../schematic/SchematicProperties.java | 20 +++++++++++++++++++ .../bjoernkw/schematic/TablesController.java | 2 +- src/main/resources/application.yml | 2 ++ .../resources/templates/fragments/tables.html | 4 ++-- src/main/resources/templates/index.html | 2 +- .../resources/templates/layouts/layout.html | 14 ++++++------- 10 files changed, 63 insertions(+), 17 deletions(-) rename docker-compose.yml => compose.yaml (79%) diff --git a/README.md b/README.md index 97a3245..bc1403b 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ To use **Schematic**, you need to add the following Maven dependency to your pro com.bjoernkw schematic - 0.2.2 + 0.2.3 ``` @@ -25,13 +25,25 @@ If you're using Spring Boot 2.7.x and Java 11 you can add this version of **Sche com.bjoernkw schematic - 0.2.2.jre11 + 0.2.3.jre11 ``` After that, simply restart your Spring Boot application. **Schematic** will be available under http://localhost:8080/schematic/tables and show the database tables for the database connection configured for your application. +## Configuration Options + +In case you need to customise the root path of your application (the default is `/`) or the path +Schematic will run under (the default is `/schematic`), respectively, you can do so by adding the +following properties to your `application.yml` (or `application.properties`) file: + +``` +schematic: + path: custom-path-for-schematic + root-path: /MyApplication +``` + ### Screenshots ![Schematic-screenshot-1.png](documentation/static-resources/Schematic-screenshot-1.png) diff --git a/docker-compose.yml b/compose.yaml similarity index 79% rename from docker-compose.yml rename to compose.yaml index 4b3ae95..c0fc436 100644 --- a/docker-compose.yml +++ b/compose.yaml @@ -1,4 +1,3 @@ -version: '3.8' services: db: image: postgres:latest @@ -6,4 +5,4 @@ services: - POSTGRES_USER=postgres - POSTGRES_PASSWORD=postgres ports: - - "5432:5432" + - 5432:5432 diff --git a/pom.xml b/pom.xml index b9e0c98..7562f8c 100644 --- a/pom.xml +++ b/pom.xml @@ -104,6 +104,12 @@ runtime true + + org.springframework.boot + spring-boot-docker-compose + runtime + true + org.postgresql postgresql diff --git a/src/main/java/com/bjoernkw/schematic/IndexController.java b/src/main/java/com/bjoernkw/schematic/IndexController.java index 4f8d45e..84b1a84 100644 --- a/src/main/java/com/bjoernkw/schematic/IndexController.java +++ b/src/main/java/com/bjoernkw/schematic/IndexController.java @@ -1,15 +1,22 @@ package com.bjoernkw.schematic; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; @Controller @RequestMapping("/") public class IndexController { + @Value("${schematic.path}") + private String path; + @GetMapping - public String redirect() { - return "redirect:/schematic/tables"; + public String redirect(RedirectAttributes redirectAttributes) { + redirectAttributes.addAttribute("path", path); + + return "redirect:/{path}/tables"; } } diff --git a/src/main/java/com/bjoernkw/schematic/SchematicProperties.java b/src/main/java/com/bjoernkw/schematic/SchematicProperties.java index 8a9c7c2..6abd304 100644 --- a/src/main/java/com/bjoernkw/schematic/SchematicProperties.java +++ b/src/main/java/com/bjoernkw/schematic/SchematicProperties.java @@ -11,6 +11,10 @@ public class SchematicProperties { private String version = getClass().getPackage().getImplementationVersion(); + private String path; + + private String rootPath; + public String getName() { return name; } @@ -26,4 +30,20 @@ public String getVersion() { public void setVersion(String version) { this.version = version; } + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getRootPath() { + return rootPath; + } + + public void setRootPath(String rootPath) { + this.rootPath = rootPath; + } } diff --git a/src/main/java/com/bjoernkw/schematic/TablesController.java b/src/main/java/com/bjoernkw/schematic/TablesController.java index 415d621..39a54d2 100644 --- a/src/main/java/com/bjoernkw/schematic/TablesController.java +++ b/src/main/java/com/bjoernkw/schematic/TablesController.java @@ -21,7 +21,7 @@ import org.springframework.web.bind.annotation.RequestParam; @Controller -@RequestMapping("/schematic/tables") +@RequestMapping("/${schematic.path}/tables") public class TablesController { private static final Logger LOGGER = LoggerFactory.getLogger(TablesController.class); diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index aad87b4..33e3d08 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,6 +1,8 @@ schematic: name: @project.name@ version: @project.version@ + path: schematic + root-path: / spring: datasource: diff --git a/src/main/resources/templates/fragments/tables.html b/src/main/resources/templates/fragments/tables.html index 9099f9e..1a18c59 100644 --- a/src/main/resources/templates/fragments/tables.html +++ b/src/main/resources/templates/fragments/tables.html @@ -81,7 +81,7 @@

Truncate table "[[${table @@ -104,7 +104,7 @@

Drop table "[[${table.tabl diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 796cb89..103c933 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -24,7 +24,7 @@

-
diff --git a/src/main/resources/templates/layouts/layout.html b/src/main/resources/templates/layouts/layout.html index 59fbe4a..6af1ae8 100644 --- a/src/main/resources/templates/layouts/layout.html +++ b/src/main/resources/templates/layouts/layout.html @@ -14,15 +14,15 @@ - + - - - + + + - - - + + +