From 7154026d7cda49a89155547946bda75a275b53e9 Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Thu, 19 Dec 2024 12:53:22 +0100 Subject: [PATCH 1/7] a better way, maybe, to show broadcast card alt --- modules/relay/src/main/RelayCard.scala | 2 +- modules/relay/src/main/RelayListing.scala | 6 +----- modules/relay/src/main/ui/RelayTourUi.scala | 19 +++++++++---------- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/modules/relay/src/main/RelayCard.scala b/modules/relay/src/main/RelayCard.scala index f455265e43b3f..127b0df2f8b1c 100644 --- a/modules/relay/src/main/RelayCard.scala +++ b/modules/relay/src/main/RelayCard.scala @@ -5,7 +5,7 @@ case class RelayCard( display: RelayRound, // which round to show on the tour link link: RelayRound, // which round to actually link to group: Option[RelayGroup.Name], - alts: List[RelayRound.WithTour] // other notable tours of the group + alt: Option[RelayRound.WithTour] // other notable tours of the group ) extends RelayRound.AndTourAndGroup: def errors: List[String] = diff --git a/modules/relay/src/main/RelayListing.scala b/modules/relay/src/main/RelayListing.scala index b8f03a8f844a6..5b2e288fe3c88 100644 --- a/modules/relay/src/main/RelayListing.scala +++ b/modules/relay/src/main/RelayListing.scala @@ -68,11 +68,7 @@ final class RelayListing( display = main.round, link = RelayListing.defaultRoundToLink(main.t) | main.round, group = main.group, - alts = s.tail - .filter(_.round.hasStarted) - .take(2) - .map: s => - s.round.withTour(s.t.tour) + alt = s.tail.find(_.round.hasStarted).map(s => s.round.withTour(s.t.tour)) ) private def tierPriority(t: RelayTour) = -t.tier.so(_.v) diff --git a/modules/relay/src/main/ui/RelayTourUi.scala b/modules/relay/src/main/ui/RelayTourUi.scala index 38b487b53054f..3df3c94cda914 100644 --- a/modules/relay/src/main/ui/RelayTourUi.scala +++ b/modules/relay/src/main/ui/RelayTourUi.scala @@ -24,7 +24,7 @@ final class RelayTourUi(helpers: Helpers, ui: RelayUi): val selected = active.filter(_.tour.tierIs(selector)) selected.nonEmpty.option(st.section(cls := s"relay-cards relay-cards--tier-$tier"): selected.map: sel => - card.render(sel, live = _.display.hasStarted, alts = sel.alts) + card.render(sel, live = _.display.hasStarted, alt = sel.alt) ) Page(trc.liveBroadcasts.txt()) .css("bits.relay.index") @@ -240,14 +240,20 @@ final class RelayTourUi(helpers: Helpers, ui: RelayUi): def render[A <: RelayRound.AndTourAndGroup]( tr: A, live: A => Boolean, - alts: List[RelayRound.WithTour] = Nil, + alt: Option[RelayRound.WithTour] = None, errors: List[String] = Nil )(using Context) = link(tr.tour, tr.path, live(tr))( image(tr.tour), span(cls := "relay-card__body")( span(cls := "relay-card__info")( - tr.tour.active.option(span(cls := "relay-card__round")(tr.display.name)), + tr.tour.active.option: + span(cls := "relay-card__round")( + tr.display.name, + (tr.group, alt).mapN: (group, alt) => + frag(" & ", group.shortTourName(alt.tour.name)) + ) + , if live(tr) then span(cls := "relay-card__live")( @@ -260,13 +266,6 @@ final class RelayTourUi(helpers: Helpers, ui: RelayUi): else tr.display.startedAt.orElse(tr.display.startsAtTime).map(momentFromNow) ), h3(cls := "relay-card__title")(tr.group.fold(tr.tour.name.value)(_.value)), - tr.group - .ifTrue(alts.nonEmpty) - .map: group => - ul(cls := "relay-card__alts"): - alts.map: alt => - li(group.shortTourName(alt.tour.name)) - , if errors.nonEmpty then ul(cls := "relay-card__errors")(errors.map(li(_))) else truncatedPlayers(tr.tour) From c88999ab41b407982926760a395f53bb9bdf9283 Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Thu, 19 Dec 2024 13:00:11 +0100 Subject: [PATCH 2/7] expand broadcast card alts in admin view --- modules/relay/src/main/RelayCard.scala | 2 +- modules/relay/src/main/RelayListing.scala | 2 +- modules/relay/src/main/ui/RelayTourUi.scala | 9 +++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/relay/src/main/RelayCard.scala b/modules/relay/src/main/RelayCard.scala index 127b0df2f8b1c..f455265e43b3f 100644 --- a/modules/relay/src/main/RelayCard.scala +++ b/modules/relay/src/main/RelayCard.scala @@ -5,7 +5,7 @@ case class RelayCard( display: RelayRound, // which round to show on the tour link link: RelayRound, // which round to actually link to group: Option[RelayGroup.Name], - alt: Option[RelayRound.WithTour] // other notable tours of the group + alts: List[RelayRound.WithTour] // other notable tours of the group ) extends RelayRound.AndTourAndGroup: def errors: List[String] = diff --git a/modules/relay/src/main/RelayListing.scala b/modules/relay/src/main/RelayListing.scala index 5b2e288fe3c88..3503239afa10e 100644 --- a/modules/relay/src/main/RelayListing.scala +++ b/modules/relay/src/main/RelayListing.scala @@ -68,7 +68,7 @@ final class RelayListing( display = main.round, link = RelayListing.defaultRoundToLink(main.t) | main.round, group = main.group, - alt = s.tail.find(_.round.hasStarted).map(s => s.round.withTour(s.t.tour)) + alts = s.tail.filter(_.round.hasStarted).map(s => s.round.withTour(s.t.tour)) ) private def tierPriority(t: RelayTour) = -t.tier.so(_.v) diff --git a/modules/relay/src/main/ui/RelayTourUi.scala b/modules/relay/src/main/ui/RelayTourUi.scala index 3df3c94cda914..b0a03e27dffd9 100644 --- a/modules/relay/src/main/ui/RelayTourUi.scala +++ b/modules/relay/src/main/ui/RelayTourUi.scala @@ -24,7 +24,7 @@ final class RelayTourUi(helpers: Helpers, ui: RelayUi): val selected = active.filter(_.tour.tierIs(selector)) selected.nonEmpty.option(st.section(cls := s"relay-cards relay-cards--tier-$tier"): selected.map: sel => - card.render(sel, live = _.display.hasStarted, alt = sel.alt) + card.render(sel, live = _.display.hasStarted, alt = sel.alts.headOption) ) Page(trc.liveBroadcasts.txt()) .css("bits.relay.index") @@ -51,7 +51,12 @@ final class RelayTourUi(helpers: Helpers, ui: RelayUi): ) private def adminIndex(active: List[RelayCard])(using Context) = - val errored = active.flatMap(a => a.errors.some.filter(_.nonEmpty).map(a -> _)) + val errored = for + main <- active + card <- main :: main.alts.map: alt => + RelayCard(tour = alt.tour, display = alt.round, link = alt.round, group = main.group, alts = Nil) + errors <- card.errors.some.filter(_.nonEmpty) + yield (card, errors) errored.nonEmpty.option: div(cls := "relay-index__admin")( h2("Ongoing broadcasts with errors"), From 904c1abad0f89a23686a8464bf8432b29d55c7de Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Thu, 19 Dec 2024 13:13:55 +0100 Subject: [PATCH 3/7] warn about http:// URLs in broadcast upstream form --- modules/relay/src/main/RelayRound.scala | 5 +- modules/relay/src/main/ui/RelayFormUi.scala | 72 ++++++++++++--------- ui/bits/css/relay/_form.scss | 2 +- 3 files changed, 48 insertions(+), 31 deletions(-) diff --git a/modules/relay/src/main/RelayRound.scala b/modules/relay/src/main/RelayRound.scala index c5c4b6b638660..6d6b7d62a4029 100644 --- a/modules/relay/src/main/RelayRound.scala +++ b/modules/relay/src/main/RelayRound.scala @@ -155,7 +155,10 @@ object RelayRound: case Url(url) => url.looksLikeLcc case Urls(urls) => urls.exists(_.looksLikeLcc) case _ => false - + def hasUnsafeHttp: Option[URL] = this match + case Url(url) => Option.when(url.scheme == "http")(url) + case Urls(urls) => urls.find(_.scheme == "http") + case _ => none def roundId: Option[RelayRoundId] = this match case Url(url) => url.path.split("/") match diff --git a/modules/relay/src/main/ui/RelayFormUi.scala b/modules/relay/src/main/ui/RelayFormUi.scala index e3d58d352a7f6..96420a54c6b40 100644 --- a/modules/relay/src/main/ui/RelayFormUi.scala +++ b/modules/relay/src/main/ui/RelayFormUi.scala @@ -1,10 +1,9 @@ package lila.relay package ui -import play.api.data.Form +import play.api.data.Form import lila.ui.* - -import ScalatagsTemplate.{ given, * } +import lila.ui.ScalatagsTemplate.{ given, * } case class FormNavigation( group: Option[RelayGroup.WithTours], @@ -154,30 +153,42 @@ final class RelayFormUi(helpers: Helpers, ui: RelayUi, tourUi: RelayTourUi): nav: FormNavigation )(using ctx: Context) = val broadcastEmailContact = a(href := "mailto:broadcast@lichess.org")("broadcast@lichess.org") - val lccWarning = nav.round - .flatMap(_.sync.upstream) - .exists(_.hasLcc) - .option: - flashMessage("box relay-form__lcc-deprecated")( - p(strong("Please use the ", a(href := broadcasterUrl)("Lichess Broadcaster App"))), - p( - "LiveChessCloud support is deprecated and will be removed soon.", - br, - s"If you need help, please contact us at ", - broadcastEmailContact, - "." - ) - ) - val contactUsForOfficial = nav.featurableRound.isDefined - .option: - flashMessage("box relay-form__contact-us")( - p( - "Is this a tournament you organize? Do you want Lichess to feature it on the ", - a(href := routes.RelayTour.index(1))("broadcast page"), - "?" - ), - p(trans.contact.sendEmailAt(broadcastEmailContact)) - ) + val lccWarning = for + round <- nav.round + upstream <- round.sync.upstream + if upstream.hasLcc + yield flashMessage("box relay-form__warning")( + p(strong("Please use the ", a(href := broadcasterUrl)("Lichess Broadcaster App"))), + p( + "LiveChessCloud support is deprecated and will be removed soon.", + br, + s"If you need help, please contact us at ", + broadcastEmailContact, + "." + ) + ) + val contactUsForOfficial = nav.featurableRound.isDefined.option: + flashMessage("box relay-form__contact-us")( + p( + "Is this a tournament you organize? Do you want Lichess to feature it on the ", + a(href := routes.RelayTour.index(1))("broadcast page"), + "?" + ), + p(trans.contact.sendEmailAt(broadcastEmailContact)) + ) + val httpWarning = for + round <- nav.round + upstream <- round.sync.upstream + http <- upstream.hasUnsafeHttp + https = http.withScheme("https") + yield flashMessage("box relay-form__warning")( + p( + strong("Warning: a source uses an insecure http:// protocol:"), + br, + a(href := http.toString)(http.toString) + ), + p("Did you mean ", a(href := https.toString)(https.toString), "?") + ) postForm(cls := "form3", action := url)( (!Granter.opt(_.StudyAdmin)).option: div(cls := "form-group")( @@ -195,7 +206,7 @@ final class RelayFormUi(helpers: Helpers, ui: RelayUi, tourUi: RelayTourUi): "Where do the games come from?" )(form3.select(_, RelayRoundForm.sourceTypes)), div(cls := "relay-form__sync relay-form__sync-url")( - lccWarning.orElse(contactUsForOfficial), + httpWarning.orElse(lccWarning).orElse(contactUsForOfficial), form3.group( form("syncUrl"), trb.sourceSingleUrl(), @@ -235,7 +246,10 @@ final class RelayFormUi(helpers: Helpers, ui: RelayUi, tourUi: RelayTourUi): help = frag("The games will be combined in the order of the URLs.").some, half = false )(field => - frag(lccWarning, form3.textarea(field)(rows := 5, spellcheck := "false", cls := "monospace")) + frag( + httpWarning.orElse(lccWarning), + form3.textarea(field)(rows := 5, spellcheck := "false", cls := "monospace") + ) )(cls := "relay-form__sync relay-form__sync-urls none"), form3.group( form("syncIds"), diff --git a/ui/bits/css/relay/_form.scss b/ui/bits/css/relay/_form.scss index 9e92267cfc6aa..58f495200bfc7 100644 --- a/ui/bits/css/relay/_form.scss +++ b/ui/bits/css/relay/_form.scss @@ -29,7 +29,7 @@ } } -.relay-form__lcc-deprecated { +.relay-form__warning { border: 5px solid $m-brag_bg--mix-70; &::before { From e85e94e5a0a69719b5e36956ecf4c04532a619b7 Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Thu, 19 Dec 2024 13:18:33 +0100 Subject: [PATCH 4/7] in user mod zone, move timeline before irwin & kaladin --- ui/mod/css/_user.scss | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/mod/css/_user.scss b/ui/mod/css/_user.scss index 825c2e3df23a0..fe3c1f3392c28 100644 --- a/ui/mod/css/_user.scss +++ b/ui/mod/css/_user.scss @@ -105,15 +105,15 @@ } &--kaladin { - order: 8; + order: 9; } &--irwin { - order: 9; + order: 10; } &--timeline { - order: 10; + order: 8; } &--assessments { From 7a5a7ade8832de5933f3edfee0437b68f32dac76 Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Thu, 19 Dec 2024 13:30:30 +0100 Subject: [PATCH 5/7] show up to 30 notes on user profile --- modules/user/src/main/NoteApi.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/user/src/main/NoteApi.scala b/modules/user/src/main/NoteApi.scala index dc39f2bbd2deb..b8b281dc516ee 100644 --- a/modules/user/src/main/NoteApi.scala +++ b/modules/user/src/main/NoteApi.scala @@ -25,7 +25,7 @@ final class NoteApi(coll: Coll)(using Executor) extends lila.core.user.NoteApi: import reactivemongo.api.bson.* private given bsonHandler: BSONDocumentHandler[Note] = Macros.handler[Note] - def getForMyPermissions(user: User, max: Max = Max(20))(using me: Me): Fu[List[Note]] = + def getForMyPermissions(user: User, max: Max = Max(30))(using me: Me): Fu[List[Note]] = coll .find( $doc("to" -> user.id) ++ { From 9702874d9f45dc209fccd34d92187f9f19a0a779 Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Thu, 19 Dec 2024 13:55:27 +0100 Subject: [PATCH 6/7] change the round buttons element --- ui/round/css/_constants.scss | 1 + ui/round/css/_moves-col1.scss | 2 +- ui/round/css/_moves.scss | 2 +- ui/round/src/view/replay.ts | 5 +++-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ui/round/css/_constants.scss b/ui/round/css/_constants.scss index 60118927999f7..e8067218a3f0b 100644 --- a/ui/round/css/_constants.scss +++ b/ui/round/css/_constants.scss @@ -5,6 +5,7 @@ $col1-mat-height: $col1-player-clock-height * 2 / 5; $col1-moves-height: 4em; $move-tag: 'kwdb'; $rmoves-tag: 'rm6'; +$rbuttons-tag: 'rb1'; $moves-tag: 'l4x'; $index-tag: 'i5z'; $active-class: 'a1t'; diff --git a/ui/round/css/_moves-col1.scss b/ui/round/css/_moves-col1.scss index 6f3c5cd9f616b..ef157dfaa0192 100644 --- a/ui/round/css/_moves-col1.scss +++ b/ui/round/css/_moves-col1.scss @@ -68,7 +68,7 @@ } } - .buttons { + #{$rbuttons-tag} { display: none; } diff --git a/ui/round/css/_moves.scss b/ui/round/css/_moves.scss index cd7a60dce0f0f..655a982028b72 100644 --- a/ui/round/css/_moves.scss +++ b/ui/round/css/_moves.scss @@ -16,7 +16,7 @@ $buttons-height: 2.5rem; @extend %flex-column, %double-tap; position: relative; - .buttons { + #{$rbuttons-tag} { @extend %box-shadow; flex: 0 0 $buttons-height; diff --git a/ui/round/src/view/replay.ts b/ui/round/src/view/replay.ts index 957c3c5acfdca..94d8e1a39104e 100644 --- a/ui/round/src/view/replay.ts +++ b/ui/round/src/view/replay.ts @@ -18,7 +18,8 @@ const scrollMax = 99999, indexTag = 'i5z', indexTagUC = indexTag.toUpperCase(), movesTag = 'l4x', - rmovesTag = 'rm6'; + rmovesTag = 'rm6', + rbuttonsTag = 'rb1'; const autoScroll = throttle(100, (movesEl: HTMLElement, ctrl: RoundController) => window.requestAnimationFrame(() => { @@ -146,7 +147,7 @@ const goThroughMoves = (ctrl: RoundController, e: Event) => { function renderButtons(ctrl: RoundController) { const firstPly = util.firstPly(ctrl.data), lastPly = util.lastPly(ctrl.data); - return h('div.buttons', [ + return h(rbuttonsTag, [ analysisButton(ctrl) || h('div.noop'), ...[ [licon.JumpFirst, firstPly], From 8c48699637f24a93d3ba875a9ee6628ed416ea61 Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Thu, 19 Dec 2024 18:00:32 +0100 Subject: [PATCH 7/7] fix added port in broadcast error message --- modules/relay/src/main/ui/RelayFormUi.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/relay/src/main/ui/RelayFormUi.scala b/modules/relay/src/main/ui/RelayFormUi.scala index 96420a54c6b40..d2739362275d3 100644 --- a/modules/relay/src/main/ui/RelayFormUi.scala +++ b/modules/relay/src/main/ui/RelayFormUi.scala @@ -180,7 +180,7 @@ final class RelayFormUi(helpers: Helpers, ui: RelayUi, tourUi: RelayTourUi): round <- nav.round upstream <- round.sync.upstream http <- upstream.hasUnsafeHttp - https = http.withScheme("https") + https = http.withScheme("https").withPort(-1) // else it adds :80 for some reason yield flashMessage("box relay-form__warning")( p( strong("Warning: a source uses an insecure http:// protocol:"),