From a8d46494048f1aad897ccb2659b266d971800233 Mon Sep 17 00:00:00 2001 From: Claude Brisson Date: Sun, 11 Jun 2023 13:52:15 +0200 Subject: [PATCH] View layout in progress --- .../org/jeudego/pairgoth/store/FileStore.kt | 2 +- .../org/jeudego/pairgoth/web/ApiServlet.kt | 4 +- view-webapp/pom.xml | 30 ++---------- .../src/main/config/layouts/standard.html | 17 +++++-- view-webapp/src/main/config/tools.xml | 3 +- .../org/jeudego/pairgoth/view/ApiTool.kt | 43 ++++++++++++++++++ .../pairgoth/view/TranslateDirective.kt | 3 +- .../view/{IntlTool.kt => TranslationTool.kt} | 2 +- .../jeudego/pairgoth/web/LanguageFilter.kt | 4 +- view-webapp/src/main/sass/main.scss | 43 ++++++++++++++---- view-webapp/src/main/webapp/favicon.ico | Bin 0 -> 145042 bytes view-webapp/src/main/webapp/img/logo.svg | 18 ++++++++ view-webapp/src/main/webapp/index.html | 3 ++ webserver/pom.xml | 5 ++ 14 files changed, 129 insertions(+), 48 deletions(-) create mode 100644 view-webapp/src/main/kotlin/org/jeudego/pairgoth/view/ApiTool.kt rename view-webapp/src/main/kotlin/org/jeudego/pairgoth/view/{IntlTool.kt => TranslationTool.kt} (93%) create mode 100644 view-webapp/src/main/webapp/favicon.ico create mode 100644 view-webapp/src/main/webapp/img/logo.svg diff --git a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/store/FileStore.kt b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/store/FileStore.kt index 22fd6a2..1f70fb3 100644 --- a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/store/FileStore.kt +++ b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/store/FileStore.kt @@ -40,7 +40,7 @@ class FileStore(pathStr: String): StoreImplementation { return path.useDirectoryEntries("*.tour") { entries -> entries.mapNotNull { entry -> filenameRegex.matchEntire(entry.fileName.toString())?.groupValues?.get(1)?.toID() - }.toSet() + }.toSortedSet() } } diff --git a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/web/ApiServlet.kt b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/web/ApiServlet.kt index 269fca1..34d2d9b 100644 --- a/api-webapp/src/main/kotlin/org/jeudego/pairgoth/web/ApiServlet.kt +++ b/api-webapp/src/main/kotlin/org/jeudego/pairgoth/web/ApiServlet.kt @@ -170,7 +170,7 @@ class ApiServlet : HttpServlet() { } // check charset - if (charset != null && EXPECTED_CHARSET != charset) throw ApiException( + if (charset != null && EXPECTED_CHARSET != charset.lowercase(Locale.ROOT).replace("-", "")) throw ApiException( HttpServletResponse.SC_BAD_REQUEST, "UTF-8 content expected" ) @@ -215,6 +215,8 @@ class ApiServlet : HttpServlet() { HttpServletResponse.SC_BAD_REQUEST, "Missing 'Accept' header" ) + // CB TODO 1) a reference to a specific API call at this point is a code smell. + // 2) there will e other content types: .tou, .h9, .html if (!isJson(accept) && (!isXml(accept) || !request.requestURI.matches(Regex("/api/tour/\\d+")))) throw ApiException( HttpServletResponse.SC_BAD_REQUEST, "Invalid 'Accept' header" diff --git a/view-webapp/pom.xml b/view-webapp/pom.xml index 5523f07..bfa5175 100644 --- a/view-webapp/pom.xml +++ b/view-webapp/pom.xml @@ -196,34 +196,12 @@ 70.1 --> - - org.apache.httpcomponents - httpclient - 4.5.13 - - - commons-logging - commons-logging - - + com.squareup.okhttp3 + okhttp + 4.8.1 - - org.apache.httpcomponents - httpmime - 4.5.13 - - - commons-io - commons-io - 2.11.0 - - - commons-net - commons-net - 3.8.0 - - --> com.republicate diff --git a/view-webapp/src/main/config/layouts/standard.html b/view-webapp/src/main/config/layouts/standard.html index 9cf65df..f291ed8 100644 --- a/view-webapp/src/main/config/layouts/standard.html +++ b/view-webapp/src/main/config/layouts/standard.html @@ -9,9 +9,13 @@ - -