me-web? skeleton: Avalonia 12 app, server, packaging and CI
Build / Desktop, server and tools (push) Successful in 1m7s

The first screen (online or not, a Check button, every language with a
draft notice), the desktop and Android heads, the server's /api/info and
/api/ip, a release tool that builds deb, rpm, a Windows exe, macOS zips,
a signed APK and the server, and the Gitea workflows that run it. Rules
adapted from passolo; AGPL-3.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012CzABvBkbcFqoHdmi8b9WB
This commit is contained in:
thepraandClaude Opus 5.5 committed 2026-10-15 01:14:44 +02:00
commit 7589121846
76 files changed
+3082

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace MeWeb.App.Services;
[JsonSourceGenerationOptions(JsonSerializerDefaults.Web, WriteIndented = true)]
[JsonSerializable(typeof(List<Language>))]
[JsonSerializable(typeof(StoredSettings))]
public partial class AppJsonContext : JsonSerializerContext
{
}
+43
View File
@@ -0,0 +1,43 @@
using System.Text.Json;
namespace MeWeb.App.Services;
public class StoredSettings
{
public string Language { get; set; }
}
public static class AppSettings
{
static readonly string Folder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "MeWeb");
static readonly string FilePath = Path.Combine(Folder, "settings.json");
public static StoredSettings Read()
{
try
{
if (!File.Exists(FilePath)) return new StoredSettings();
using var stream = File.OpenRead(FilePath);
return JsonSerializer.Deserialize(stream, AppJsonContext.Default.StoredSettings) ?? new StoredSettings();
}
catch (Exception ex) when (ex is IOException or JsonException or UnauthorizedAccessException)
{
return new StoredSettings();
}
}
public static void Write(StoredSettings settings)
{
try
{
Directory.CreateDirectory(Folder);
var temporary = FilePath + ".tmp";
using (var stream = File.Create(temporary))
JsonSerializer.Serialize(stream, settings, AppJsonContext.Default.StoredSettings);
File.Move(temporary, FilePath, overwrite: true);
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
{
}
}
}
+41
View File
@@ -0,0 +1,41 @@
using System.Globalization;
using System.Text.Json;
namespace MeWeb.App.Services;
public class Language
{
public string Code { get; set; }
public string Name { get; set; }
public string Status { get; set; }
public bool IsDraft => Status == "draft";
}
public static class Languages
{
public static Language Fallback { get; } = new() { Code = "en", Name = "English", Status = "reviewed" };
public static IReadOnlyList<Language> All { get; } = Load();
public static Language Find(string code) =>
string.IsNullOrEmpty(code) ? null : All.FirstOrDefault(l => string.Equals(l.Code, code, StringComparison.OrdinalIgnoreCase));
public static Language ForCulture(CultureInfo culture)
{
for (var current = culture; current is not null && !string.IsNullOrEmpty(current.Name); current = current.Parent)
{
var found = Find(current.Name);
if (found is not null) return found;
}
return Fallback;
}
static List<Language> Load()
{
using var stream = typeof(Languages).Assembly.GetManifestResourceStream("languages.json");
if (stream is null) return [Fallback];
var list = JsonSerializer.Deserialize(stream, AppJsonContext.Default.ListLanguage) ?? [];
return list.Count == 0 ? [Fallback] : list.OrderBy(l => l.Name, StringComparer.Create(CultureInfo.InvariantCulture, CompareOptions.IgnoreCase)).ToList();
}
}
+52
View File
@@ -0,0 +1,52 @@
using System.ComponentModel;
using System.Globalization;
using System.Resources;
using Avalonia.Data;
using Avalonia.Markup.Xaml;
using Avalonia.Markup.Xaml.MarkupExtensions;
namespace MeWeb.App.Services;
public sealed class Localizer : INotifyPropertyChanged
{
readonly ResourceManager resources = new("MeWeb.App.Strings.Strings", typeof(Localizer).Assembly);
public static Localizer Instance { get; } = new();
public event PropertyChangedEventHandler PropertyChanged;
public Language Language { get; private set; } = Languages.Fallback;
public CultureInfo Culture { get; private set; } = CultureInfo.GetCultureInfo(Languages.Fallback.Code);
public bool IsRightToLeft => Culture.TextInfo.IsRightToLeft;
public string this[string key] => resources.GetString(key, Culture) ?? key;
public string Format(string key, params object[] args) => string.Format(Culture, this[key], args);
public void SetLanguage(Language language)
{
Language = language ?? Languages.Fallback;
Culture = CultureInfo.GetCultureInfo(Language.Code);
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.DefaultThreadCurrentUICulture = Culture;
CultureInfo.CurrentCulture = CultureInfo.CurrentUICulture = Culture;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Item[]"));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(string.Empty));
}
}
public sealed class TrExtension : MarkupExtension
{
public TrExtension()
{
}
public TrExtension(string key) => Key = key;
public string Key { get; set; }
public override object ProvideValue(IServiceProvider serviceProvider) =>
new ReflectionBindingExtension($"[{Key}]") { Mode = BindingMode.OneWay, Source = Localizer.Instance }.ProvideValue(serviceProvider);
}
+33
View File
@@ -0,0 +1,33 @@
using System.Net.Http.Json;
using MeWeb.Shared;
namespace MeWeb.App.Services;
public enum Reachability
{
Unknown,
Online,
Offline,
}
public class ServerClient(IHttpClientFactory factory)
{
public const string Name = "server";
public async Task<(Reachability State, ViewInfo Info)> Probe(CancellationToken ct)
{
try
{
var http = factory.CreateClient(Name);
using var timeout = CancellationTokenSource.CreateLinkedTokenSource(ct);
timeout.CancelAfter(TimeSpan.FromSeconds(6));
var info = await http.GetFromJsonAsync(Endpoints.Server.GET_Info, MeWebJsonContext.Default.ViewInfo, timeout.Token);
return (Reachability.Online, info);
}
catch (Exception ex) when (ex is HttpRequestException or TaskCanceledException && !ct.IsCancellationRequested)
{
return (Reachability.Offline, null);
}
}
}