Files
MeWeb/src/MeWeb.App/Services/Texts.cs
T
thepraandClaude Opus 5.5 0dffbc27d6 The checks engine, the path and the cards: me-web? 0.1 reads the connection
MeWeb.Core runs seven checks concurrently and reports each as it settles:
online or behind a login page, this connection, the public IPv4 and IPv6
seen from v4./v6.meweb, the provider from a built-in map, the router
(UPnP IGD, NAT-PMP and PCP, read-only), address sharing (router WAN
against the echo, TTL hops only as a hint), and the history kept on the
device. The app draws the path from this device to the internet and lights
it node by node, with a card per check and a sheet listing every host it
contacts.

The provider map is iptoasn's table compressed to 2.1 MB by
tools/knowledge.cs and built before every app release; eleven Italian
provider profiles carry each fact with who said it, the source and the
month. The server gains a download page (en, it) and /download/{platform}
from the latest Gitea release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012CzABvBkbcFqoHdmi8b9WB
2026-10-15 04:39:03 +02:00

53 lines
2.0 KiB
C#

using System.Globalization;
using MeWeb.Core.Checks;
namespace MeWeb.App.Services;
public static class Texts
{
public static string Summary(Finding finding) => finding?.Summary is null ? "" : Localizer.Instance.Format(finding.Summary, finding.Args.Select(Argument).ToArray());
public static string Value(Fact fact)
{
if (fact.Text is not null) return Isolate(fact.Text);
if (fact.Key is null) return fact.Date is null ? "" : Date(fact.Date);
var args = fact.Amount is null ? fact.Args.Select(Argument).ToArray() : new object[] { Money(fact.Amount.Value, fact.Currency) };
return Localizer.Instance.Format(fact.Key, args);
}
public static string Source(Fact fact)
{
var parts = new List<string>();
if (fact.Basis is not null) parts.Add(Localizer.Instance[fact.Basis]);
if (fact.Date is not null && fact.Key is not null) parts.Add(Date(fact.Date));
return string.Join(", ", parts);
}
public static string Money(decimal amount, string currency)
{
var format = (NumberFormatInfo)Localizer.Instance.Culture.NumberFormat.Clone();
format.CurrencySymbol = currency switch
{
"EUR" => "€",
"USD" => "$",
"GBP" => "£",
_ => currency ?? "",
};
return amount.ToString("C2", format);
}
public static string Date(string text)
{
var culture = Localizer.Instance.Culture;
if (DateTime.TryParseExact(text, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out var day)) return day.ToString("d", culture);
if (DateTime.TryParseExact(text, "yyyy-MM", CultureInfo.InvariantCulture, DateTimeStyles.None, out var month)) return month.ToString("Y", culture);
return text;
}
public static string Isolate(string text) => string.IsNullOrEmpty(text) ? text : $"\u2068{text}\u2069";
static object Argument(string text) =>
DateTime.TryParseExact(text, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out var day) ? day.ToString("d", Localizer.Instance.Culture) : text;
}