base/src/sqwl/cms/Layout.scala
changeset 5 de7c56ce0654
parent 4 1a1347e8c5be
child 7 50a354e5bda4
equal deleted inserted replaced
4:1a1347e8c5be 5:de7c56ce0654
     1 package sqwl.cms
     1 package sqwl.cms
     2 
     2 
       
     3 import BuildInfo.versions
       
     4 import scalatags.Text.all
     3 import scalatags.Text.all._
     5 import scalatags.Text.all._
     4 import scalatags.Text.tags2
     6 import scalatags.Text.tags2
     5 import scalatags.Text.TypedTag
     7 import scalatags.Text.TypedTag
       
     8 import sqwl.cms.layout.Navbar
     6 
     9 
     7 object Layout {
    10 object Layout extends config {
       
    11 
       
    12   lazy val bootstrapCss = s"/${http.prefix}/assets/bootstrap/${versions.bootstrap}/css/bootstrap.min.css"
       
    13   lazy val bootstrapJs = s"/${http.prefix}/assets/bootstrap/${versions.bootstrap}/js/bootstrap.min.js"
       
    14   lazy val fontAwesomeCss = s"/${http.prefix}/assets/font-awesome/${versions.fontAwesome}/css/all.min.css"
       
    15   lazy val siteCss = s"/${http.prefix}/public/css/site.css?${BuildInfo.hgId}"
       
    16   lazy val jquery = s"/${http.prefix}/assets/jquery/${versions.jquery}/jquery.min.js"
       
    17 
     8   def apply(content: iContent, st: ViewState): TypedTag[String] = {
    18   def apply(content: iContent, st: ViewState): TypedTag[String] = {
     9     html(
    19     html(
    10       head(
    20       head(
       
    21         tags2.style("""
       
    22           |.nav, .pagination, .carousel, .panel-title a, .panel a { cursor: pointer; }""".stripMargin),
       
    23         meta(charset:="utf-8"),
       
    24         meta(name:="viewport", all.content:="width=device-width, initial-scale=1"),
       
    25         link(rel:="stylesheet", href:=bootstrapCss),
       
    26         link(rel:="stylesheet", href:=fontAwesomeCss),
       
    27         link(rel:="stylesheet", href:=siteCss),
       
    28         link(rel:="icon", href:="favicon.ico"),
    11         tags2.title(st match {
    29         tags2.title(st match {
    12           case ViewArticle(v) => v.title
    30           case ViewArticle(v) => v.title
    13           case ViewCategory(v) => v.name
    31           case ViewCategory(v) => v.name
    14           case ViewTag(v) => v.name
    32           case ViewTag(v) => v.name
    15           case Dashboard => "SQWL"
    33           case Dashboard => "SQWL"
    16           case News => "Novinky"
    34           case News => "Novinky"
    17         })
    35         })
    18 
       
    19       ),
    36       ),
    20       body(
    37       body(paddingTop:=120,
    21         div("foo"),
    38         Navbar(content, st),
    22         st match {
    39         div(role:="main", cls:="container",
    23           case ViewArticle(article) => div(
    40           st match {
    24             a(href:=article.pathSegment, article.title),
    41             case ViewArticle(article) => div(
    25             raw(article.htmlContent)
    42               a(href:=article.pathSegment, article.title),
    26           )
    43               raw(article.htmlContent)
    27           case _ => ""
    44             )
    28         },
    45             case _ => ""
    29         div(
    46           }
    30           content.categories map(c => div(a(href:=c.pathSegment, c.name)))
    47         ),
    31         )
    48         footer(id:="footer", p(raw(" "))),
    32 
    49         script(src:=jquery),
       
    50         script(src:=bootstrapJs)
    33       )
    51       )
    34     )
    52     )
    35   }
    53   }
    36 
    54 
    37 }
    55 }