From f6e5bda2d8ab55960e5b454dcefc7ece82a5836d Mon Sep 17 00:00:00 2001 From: Eike Kettner Date: Sun, 14 Feb 2021 01:31:38 +0100 Subject: [PATCH] Change default ui to be the new ui The old ui is still available, using a header: `Docspell-Ui: 1`. Using a browser addon a "ui switch" can be easily achieved. --- .../docspell/restserver/webapp/TemplateRoutes.scala | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/restserver/src/main/scala/docspell/restserver/webapp/TemplateRoutes.scala b/modules/restserver/src/main/scala/docspell/restserver/webapp/TemplateRoutes.scala index 84e8ce27..b920168a 100644 --- a/modules/restserver/src/main/scala/docspell/restserver/webapp/TemplateRoutes.scala +++ b/modules/restserver/src/main/scala/docspell/restserver/webapp/TemplateRoutes.scala @@ -34,6 +34,11 @@ object TemplateRoutes { writer.append(version) } object UiVersion extends HeaderKey.Singleton { + val default = UiVersion(2) + + def get[F[_]](req: Request[F]): UiVersion = + req.headers.get(UiVersion).getOrElse(UiVersion.default) + type HeaderT = UiVersion val name = CaseInsensitiveString("Docspell-Ui") override def parse(s: String): ParseResult[UiVersion] = @@ -79,7 +84,7 @@ object TemplateRoutes { HttpRoutes.of[F] { case req @ GET -> _ => for { templ <- indexTemplate - uiv = req.headers.get(UiVersion).map(_.version).getOrElse(1) + uiv = UiVersion.get(req).version resp <- Ok( IndexData(cfg, uiv).render(templ), `Content-Type`(`text/html`, Charset.`UTF-8`) @@ -91,7 +96,7 @@ object TemplateRoutes { HttpRoutes.of[F] { case req @ GET -> _ => for { templ <- swTemplate - uiv = req.headers.get(UiVersion).map(_.version).getOrElse(1) + uiv = UiVersion.get(req).version resp <- Ok( IndexData(cfg, uiv).render(templ), `Content-Type`(`application/javascript`, Charset.`UTF-8`)