.getNation(id.id)
.shards(NationShard.NAME, NationShard.FLAG_URL)
.executeSuspend()
- ?.let {
- NationData(id = Id(it.id), name = it.name, flag = it.flagUrl)
+ ?.let { nation ->
+ NationData(id = Id(nation.id), name = nation.name, flag = nation.flagUrl)
} ?: unknown(id)
}
}
val ApplicationCall.nationCache: MutableMap<Id<NationData>, NationData>
get() = attributes.getOrNull(CallNationCacheAttribute)
- ?: mutableMapOf<Id<NationData>, NationData>().also {
- attributes.put(CallNationCacheAttribute, it)
+ ?: mutableMapOf<Id<NationData>, NationData>().also { cache ->
+ attributes.put(CallNationCacheAttribute, cache)
}
suspend fun MutableMap<Id<NationData>, NationData>.getNation(id: Id<NationData>): NationData {
.orEmpty()
.map { it.toArticleNode() }
.sortedBy { it.name }
- .sortedBy {
- if (it.subNodes.isNotEmpty())
+ .sortedBy { node ->
+ if (node.subNodes.isNotEmpty())
0
else
1
fun List<ArticleNode>.renderInto(list: UL, base: String? = null) {
val prefix = base?.let { "$it/" } ?: ""
- forEach {
+ forEach { node ->
list.li {
- a(href = "/lore/$prefix${it.name}") { +it.name }
- if (it.subNodes.isNotEmpty())
+ a(href = "/lore/$prefix${node.name}") { +node.name }
+ if (node.subNodes.isNotEmpty())
ul {
- it.subNodes.renderInto(this, "$prefix${it.name}")
+ node.subNodes.renderInto(this, "$prefix${node.name}")
}
}
}
data class PageNavSidebar(val contents: List<NavItem>) : Sidebar() {
override fun TagConsumer<*>.display() {
div(classes = "list") {
- for (it in contents) {
+ for (content in contents) {
div(classes = "item") {
- it.displayIn(this)
+ content.displayIn(this)
}
}
}
}.orEmpty() + listOf(
NavHead("Client Preferences"),
NavLink("/change-theme", "Light/Dark Mode"),
-) + (currentNation()?.let {
+) + (currentNation()?.let { data ->
listOf(
- NavHead(it.name),
- NavLink("/user/${it.id}", "Your User Page"),
- NavLink("https://nationstates.net/${it.id}", "Your NationStates Page"),
+ NavHead(data.name),
+ NavLink("/user/${data.id}", "Your User Page"),
+ NavLink("https://nationstates.net/${data.id}", "Your NationStates Page"),
NavLink("/auth/logout", "Log Out", linkAttributes = mapOf("data-method" to "post", "data-csrf-token" to createCsrfToken("/auth/logout")))
)
} ?: listOf(