Skip to content

Commit 067f252

Browse files
committed
reinstate flags as "Country or region"
and migrate non-regional flags such as _lichess or _esperanto into their corresponding flairs
1 parent 04ed29c commit 067f252

File tree

12 files changed

+60
-47
lines changed

12 files changed

+60
-47
lines changed

app/views/account/profile.scala

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ object profile:
2626
postForm(cls := "form3", action := routes.Account.profileApply)(
2727
div(cls := "form-group")(trans.allInformationIsPublicAndOptional()),
2828
form3.split(
29+
ctx.kid.no option
30+
form3
31+
.group(form("bio"), trans.biography(), half = true, help = trans.biographyDescription().some):
32+
f => form3.textarea(f)(rows := 5)
33+
,
2934
form3.group(form("flair"), "Flair", half = true): f =>
3035
details(cls := "form-control emoji-details")(
3136
summary(cls := "button button-metal button-no-upper")(
@@ -35,11 +40,12 @@ object profile:
3540
form3.hidden(f),
3641
div(cls := "emoji-picker")
3742
),
43+
),
44+
form3.split(
45+
form3.group(form("flag"), trans.countryRegion(), half = true): f =>
46+
form3.select(f, lila.user.Flags.allPairs, default = "".some),
3847
form3.group(form("location"), trans.location(), half = true)(form3.input(_))
3948
),
40-
ctx.kid.no option
41-
form3.group(form("bio"), trans.biography(), help = trans.biographyDescription().some): f =>
42-
form3.textarea(f)(rows := 5),
4349
form3.split(
4450
form3.group(form("firstName"), trans.firstName(), half = true)(form3.input(_)),
4551
form3.group(form("lastName"), trans.lastName(), half = true)(form3.input(_))

app/views/coach/widget.scala

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,16 @@ object widget:
3737
tr(
3838
th(location()),
3939
td(
40-
profile.nonEmptyLocation.map { l =>
41-
span(cls := "location")(l)
42-
},
43-
profile.countryInfo.map { c =>
40+
profile.nonEmptyLocation.map: l =>
41+
span(cls := "location")(l),
42+
profile.flagInfo.map: c =>
4443
frag(
45-
span(cls := "country")(
46-
img(cls := "flag", src := assetUrl(s"images/flags/${c.code}.png")),
44+
span(cls := "flag")(
45+
img(src := assetUrl(s"images/flags/${c.code}.png")),
4746
" ",
4847
c.name
4948
)
5049
)
51-
}
5250
)
5351
),
5452
tr(cls := "languages")(

app/views/user/mini.scala

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ object mini:
2020
frag(
2121
div(cls := "upt__info")(
2222
div(cls := "upt__info__top")(
23-
div(cls := "left")(userLink(u, withPowerTip = false, withFlair = true)),
23+
div(cls := "left")(
24+
userLink(u, withPowerTip = false, withFlair = true),
25+
u.profileOrDefault.flagInfo map: c =>
26+
span(cls := "upt__info__top__flag", attrData("flag") := c.code)(c.shortName)
27+
),
2428
ping map bits.signalBars
2529
),
2630
if u.lame && !ctx.is(u) && !isGranted(_.UserModView)
@@ -31,7 +35,7 @@ object mini:
3135
),
3236
ctx.userId.map: myId =>
3337
frag(
34-
(myId != u.id && u.enabled.yes) option div(cls := "upt__actions btn-rack")(
38+
(myId.isnt(u.id) && u.enabled.yes) option div(cls := "upt__actions btn-rack")(
3539
a(
3640
dataIcon := licon.AnalogTv,
3741
cls := "btn-rack__btn",
@@ -54,7 +58,7 @@ object mini:
5458
),
5559
views.html.relation.mini(u.id, blocked, followable, rel)
5660
),
57-
crosstable.flatMap(_.nonEmpty) map { cross =>
61+
crosstable.flatMap(_.nonEmpty) map: cross =>
5862
a(
5963
cls := "upt__score",
6064
href := s"${routes.User.games(u.username, "me")}#games",
@@ -64,7 +68,6 @@ object mini:
6468
val opponent = ~cross.showOpponentScore(myId)
6569
s"""<strong>${cross.showScore(myId)}</strong> - <strong>$opponent</strong>"""
6670
)
67-
}
6871
),
6972
isGranted(_.UserModView) option div(cls := "upt__mod")(
7073
span(

app/views/user/show/header.scala

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,12 @@ object header:
168168
profile.nonEmptyLocation.ifTrue(ctx.kid.no && !hideTroll).map { l =>
169169
span(cls := "location")(l)
170170
},
171-
profile.countryInfo.map { c =>
172-
span(cls := "country")(
173-
img(cls := "flag", src := assetUrl(s"images/flags/${c.code}.png")),
171+
profile.flagInfo.map: c =>
172+
span(cls := "flag")(
173+
img(src := assetUrl(s"images/flags/${c.code}.png")),
174174
" ",
175175
c.name
176-
)
177-
},
176+
),
178177
p(cls := "thin")(trans.memberSince(), " ", showDate(u.createdAt)),
179178
u.seenAt.map { seen =>
180179
p(cls := "thin")(trans.lastSeenActive(momentFromNow(seen)))
@@ -191,35 +190,31 @@ object header:
191190
br,
192191
a(href := s"${routes.User.opponents}?u=${u.username}")(trans.favoriteOpponents())
193192
),
194-
u.playTime.map { playTime =>
193+
u.playTime.map: playTime =>
195194
frag(
196195
p(trans.tpTimeSpentPlaying(showDuration(playTime.totalDuration))),
197196
playTime.nonEmptyTvDuration.map { tvDuration =>
198197
p(trans.tpTimeSpentOnTV(showDuration(tvDuration)))
199198
}
200-
)
201-
},
199+
),
202200
!hideTroll option div(cls := "social_links col2")(
203201
profile.actualLinks.nonEmpty option strong(trans.socialMediaLinks()),
204-
profile.actualLinks.map { link =>
202+
profile.actualLinks.map: link =>
205203
a(href := link.url, targetBlank, noFollow)(link.site.name)
206-
}
207204
),
208205
div(cls := "teams col2")(
209206
info.teamIds.nonEmpty option strong(trans.team.teams()),
210-
info.teamIds.sorted(stringOrdering).map { t =>
207+
info.teamIds.sorted(stringOrdering) map: t =>
211208
teamLink(t, withIcon = false)
212-
}
213209
)
214210
)
215211
),
216212
info.insightVisible option
217-
a(cls := "insight", href := routes.Insight.index(u.username), dataIcon := licon.Target)(
213+
a(cls := "insight", href := routes.Insight.index(u.username), dataIcon := licon.Target):
218214
span(
219215
strong("Chess Insights"),
220216
em("Analytics from ", if ctx.is(u) then "your" else s"${u.username}'s", " games")
221217
)
222-
)
223218
)
224219
)
225220
,
@@ -274,11 +269,9 @@ object header:
274269
p(cls := "note__text")(richText(note.text, expandImg = false)),
275270
(note.mod && isGranted(_.Admin)) option postForm(
276271
action := routes.User.setDoxNote(note._id, !note.dox)
277-
)(
278-
submitButton(
279-
cls := "button-empty confirm button text"
280-
)("Toggle Dox")
281-
),
272+
):
273+
submitButton(cls := "button-empty confirm button text")("Toggle Dox")
274+
,
282275
p(cls := "note__meta")(
283276
userIdLink(note.from.some),
284277
br,

bin/download-lifat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh -e
22

3-
commit=5b684ed8c7de938268200717b22ba48120715b40
3+
commit=3e7c037e05bf0b5d61e5c2bd95b1f5205c480685
44

55
lifat_dir="${LIFAT_DIR:-lifat}"
66
mkdir -p "$lifat_dir"
@@ -14,7 +14,7 @@ if [ ! -d "$lifat_commit_dir" ]; then
1414
git remote add origin https://github.com/lichess-org/lifat
1515
git fetch --depth 1 origin "$commit"
1616
git checkout --detach "$commit"
17-
git log -n 1 --pretty="oneline" > "commit.txt"
17+
git log -n 1 --pretty="oneline" >"commit.txt"
1818
cd -
1919
fi
2020

bin/mongodb/user-flag-to-flair.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
map = [
2+
['_lichess', 'activity.lichess'],
3+
['_pirate', 'flags.pirate-flag'],
4+
['_rainbow', 'flags.rainbow-flag'],
5+
['_transgender', 'flags.transgender-flag'],
6+
['_esperanto', 'symbols.esperanto'],
7+
];
8+
9+
db.user4.find({ 'profile.country': { $in: map.map(e => e[0]) } }, { 'profile.country': 1 }).forEach(user => {
10+
flair = map.find(e => e[0] == user.profile.country)[1];
11+
db.user4.updateOne({ _id: user._id }, { $unset: { 'profile.country': 1 }, $set: { flair: flair } });
12+
});

modules/i18n/src/main/I18nKeys.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ object I18nKeys:
377377
val `firstName` = I18nKey("firstName")
378378
val `lastName` = I18nKey("lastName")
379379
val `biography` = I18nKey("biography")
380-
val `flag` = I18nKey("flag")
380+
val `countryRegion` = I18nKey("countryRegion")
381381
val `thankYou` = I18nKey("thankYou")
382382
val `socialMediaLinks` = I18nKey("socialMediaLinks")
383383
val `oneUrlPerLine` = I18nKey("oneUrlPerLine")

modules/user/src/main/Flags.scala

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,14 +283,9 @@ object Flags:
283283
C("_adygea", "Adygea"),
284284
C("_belarus-wrw", "Belarus White-red-white"),
285285
C("_east-turkestan", "East Turkestan"),
286-
C("_esperanto", "Esperanto"),
287-
C("_lichess", "Lichess"),
288-
C("_pirate", "Pirate"),
289-
C("_rainbow", "Rainbow"),
290286
C("_russia-wbw", "Russia White-blue-white"),
291287
C("_united-nations", "United Nations"),
292-
C("_earth", "Earth"),
293-
C("_transgender", "Transgender")
288+
C("_earth", "Earth")
294289
)
295290

296291
val allPairs = all.map: c =>

modules/user/src/main/Profile.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package lila.user
22

3+
import reactivemongo.api.bson.Macros.Annotations.Key
4+
35
case class Profile(
4-
country: Option[String] = None,
6+
@Key("country") flag: Option[String] = None,
57
location: Option[String] = None,
68
bio: Option[String] = None,
79
firstName: Option[String] = None,
@@ -20,7 +22,7 @@ case class Profile(
2022
case Nil => none
2123
case names => (names mkString " ").some
2224

23-
def countryInfo = country flatMap Flags.info
25+
def flagInfo = flag flatMap Flags.info
2426

2527
def nonEmptyLocation = ne(location)
2628

@@ -29,7 +31,7 @@ case class Profile(
2931
def isEmpty = completionPercent == 0
3032

3133
def completionPercent: Int =
32-
100 * List(country, bio, firstName, lastName).count(_.isDefined) / 4
34+
100 * List(flag, bio, firstName, lastName).count(_.isDefined) / 4
3335

3436
def actualLinks: List[Link] = links so Links.make
3537

translation/source/site.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ computer analysis, game chat and shareable URL.</string>
507507
<string name="firstName">First name</string>
508508
<string name="lastName">Surname</string>
509509
<string name="biography">Biography</string>
510-
<string name="flag" comment="flag&#10;Appears when you edit your profile. Lets a player add a country/flag (not all flags are for countries) to their profile">Flag</string>
510+
<string name="countryRegion" comment="flag&#10;Appears when you edit your profile. Lets a player add a country/flag (not all flags are for countries) to their profile">Country or region</string>
511511
<string name="thankYou">Thank you!</string>
512512
<string name="socialMediaLinks">Social media links</string>
513513
<string name="oneUrlPerLine">One URL per line.</string>

0 commit comments

Comments
 (0)