base/src/sqwl/cms/Layout.scala
author Tomas Zeman <tzeman@volny.cz>
Thu, 29 Nov 2018 12:20:20 +0100
changeset 4 1a1347e8c5be
child 5 de7c56ce0654
permissions -rw-r--r--
Build modules: base, content, app; example content, minimal layout

package sqwl.cms

import scalatags.Text.all._
import scalatags.Text.tags2
import scalatags.Text.TypedTag

object Layout {
  def apply(content: iContent, st: ViewState): TypedTag[String] = {
    html(
      head(
        tags2.title(st match {
          case ViewArticle(v) => v.title
          case ViewCategory(v) => v.name
          case ViewTag(v) => v.name
          case Dashboard => "SQWL"
          case News => "Novinky"
        })

      ),
      body(
        div("foo"),
        st match {
          case ViewArticle(article) => div(
            a(href:=article.pathSegment, article.title),
            raw(article.htmlContent)
          )
          case _ => ""
        },
        div(
          content.categories map(c => div(a(href:=c.pathSegment, c.name)))
        )

      )
    )
  }

}