From 9d94d05db1c248774237193d00e9a40c3357e73c Mon Sep 17 00:00:00 2001 From: Weyoune Date: Sun, 15 Nov 2026 19:58:07 +0100 Subject: [PATCH] The inbox with drawn signs: a letter, the doctor's case, a coin, a newspaper Co-Authored-By: Claude Fable 5.2 --- assets/modern/pages.rcss | 1 + src/modern/ui/news_screens.inc | 51 +++++++++++++++++----------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/assets/modern/pages.rcss b/assets/modern/pages.rcss index 9d3af25..e53b267 100644 --- a/assets/modern/pages.rcss +++ b/assets/modern/pages.rcss @@ -465,3 +465,4 @@ body .pg-btn.pg-go[disabled] {opacity:1;background-color:var(--p-a3);border-colo .nw-row.is-unread .nw-title {font-weight:bold;} .nw-excerpt {display:block;font-size:28dp;line-height:36dp;} .nw-body {display:block;font-size:36dp;line-height:54dp;} +.pg-root .news-art,.pg-ov .news-art {background-color:transparent;} diff --git a/src/modern/ui/news_screens.inc b/src/modern/ui/news_screens.inc index de390b8..31cacdf 100644 --- a/src/modern/ui/news_screens.inc +++ b/src/modern/ui/news_screens.inc @@ -1,34 +1,33 @@ // SPDX-License-Identifier: GPL-3.0-only namespace {std::string news_body_markup(const std::string &text){auto value=esc(text);size_t at=0;while((at=value.find('\n',at))!=std::string::npos){value.replace(at,1,"
");at+=5;}return value;}} +// The picture of a message: the crest of the club it is about, the flag for the national side, +// else one of four drawn signs: a letter, the doctor's case, a coin, a newspaper. std::string App::render_news_art(const Json &message, double size) { const auto kind = message.at("kind").get(); + const auto sign = [&](const char *name, const std::string &body) { + return picture(renderer_.diagram(std::string("news-sign-") + name, "" + body + "", 192), size * .95, size * .95); + }; + const auto has = [&](std::initializer_list words) { + const auto text = message.value("title", std::string()) + " " + message.value("body", std::string()); + return std::any_of(words.begin(), words.end(), [&](const char *word) { return text.find(word) != std::string::npos; }); + }; + static const std::string letter = ""; + static const std::string doctor = ""; + static const std::string coin = ""; + static const std::string paper = ""; std::string art; - if(kind=="mail")art=glyph("mail",size*.65); - else if (kind == "national" || - (message.contains("scope") && - message.at("scope").value("kind", "") == "national")) - art = picture( - renderer_.diagram("news-national-flag", ui_nation_flag_svg("de"), 176), - size * .69, size * .46); - else if (kind == "club" || kind == "career") { - const auto id = - message.value("scope", Json::object()).value("id", std::string()); - art = crest(world_->find("clubs", id), size * .69); - if (art.empty()) - art = glyph("world", size * .55); - } else { - const auto key = - kind == "fixture" ? "button.league" - : kind == "transfer" ? "button.contracts" - : kind == "finance" - ? (gui_.contains("news.cash") ? "news.cash" : "icon.coins") - : kind == "training" ? "button.training" - : "button.stadium"; - art = img(key, size * .76, size * .76, false, false, 256); + if (kind == "national" || (message.contains("scope") && message.at("scope").value("kind", "") == "national")) + art = picture(renderer_.diagram("news-national-flag", ui_nation_flag_svg("de"), 176), size * .69, size * .46); + else if (kind == "club" || kind == "career") + art = crest(world_->find("clubs", message.value("scope", Json::object()).value("id", std::string())), size * .69); + if (art.empty()) { + // what a letter is about decides its sign: an injury, money, a report of a match + if (has({"verletz", "Verletz", "fällt", "Arzt", "Prellung", "prellung", "Zerrung", "riss"})) art = sign("doctor", doctor); + else if (kind == "finance" || has({"€", "Prämie", "prämie", "Werbe", "Sponsor", "Zinsen", "Kredit"})) art = sign("coin", coin); + else if (kind == "fixture" || message.value("category", std::string()) == "Bericht") art = sign("paper", paper); + else art = sign("letter", letter); } - return "
" + art + "
"; + return "
" + art + "
"; } // The messages of a folder as rows of the page: a dot while unread, the sender's picture, date // and kind, the headline as a link, a line of the text, and the two things one does with a @@ -44,7 +43,7 @@ std::string App::render_news_feed(const Json &data) { const auto id = m.at("id").get(), name = m.at("title").get(); const bool unread = m.at("read").is_boolean() && !m.at("read").get(), archived = m.at("folder") == "archive" || (engine_mode_ && m.at("folder") == "trash"); const auto category = m.at("category").get(); - out += "
" + render_news_art(m, 86) + "
" + render_news_art(m, 100) + "
" + esc(m.at("display_date").get()) + "" + esc(category) + "" + (unread ? "Neu" : "") + (data.value("fictional", false) ? "Demo" : "") + "
" + btn("news-open", "" + esc(name) + "", "pg-link nw-title", "id=\"news-read-" + id + "\" data-id=\"" + id + "\" aria-label=\"Nachricht lesen: " + esc(name) + "\"") +