Skip to content

Commit

Permalink
clean (ui): Drop /entity/ from URL
Browse files Browse the repository at this point in the history
  • Loading branch information
vorburger committed Feb 15, 2024
1 parent 11a34fd commit 5f39817
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion docs/use/server/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@
$ ./enola server --model file:docs/use/library/model.yaml --httpPort=8080
HTTP JSON REST API + HTML UI server started; open http://0:0:0:0:0:0:0:0:8080/ui ...

You can now open e.g. <http://localhost:8080/ui/entity/demo.book/ABC/0-13-140731-7/1>
You can now open e.g. <http://localhost:8080/ui/demo.book/ABC/0-13-140731-7/1>
to view this `demo.book` _Entity._ When you click on the _Related_ `kind` you will
see its `demo.book_kind`, where you can click e.g. on its `google` _Link._

## REST

There is also a REST API which returns JSON if you replace `ui` with `api` in the URL,
so e.g. on <http://localhost:8080/api/entity/demo.book/ABC/0-13-140731-7/1>.
<!-- TODO Clean Up: /ui/ dropped /entity/ but API kept it, due to /entities/ ... -->

## gRPC

Expand Down
4 changes: 2 additions & 2 deletions web/ui/src/main/java/dev/enola/web/ui/UI.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ public ListenableFuture<ReadableResource> get(URI uri) {

private String getHTML(URI uri) throws EnolaException, IOException {
var path = uri.getPath();
if (path.startsWith("/ui/entity/")) {
var eri = path.substring("/ui/entity/".length());
if (path.startsWith("/ui/")) {
var eri = path.substring("/ui/".length());
return getEntityHTML(eri);
} else {
// TODO Create HTML page “frame” from template, with body from another template
Expand Down
4 changes: 2 additions & 2 deletions web/ui/src/main/resources/static/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ <h1>😞 404 💀</h1>

<ul>
<li>
<tt>/ui/entity/{ns}/{entity}/{paths+}</tt>, e.g.
<a href="/ui/entity/demo.book/ABC/0-13-140731-7/1">demo.book_kind/ABC/0-13-140731-7/1</a>
<tt>/ui/{ns}/{entity}/{paths+}</tt>, e.g.
<a href="/ui/demo.book/ABC/0-13-140731-7/1">demo.book_kind/ABC/0-13-140731-7/1</a>
</li>
</ul>
</div>
Expand Down
2 changes: 1 addition & 1 deletion web/ui/src/test/java/dev/enola/web/ui/UiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void testUi() throws Exception {
assertThat(response1.charSource().read()).contains("Enola");
assertThat(response1.charSource().read()).contains("404");

var uri2 = create(prefix + "/ui/entity/test.demo/123");
var uri2 = create(prefix + "/ui/test.demo/123");
var response2 = rp.getResource(uri2).charSource().read();
assertThat(response2).contains("Enola");
assertThat(response2).contains("test.demo/123");
Expand Down

0 comments on commit 5f39817

Please sign in to comment.