integrate community blogs and Lichess blog

pull/9746/head
Thibault Duplessis 2021-09-06 21:10:32 +02:00
parent 3a0a517796
commit 27278f7d47
4 changed files with 36 additions and 28 deletions

View File

@ -10,10 +10,12 @@ import controllers.routes
object bits {
private[blog] def menu(year: Option[Int], hasActive: Boolean = true) =
def menu(year: Option[Int], active: Option[String]) =
st.nav(cls := "page-menu__menu subnav")(
a(cls := (year.isEmpty && hasActive).option("active"), href := routes.Blog.index())("Latest"),
lila.blog.allYears map { y =>
a(cls := active.has("friends").option("active"), href := routes.Ublog.friends())("Friends blogs"),
a(cls := active.has("community").option("active"), href := routes.Ublog.community())("Community blogs"),
a(cls := active.has("lichess").option("active"), href := routes.Blog.index())("Lichess blog"),
year.isDefined || active.has("lichess") option lila.blog.allYears.map { y =>
a(cls := (year has y).option("active"), href := routes.Blog.year(y))(y)
}
)

View File

@ -23,7 +23,7 @@ object index {
moreJs = infiniteScrollTag
)(
main(cls := "page-menu")(
bits.menu(none),
bits.menu(none, "lichess".some),
div(cls := "blog index page-menu__content page-small box")(
div(cls := "box__top")(
h1("Lichess Official Blog"),
@ -48,14 +48,14 @@ object index {
def byYear(year: Int, posts: List[MiniPost])(implicit ctx: Context) =
views.html.base.layout(
title = s"Blog posts from $year",
title = s"Lichess blog posts from $year",
moreCss = cssTag("blog"),
csp = bits.csp
)(
main(cls := "page-menu")(
bits.menu(year.some),
bits.menu(year.some, none),
div(cls := "page-menu__content box")(
div(cls := "box__top")(h1(s"Blog posts from $year")),
div(cls := "box__top")(h1(s"Lichess blog posts from $year")),
st.section(
div(cls := "blog-cards")(posts map { bits.postCard(_) })
)

View File

@ -25,7 +25,7 @@ object show {
csp = bits.csp
)(
main(cls := "page-menu page-small")(
bits.menu(none, hasActive = false),
bits.menu(none, "lichess".some),
div(cls := s"blog page-menu__content box post ${~doc.getText("blog.cssClasses")}")(
h1(doc.getText("blog.title")),
bits.metas(doc),

View File

@ -76,19 +76,22 @@ object index {
moreJs = posts.hasNextPage option infiniteScrollTag,
title = "Friends blogs"
) {
main(cls := "box box-pad page page-small ublog-index")(
div(cls := "box__top")(
h1("Friends blogs")
),
if (posts.nbResults > 0)
div(cls := "ublog-index__posts ublog-post-cards infinite-scroll")(
posts.currentPageResults map { postView.card(_, showAuthor = true) },
pagerNext(posts, np => routes.Ublog.friends(np).url)
)
else
div(cls := "ublog-index__posts--empty")(
"Nothing to show. Follow some authors!"
)
main(cls := "page-menu")(
views.html.blog.bits.menu(none, "friends".some),
main(cls := "page-menu__content box box-pad ublog-index")(
div(cls := "box__top")(
h1("Friends blogs")
),
if (posts.nbResults > 0)
div(cls := "ublog-index__posts ublog-post-cards infinite-scroll")(
posts.currentPageResults map { postView.card(_, showAuthor = true) },
pagerNext(posts, np => routes.Ublog.friends(np).url)
)
else
div(cls := "ublog-index__posts--empty")(
"Nothing to show. Follow some authors!"
)
)
)
}
@ -98,13 +101,16 @@ object index {
moreJs = posts.hasNextPage option infiniteScrollTag,
title = "Community blogs"
) {
main(cls := "box box-pad page page-small ublog-index")(
div(cls := "box__top")(
h1("Community blogs")
),
div(cls := "ublog-index__posts ublog-post-cards infinite-scroll")(
posts.currentPageResults map { postView.card(_, showAuthor = true) },
pagerNext(posts, np => routes.Ublog.friends(np).url)
main(cls := "page-menu")(
views.html.blog.bits.menu(none, "community".some),
main(cls := "page-menu__content box box-pad ublog-index")(
div(cls := "box__top")(
h1("Community blogs")
),
div(cls := "ublog-index__posts ublog-post-cards infinite-scroll")(
posts.currentPageResults map { postView.card(_, showAuthor = true) },
pagerNext(posts, np => routes.Ublog.community(np).url)
)
)
)
}