diff options
author | Jakob Odersky <jakob@inpher.io> | 2019-10-09 20:32:48 -0400 |
---|---|---|
committer | Jakob Odersky <jakob@inpher.io> | 2019-10-09 20:33:16 -0400 |
commit | f67c8d59a26132a8d7c80b3e15bddc35ba0091d9 (patch) | |
tree | eb733861e64397d7b36b2ee00aa97e8a92a9044f /shared | |
parent | 0ceee5ed4bae240b8c8e94d2fd7424d9d0b67ec7 (diff) | |
download | scala-triad-f67c8d59a26132a8d7c80b3e15bddc35ba0091d9.tar.gz scala-triad-f67c8d59a26132a8d7c80b3e15bddc35ba0091d9.tar.bz2 scala-triad-f67c8d59a26132a8d7c80b3e15bddc35ba0091d9.zip |
format
Diffstat (limited to 'shared')
-rw-r--r-- | shared/Message.scala | 8 | ||||
-rw-r--r-- | shared/Templates.scala | 9 | ||||
-rw-r--r-- | shared/TextTemplates.scala | 41 | ||||
-rw-r--r-- | shared/http/Response.scala | 8 |
4 files changed, 41 insertions, 25 deletions
diff --git a/shared/Message.scala b/shared/Message.scala index 84c733e..bc76fae 100644 --- a/shared/Message.scala +++ b/shared/Message.scala @@ -3,9 +3,11 @@ package triad import java.security.MessageDigest import java.time.Instant -case class Message(content: String, - author: String, - timestamp: Instant = Instant.now()) { +case class Message( + content: String, + author: String, + timestamp: Instant = Instant.now() +) { lazy val id: String = { val digest = MessageDigest.getInstance("SHA-256") diff --git a/shared/Templates.scala b/shared/Templates.scala index 10ee116..23a8eff 100644 --- a/shared/Templates.scala +++ b/shared/Templates.scala @@ -1,7 +1,8 @@ package triad class Templates[Builder, Output <: FragT, FragT]( - val bundle: scalatags.generic.Bundle[Builder, Output, FragT]) { + val bundle: scalatags.generic.Bundle[Builder, Output, FragT] +) { import bundle.all._ val colorStyles = List( @@ -20,7 +21,8 @@ class Templates[Builder, Output <: FragT, FragT]( (hash * 31 + char.toInt) } colorStyles( - ((dataHash % colorStyles.length) + colorStyles.length) % colorStyles.length) + ((dataHash % colorStyles.length) + colorStyles.length) % colorStyles.length + ) } def message(msg: Message) = { @@ -28,7 +30,8 @@ class Templates[Builder, Output <: FragT, FragT]( hashTag => span(`class` := "badge badge-light float-right ml-1")( hashTag - )) + ) + ) div(`class` := "col-xs-12 col-sm-6 col-md-3 col-lg-2")( div(`class` := s"card text-white mb-3 ${dataStyle(msg.author)}")( div(`class` := "card-header")( diff --git a/shared/TextTemplates.scala b/shared/TextTemplates.scala index 0dd45c5..5674eac 100644 --- a/shared/TextTemplates.scala +++ b/shared/TextTemplates.scala @@ -9,8 +9,7 @@ object TextTemplates extends Templates(scalatags.Text) { div(id := "scalajs-error", style := "display: none;")( "ScalaJS raised an exception. See the log for more information." ), - script(`type` := "text/javascript", - src := "/out.js"), + script(`type` := "text/javascript", src := "/out.js"), script(`type` := "text/javascript")( raw( """|document.addEventListener("DOMContentLoaded", function(event) { @@ -40,20 +39,30 @@ object TextTemplates extends Templates(scalatags.Text) { def page(messages: Seq[Message], js: Boolean = true) = html( head( - link(rel := "stylesheet", - `type` := "text/css", - href := "/assets/lib/bootstrap-4.1.0/css/bootstrap-reboot.min.css"), - link(rel := "stylesheet", - `type` := "text/css", - href := "/assets/lib/bootstrap-4.1.0/css/bootstrap-grid.min.css"), - link(rel := "stylesheet", - `type` := "text/css", - href := "/assets/lib/bootstrap-4.1.0/css/bootstrap.min.css"), - link(rel := "stylesheet", - `type` := "text/css", - href := "/assets/main.css"), - meta(name := "viewport", - content := "width=device-width, initial-scale=1, shrink-to-fit=no") + link( + rel := "stylesheet", + `type` := "text/css", + href := "/assets/lib/bootstrap-4.1.0/css/bootstrap-reboot.min.css" + ), + link( + rel := "stylesheet", + `type` := "text/css", + href := "/assets/lib/bootstrap-4.1.0/css/bootstrap-grid.min.css" + ), + link( + rel := "stylesheet", + `type` := "text/css", + href := "/assets/lib/bootstrap-4.1.0/css/bootstrap.min.css" + ), + link( + rel := "stylesheet", + `type` := "text/css", + href := "/assets/main.css" + ), + meta( + name := "viewport", + content := "width=device-width, initial-scale=1, shrink-to-fit=no" + ) ), body( conversation(messages), diff --git a/shared/http/Response.scala b/shared/http/Response.scala index 4ba2342..652e72f 100644 --- a/shared/http/Response.scala +++ b/shared/http/Response.scala @@ -1,6 +1,8 @@ package triad package http -case class Response(statusCode: Int, - headers: Map[String, String], - body: Array[Byte]) +case class Response( + statusCode: Int, + headers: Map[String, String], + body: Array[Byte] +) |