<commit_before>package views.html.relation

import play.api.mvc.Call

import lila.api.Context
import lila.app.templating.Environment._
import lila.app.ui.ScalatagsTemplate._
import lila.common.paginator.Paginator
import lila.relation.Related
import lila.user.User

import controllers.routes

object bits {

  def followers(u: User, pag: Paginator[Related], nbFollowing: Int)(implicit ctx: Context) =
    layout(s"${u.username} • ${trans.nbFollowers.pluralSameTxt(pag.nbResults)}")(
      div(cls := "box__top")(
        h1(userLink(u, withOnline = false)),
        div(cls := "actions")(
          trans.nbFollowers.pluralSame(pag.nbResults),
          " ", amp, " ",
          a(href := routes.Relation.following(u.username))(trans.nbFollowing.pluralSame(nbFollowing))
        )
      ),
      pagTable(pag, routes.Relation.followers(u.username))
    )

  def following(u: User, pag: Paginator[Related], nbFollowers: Int)(implicit ctx: Context) =
    layout(s"${u.username} • ${trans.nbFollowing.pluralSameTxt(pag.nbResults)}")(
      div(cls := "box__top")(
        h1(userLink(u, withOnline = false)),
        div(cls := "actions")(
          trans.nbFollowing.pluralSame(pag.nbResults),
          " ", amp, " ",
          a(href := routes.Relation.followers(u.username))(trans.nbFollowers.pluralSame(nbFollowers))
        )
      ),
      pagTable(pag, routes.Relation.following(u.username))
    )

  def blocks(u: User, pag: Paginator[Related])(implicit ctx: Context) =
    layout(s"${u.username} • ${trans.blocks.pluralSameTxt(pag.nbResults)}")(
      div(cls := "box__top")(
        h1(userLink(u, withOnline = false)),
        div(cls := "actions")(
          trans.blocks.pluralSame(pag.nbResults)
        )
      ),
      pagTable(pag, routes.Relation.blocks())
    )

  def layout(title: String)(content: Modifier*)(implicit ctx: Context) =
    views.html.base.layout(
      title = title,
      moreCss = cssTag("relation")
    ) {
        main(cls := "box page-small")(content)
      }

  private def pagTable(pager: Paginator[Related], call: Call)(implicit ctx: Context) =
    table(cls := "slist")(
      if (pager.nbResults > 0)
        tbody(cls := "infinitescroll")(
        pagerNextTable(pager, np => addQueryParameter(call.url, "page", np)),
        pager.currentPageResults.map { r =>
          tr(cls := "paginated")(
            td(userLink(r.user)),
            td(showBestPerf(r.user)),
            td(trans.nbGames.pluralSame(r.user.count.game)),
            td(actions(r.user.id, relation = r.relation, followable = r.followable, blocked = false))
          )
        }
      )
      else tbody(tr(td(colspan := 2)("None found.", br)))
    )
}
<commit_msg>fix top bar on long following pages<commit_after>package views.html.relation

import play.api.mvc.Call

import lila.api.Context
import lila.app.templating.Environment._
import lila.app.ui.ScalatagsTemplate._
import lila.common.paginator.Paginator
import lila.relation.Related
import lila.user.User

import controllers.routes

object bits {

  def followers(u: User, pag: Paginator[Related], nbFollowing: Int)(implicit ctx: Context) =
    layout(s"${u.username} • ${trans.nbFollowers.pluralSameTxt(pag.nbResults)}")(
      div(cls := "box__top")(
        h1(userLink(u, withOnline = false)),
        div(cls := "actions")(
          trans.nbFollowers.pluralSame(pag.nbResults),
          " ", amp, " ",
          a(href := routes.Relation.following(u.username))(trans.nbFollowing.pluralSame(nbFollowing))
        )
      ),
      pagTable(pag, routes.Relation.followers(u.username))
    )

  def following(u: User, pag: Paginator[Related], nbFollowers: Int)(implicit ctx: Context) =
    layout(s"${u.username} • ${trans.nbFollowing.pluralSameTxt(pag.nbResults)}")(
      div(cls := "box__top")(
        h1(userLink(u, withOnline = false)),
        div(cls := "actions")(
          trans.nbFollowing.pluralSame(pag.nbResults),
          " ", amp, " ",
          a(href := routes.Relation.followers(u.username))(trans.nbFollowers.pluralSame(nbFollowers))
        )
      ),
      pagTable(pag, routes.Relation.following(u.username))
    )

  def blocks(u: User, pag: Paginator[Related])(implicit ctx: Context) =
    layout(s"${u.username} • ${trans.blocks.pluralSameTxt(pag.nbResults)}")(
      div(cls := "box__top")(
        h1(userLink(u, withOnline = false)),
        div(cls := "actions")(
          trans.blocks.pluralSame(pag.nbResults)
        )
      ),
      pagTable(pag, routes.Relation.blocks())
    )

  def layout(title: String)(content: Modifier*)(implicit ctx: Context) =
    views.html.base.layout(
      title = title,
      moreCss = cssTag("relation"),
      moreJs = infiniteScrollTag
    ) {
        main(cls := "box page-small")(content)
      }

  private def pagTable(pager: Paginator[Related], call: Call)(implicit ctx: Context) =
    table(cls := "slist")(
      if (pager.nbResults > 0)
        tbody(cls := "infinitescroll")(
        pagerNextTable(pager, np => addQueryParameter(call.url, "page", np)),
        pager.currentPageResults.map { r =>
          tr(cls := "paginated")(
            td(userLink(r.user)),
            td(showBestPerf(r.user)),
            td(trans.nbGames.pluralSame(r.user.count.game)),
            td(actions(r.user.id, relation = r.relation, followable = r.followable, blocked = false))
          )
        }
      )
      else tbody(tr(td(colspan := 2)("None found.", br)))
    )
}

{'fraction_non_alphanumeric': 0.15523598820058998, 'fraction_numerical': 0.0018436578171091445, 'mean_word_length': 2.9425872093023258, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3686079', 'n_tokens_mistral': 1847, 'n_tokens_neox': 1792, 'n_words': 294}