mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-06 15:15:58 +00:00
Remove fomantic ui and ui-header handling
This commit is contained in:
parent
b95338e744
commit
64e3cb04f3
@ -18,12 +18,11 @@ case class Flags(
|
|||||||
fullTextSearchEnabled: Boolean,
|
fullTextSearchEnabled: Boolean,
|
||||||
maxPageSize: Int,
|
maxPageSize: Int,
|
||||||
maxNoteLength: Int,
|
maxNoteLength: Int,
|
||||||
showClassificationSettings: Boolean,
|
showClassificationSettings: Boolean
|
||||||
uiVersion: Int
|
|
||||||
)
|
)
|
||||||
|
|
||||||
object Flags {
|
object Flags {
|
||||||
def apply(cfg: Config, uiVersion: Int): Flags =
|
def apply(cfg: Config): Flags =
|
||||||
Flags(
|
Flags(
|
||||||
cfg.appName,
|
cfg.appName,
|
||||||
getBaseUrl(cfg),
|
getBaseUrl(cfg),
|
||||||
@ -33,8 +32,7 @@ object Flags {
|
|||||||
cfg.fullTextSearch.enabled,
|
cfg.fullTextSearch.enabled,
|
||||||
cfg.maxItemPageSize,
|
cfg.maxItemPageSize,
|
||||||
cfg.maxNoteLength,
|
cfg.maxNoteLength,
|
||||||
cfg.showClassificationSettings,
|
cfg.showClassificationSettings
|
||||||
uiVersion
|
|
||||||
)
|
)
|
||||||
|
|
||||||
private def getBaseUrl(cfg: Config): String =
|
private def getBaseUrl(cfg: Config): String =
|
||||||
|
@ -14,8 +14,6 @@ import org.http4s.HttpRoutes
|
|||||||
import org.http4s._
|
import org.http4s._
|
||||||
import org.http4s.dsl.Http4sDsl
|
import org.http4s.dsl.Http4sDsl
|
||||||
import org.http4s.headers._
|
import org.http4s.headers._
|
||||||
import org.http4s.util.CaseInsensitiveString
|
|
||||||
import org.http4s.util.Writer
|
|
||||||
import org.log4s._
|
import org.log4s._
|
||||||
import yamusca.implicits._
|
import yamusca.implicits._
|
||||||
import yamusca.imports._
|
import yamusca.imports._
|
||||||
@ -26,32 +24,6 @@ object TemplateRoutes {
|
|||||||
val `text/html` = new MediaType("text", "html")
|
val `text/html` = new MediaType("text", "html")
|
||||||
val `application/javascript` = new MediaType("application", "javascript")
|
val `application/javascript` = new MediaType("application", "javascript")
|
||||||
|
|
||||||
val ui2Header = CaseInsensitiveString("Docspell-Ui2")
|
|
||||||
|
|
||||||
case class UiVersion(version: Int) extends Header.Parsed {
|
|
||||||
val key = UiVersion
|
|
||||||
def renderValue(writer: Writer): writer.type =
|
|
||||||
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] =
|
|
||||||
Either
|
|
||||||
.catchNonFatal(s.trim.toInt)
|
|
||||||
.leftMap(ex => ParseFailure("Invalid int header", ex.getMessage))
|
|
||||||
.map(UiVersion.apply)
|
|
||||||
|
|
||||||
override def matchHeader(h: Header): Option[UiVersion] =
|
|
||||||
if (h.name == name) parse(h.value).toOption
|
|
||||||
else None
|
|
||||||
}
|
|
||||||
|
|
||||||
trait InnerRoutes[F[_]] {
|
trait InnerRoutes[F[_]] {
|
||||||
def doc: HttpRoutes[F]
|
def doc: HttpRoutes[F]
|
||||||
def app: HttpRoutes[F]
|
def app: HttpRoutes[F]
|
||||||
@ -81,24 +53,22 @@ object TemplateRoutes {
|
|||||||
} yield resp
|
} yield resp
|
||||||
}
|
}
|
||||||
def app =
|
def app =
|
||||||
HttpRoutes.of[F] { case req @ GET -> _ =>
|
HttpRoutes.of[F] { case GET -> _ =>
|
||||||
for {
|
for {
|
||||||
templ <- indexTemplate
|
templ <- indexTemplate
|
||||||
uiv = UiVersion.get(req).version
|
|
||||||
resp <- Ok(
|
resp <- Ok(
|
||||||
IndexData(cfg, uiv).render(templ),
|
IndexData(cfg).render(templ),
|
||||||
`Content-Type`(`text/html`, Charset.`UTF-8`)
|
`Content-Type`(`text/html`, Charset.`UTF-8`)
|
||||||
)
|
)
|
||||||
} yield resp
|
} yield resp
|
||||||
}
|
}
|
||||||
|
|
||||||
def serviceWorker =
|
def serviceWorker =
|
||||||
HttpRoutes.of[F] { case req @ GET -> _ =>
|
HttpRoutes.of[F] { case GET -> _ =>
|
||||||
for {
|
for {
|
||||||
templ <- swTemplate
|
templ <- swTemplate
|
||||||
uiv = UiVersion.get(req).version
|
|
||||||
resp <- Ok(
|
resp <- Ok(
|
||||||
IndexData(cfg, uiv).render(templ),
|
IndexData(cfg).render(templ),
|
||||||
`Content-Type`(`application/javascript`, Charset.`UTF-8`)
|
`Content-Type`(`application/javascript`, Charset.`UTF-8`)
|
||||||
)
|
)
|
||||||
} yield resp
|
} yield resp
|
||||||
@ -164,10 +134,10 @@ object TemplateRoutes {
|
|||||||
|
|
||||||
object IndexData {
|
object IndexData {
|
||||||
|
|
||||||
def apply(cfg: Config, uiVersion: Int): IndexData =
|
def apply(cfg: Config): IndexData =
|
||||||
IndexData(
|
IndexData(
|
||||||
Flags(cfg, uiVersion),
|
Flags(cfg),
|
||||||
chooseUi(uiVersion),
|
chooseUi,
|
||||||
Seq(
|
Seq(
|
||||||
"/app/assets" + Webjars.clipboardjs + "/clipboard.min.js",
|
"/app/assets" + Webjars.clipboardjs + "/clipboard.min.js",
|
||||||
s"/app/assets/docspell-webapp/${BuildInfo.version}/docspell-app.js",
|
s"/app/assets/docspell-webapp/${BuildInfo.version}/docspell-app.js",
|
||||||
@ -175,17 +145,11 @@ object TemplateRoutes {
|
|||||||
),
|
),
|
||||||
s"/app/assets/docspell-webapp/${BuildInfo.version}/favicon",
|
s"/app/assets/docspell-webapp/${BuildInfo.version}/favicon",
|
||||||
s"/app/assets/docspell-webapp/${BuildInfo.version}/docspell.js",
|
s"/app/assets/docspell-webapp/${BuildInfo.version}/docspell.js",
|
||||||
Flags(cfg, uiVersion).asJson.spaces2
|
Flags(cfg).asJson.spaces2
|
||||||
)
|
)
|
||||||
|
|
||||||
private def chooseUi(uiVersion: Int): Seq[String] =
|
private def chooseUi: Seq[String] =
|
||||||
if (uiVersion == 2)
|
Seq(s"/app/assets/docspell-webapp/${BuildInfo.version}/css/styles.css")
|
||||||
Seq(s"/app/assets/docspell-webapp/${BuildInfo.version}/css/styles.css")
|
|
||||||
else
|
|
||||||
Seq(
|
|
||||||
"/app/assets" + Webjars.fomanticslimdefault + "/semantic.min.css",
|
|
||||||
s"/app/assets/docspell-webapp/${BuildInfo.version}/docspell.css"
|
|
||||||
)
|
|
||||||
|
|
||||||
implicit def yamuscaValueConverter: ValueConverter[IndexData] =
|
implicit def yamuscaValueConverter: ValueConverter[IndexData] =
|
||||||
ValueConverter.deriveConverter[IndexData]
|
ValueConverter.deriveConverter[IndexData]
|
||||||
|
@ -40,7 +40,6 @@ object Dependencies {
|
|||||||
val TikaVersion = "1.25"
|
val TikaVersion = "1.25"
|
||||||
val YamuscaVersion = "0.8.0"
|
val YamuscaVersion = "0.8.0"
|
||||||
val SwaggerUIVersion = "3.44.0"
|
val SwaggerUIVersion = "3.44.0"
|
||||||
val FomanticUIVersion = "2.8.7-3"
|
|
||||||
val TwelveMonkeysVersion = "3.6.4"
|
val TwelveMonkeysVersion = "3.6.4"
|
||||||
val JQueryVersion = "3.5.1"
|
val JQueryVersion = "3.5.1"
|
||||||
val ViewerJSVersion = "0.5.8"
|
val ViewerJSVersion = "0.5.8"
|
||||||
@ -282,7 +281,6 @@ object Dependencies {
|
|||||||
|
|
||||||
val webjars = Seq(
|
val webjars = Seq(
|
||||||
"org.webjars" % "swagger-ui" % SwaggerUIVersion,
|
"org.webjars" % "swagger-ui" % SwaggerUIVersion,
|
||||||
"com.github.eikek" % "fomantic-slim-default" % FomanticUIVersion,
|
|
||||||
"org.webjars" % "viewerjs" % ViewerJSVersion,
|
"org.webjars" % "viewerjs" % ViewerJSVersion,
|
||||||
"org.webjars" % "clipboard.js" % ClipboardJsVersion
|
"org.webjars" % "clipboard.js" % ClipboardJsVersion
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user