# HG changeset patch # User Tomas Zeman # Date 1544105981 -3600 # Node ID e7512f9dc9030447aa4758d7bae66d956e50fd42 # Parent 4d8cf198bed28ead4d0b168fd916e88bf2233d77 Layout: categories, articles, primary view diff -r 4d8cf198bed2 -r e7512f9dc903 base/src/sqwl/cms/Layout.scala --- a/base/src/sqwl/cms/Layout.scala Thu Dec 06 14:03:54 2018 +0100 +++ b/base/src/sqwl/cms/Layout.scala Thu Dec 06 15:19:41 2018 +0100 @@ -5,7 +5,7 @@ import scalatags.Text.all._ import scalatags.Text.tags2 import scalatags.Text.TypedTag -import sqwl.cms.layout.Navbar +import sqwl.cms.layout._ object Layout extends config { @@ -36,13 +36,9 @@ body(paddingTop:=120, Navbar(content, st), div(role:="main", cls:="container", - st match { - case ViewArticle(article) => div( - a(href:=s"/${http.prefix}/${article.pathSegment}", article.title), - raw(article.htmlContent) - ) - case _ => "" - } + Categories(content, st), + ArticlesInCategory(content, st), + PrimaryView(content, st) ), footer(id:="footer", p(raw(" "))), script(src:=jquery), diff -r 4d8cf198bed2 -r e7512f9dc903 base/src/sqwl/cms/layout/ArticlesInCategory.scala --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/base/src/sqwl/cms/layout/ArticlesInCategory.scala Thu Dec 06 15:19:41 2018 +0100 @@ -0,0 +1,20 @@ +package sqwl.cms.layout + +import scalatags.Text.all._ +import scalatags.Text.{TypedTag, tags2} +import sqwl.cms._ + +object ArticlesInCategory extends config { + def apply(cnt: iContent, st: ViewState): Option[TypedTag[String]] = + st match { + case ViewCategory(c) => + val l = cnt.articlesByCategory(c) + Some(tags2.section( + ul(l.map(art => + li(a(href:=s"/${http.prefix}/${art.pathSegment}", art.title)) + )), + if (l.isEmpty) "V této kategorii není ještě článek." else "" + )) + case _ => None + } +} diff -r 4d8cf198bed2 -r e7512f9dc903 base/src/sqwl/cms/layout/Categories.scala --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/base/src/sqwl/cms/layout/Categories.scala Thu Dec 06 15:19:41 2018 +0100 @@ -0,0 +1,22 @@ +package sqwl.cms.layout + +import scalatags.Text.all._ +import scalatags.Text.{TypedTag, tags2} +import sqwl.cms.{Dashboard, ViewState, config, iContent} + +object Categories extends config { + + def apply(cnt: iContent, st: ViewState): Option[TypedTag[String]] = + st match { + case Dashboard => Some(tags2.section( + div(cls:="row", + cnt.categories.map(c => + div(cls:="col-xs-6 col-sm-4 col-md-3", + div(cls:="tile-category", + a(href:=s"/${http.prefix}/${c.pathSegment}", + cls:="tile-category-body", c.name))))) + )) + case _ => None + } + +} diff -r 4d8cf198bed2 -r e7512f9dc903 base/src/sqwl/cms/layout/Navbar.scala --- a/base/src/sqwl/cms/layout/Navbar.scala Thu Dec 06 14:03:54 2018 +0100 +++ b/base/src/sqwl/cms/layout/Navbar.scala Thu Dec 06 15:19:41 2018 +0100 @@ -2,7 +2,7 @@ import scalatags.Text.TypedTag import scalatags.Text.all._ -import sqwl.cms.{ViewState, config, iContent} +import sqwl.cms._ object Navbar extends config { @@ -14,9 +14,18 @@ ) */ + def activeCls(c: iCategory): String = { + st match { + case ViewCategory(v) if v == c => "active" + case ViewArticle(v) if v.category contains(c) => "active" + case _ => "" + } + } + val navSections = ul(cls:="nav navbar-nav navbar-section", width:="100%", cnt.categories map(c => - li(cls:="text-center", a(href:=s"/${http.prefix}/${c.pathSegment}", c.name)) + li(cls:=s"text-center ${activeCls(c)}", + a(href:=s"/${http.prefix}/${c.pathSegment}", c.name)) ) ) @@ -32,12 +41,13 @@ span(cls:="icon-bar"), span(cls:="icon-bar") ), - a(href:="#", cls:="navbar-brand", paddingTop:=4, paddingBottom:=4, + a(href:=s"/${http.prefix}", cls:="navbar-brand", + paddingTop:=4, paddingBottom:=4, img(src:=s"/${http.prefix}/public/${cnt.icon._1}", alt:=cnt.appTitleShort, width:=40, height:=40)), - a(href:="#", cls:="navbar-brand visible-xs", + a(href:=s"/${http.prefix}", cls:="navbar-brand visible-xs", span(cnt.appTitleShort)), - a(href:="#", cls:="navbar-brand hidden-xs", + a(href:=s"/${http.prefix}", cls:="navbar-brand hidden-xs", span(cnt.appTitle)) ) //tag("nav")(cls:="hidden-xs", navMenu) diff -r 4d8cf198bed2 -r e7512f9dc903 base/src/sqwl/cms/layout/PrimaryView.scala --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/base/src/sqwl/cms/layout/PrimaryView.scala Thu Dec 06 15:19:41 2018 +0100 @@ -0,0 +1,17 @@ +package sqwl.cms.layout + +import scalatags.Text.all._ +import scalatags.Text.{TypedTag, tags2} +import sqwl.cms._ + +object PrimaryView extends config { + def apply(cnt: iContent, st: ViewState): Option[TypedTag[String]] = + st match { + case ViewArticle(art) => Some(tags2.section( + h1(a(href:=s"/${http.prefix}/${art.pathSegment}", art.title)), + raw(art.htmlContent) + )) + case _ => None + } + +} diff -r 4d8cf198bed2 -r e7512f9dc903 example/content/public/css/site.css --- a/example/content/public/css/site.css Thu Dec 06 14:03:54 2018 +0100 +++ b/example/content/public/css/site.css Thu Dec 06 15:19:41 2018 +0100 @@ -1,5 +1,5 @@ /* - * SQWL colors: + * Colors: * - green: #006634 / #00532b / #008745 * - red: #e94e1b * - brown: #693e11 / #482500 / #9a744c / #eedece @@ -144,24 +144,52 @@ cursor: pointer; } -/* SVG */ -svg g text { - cursor: default; +/* Tiles */ +.tile-category { + background-color: #eedece; + border-color: #9a744c; + border-style: solid; + border-width: 1px; + border-radius: 4px; + height: 10em; + display: table; + margin: .5em; + padding: .5em; + width: 100%; } -svg g text.legend { - font-family: sans-serif; - font-size: 11px; - fill: #111; +.tile-category-body { + color: #006634; + display: table-cell; + font-size: 24px; + text-align: center; + vertical-align: middle; } -svg g line.level { - stroke: grey; - stroke-opacity: 0.75; - stroke-width: 0.3px; +a.tile-category-body { + text-decoration: none; +} + +a.tile-category-body:hover, a.tile-category-body:focus { + color: #693e11; } -svg g line.level.level-val-100 { - stroke: #693e11; - stroke-width: 2px; -} +p { + /* + color: #000000; + font-family: "Yantramanav", sans-serif; + */ + font-style: normal; + font-variant: normal; + margin-bottom: 0; + margin-left: 0; + margin-right: 0; + margin-top: 0; + page-break-after: auto; + page-break-before: auto; + text-align: justify; + text-align-last: left; + text-decoration: none; + text-indent: 10px; + text-transform: none; +} \ No newline at end of file diff -r 4d8cf198bed2 -r e7512f9dc903 example/src/sqwl/cms/Content.scala --- a/example/src/sqwl/cms/Content.scala Thu Dec 06 14:03:54 2018 +0100 +++ b/example/src/sqwl/cms/Content.scala Thu Dec 06 15:19:41 2018 +0100 @@ -63,7 +63,8 @@ def styleSheet = ("site.css", Paths.get("example/content/public/css/site.css")) def articlesByTag(t: iTag): Seq[iArticle] = Seq() - def articlesByCategory(c: iCategory): Seq[iArticle] = Seq() + def articlesByCategory(c: iCategory): Seq[iArticle] = + Article.values.filter(_.category contains(c)) def tags: Seq[iTag] = Seq() def categories: Seq[iCategory] = Category.values def articleByPath(path: String): Option[iArticle] =