mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-04-04 18:39:33 +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,
|
||||
maxPageSize: Int,
|
||||
maxNoteLength: Int,
|
||||
showClassificationSettings: Boolean,
|
||||
uiVersion: Int
|
||||
showClassificationSettings: Boolean
|
||||
)
|
||||
|
||||
object Flags {
|
||||
def apply(cfg: Config, uiVersion: Int): Flags =
|
||||
def apply(cfg: Config): Flags =
|
||||
Flags(
|
||||
cfg.appName,
|
||||
getBaseUrl(cfg),
|
||||
@ -33,8 +32,7 @@ object Flags {
|
||||
cfg.fullTextSearch.enabled,
|
||||
cfg.maxItemPageSize,
|
||||
cfg.maxNoteLength,
|
||||
cfg.showClassificationSettings,
|
||||
uiVersion
|
||||
cfg.showClassificationSettings
|
||||
)
|
||||
|
||||
private def getBaseUrl(cfg: Config): String =
|
||||
|
@ -14,8 +14,6 @@ import org.http4s.HttpRoutes
|
||||
import org.http4s._
|
||||
import org.http4s.dsl.Http4sDsl
|
||||
import org.http4s.headers._
|
||||
import org.http4s.util.CaseInsensitiveString
|
||||
import org.http4s.util.Writer
|
||||
import org.log4s._
|
||||
import yamusca.implicits._
|
||||
import yamusca.imports._
|
||||
@ -26,32 +24,6 @@ object TemplateRoutes {
|
||||
val `text/html` = new MediaType("text", "html")
|
||||
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[_]] {
|
||||
def doc: HttpRoutes[F]
|
||||
def app: HttpRoutes[F]
|
||||
@ -81,24 +53,22 @@ object TemplateRoutes {
|
||||
} yield resp
|
||||
}
|
||||
def app =
|
||||
HttpRoutes.of[F] { case req @ GET -> _ =>
|
||||
HttpRoutes.of[F] { case GET -> _ =>
|
||||
for {
|
||||
templ <- indexTemplate
|
||||
uiv = UiVersion.get(req).version
|
||||
resp <- Ok(
|
||||
IndexData(cfg, uiv).render(templ),
|
||||
IndexData(cfg).render(templ),
|
||||
`Content-Type`(`text/html`, Charset.`UTF-8`)
|
||||
)
|
||||
} yield resp
|
||||
}
|
||||
|
||||
def serviceWorker =
|
||||
HttpRoutes.of[F] { case req @ GET -> _ =>
|
||||
HttpRoutes.of[F] { case GET -> _ =>
|
||||
for {
|
||||
templ <- swTemplate
|
||||
uiv = UiVersion.get(req).version
|
||||
resp <- Ok(
|
||||
IndexData(cfg, uiv).render(templ),
|
||||
IndexData(cfg).render(templ),
|
||||
`Content-Type`(`application/javascript`, Charset.`UTF-8`)
|
||||
)
|
||||
} yield resp
|
||||
@ -164,10 +134,10 @@ object TemplateRoutes {
|
||||
|
||||
object IndexData {
|
||||
|
||||
def apply(cfg: Config, uiVersion: Int): IndexData =
|
||||
def apply(cfg: Config): IndexData =
|
||||
IndexData(
|
||||
Flags(cfg, uiVersion),
|
||||
chooseUi(uiVersion),
|
||||
Flags(cfg),
|
||||
chooseUi,
|
||||
Seq(
|
||||
"/app/assets" + Webjars.clipboardjs + "/clipboard.min.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}/docspell.js",
|
||||
Flags(cfg, uiVersion).asJson.spaces2
|
||||
Flags(cfg).asJson.spaces2
|
||||
)
|
||||
|
||||
private def chooseUi(uiVersion: Int): Seq[String] =
|
||||
if (uiVersion == 2)
|
||||
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"
|
||||
)
|
||||
private def chooseUi: Seq[String] =
|
||||
Seq(s"/app/assets/docspell-webapp/${BuildInfo.version}/css/styles.css")
|
||||
|
||||
implicit def yamuscaValueConverter: ValueConverter[IndexData] =
|
||||
ValueConverter.deriveConverter[IndexData]
|
||||
|
@ -40,7 +40,6 @@ object Dependencies {
|
||||
val TikaVersion = "1.25"
|
||||
val YamuscaVersion = "0.8.0"
|
||||
val SwaggerUIVersion = "3.44.0"
|
||||
val FomanticUIVersion = "2.8.7-3"
|
||||
val TwelveMonkeysVersion = "3.6.4"
|
||||
val JQueryVersion = "3.5.1"
|
||||
val ViewerJSVersion = "0.5.8"
|
||||
@ -282,7 +281,6 @@ object Dependencies {
|
||||
|
||||
val webjars = Seq(
|
||||
"org.webjars" % "swagger-ui" % SwaggerUIVersion,
|
||||
"com.github.eikek" % "fomantic-slim-default" % FomanticUIVersion,
|
||||
"org.webjars" % "viewerjs" % ViewerJSVersion,
|
||||
"org.webjars" % "clipboard.js" % ClipboardJsVersion
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user