Foto del profilo: uno schema dei nomi proprio (#38)
verifica / controlli (push) Successful in 17s
verifica / prove (push) Successful in 12m21s
verifica / installatore (push) Successful in 3m45s
verifica / immagine (push) Successful in 16m5s

Alberto ha deciso che le foto del profilo stanno dentro ogni account, in
<account>\profilo. Con un solo schema generale bastava cambiarlo perché
finissero insieme ai post: ora hanno il loro schema, come le raccolte in
evidenza, predefinito {account}\profilo\{data}_{ora}_{codice}_{n}, senza la
cartella dell'anno.

Impostazioni > Generali mostra il terzo campo con la cartella nel risultato
e colora solo il campo sbagliato. Un salvataggio che non manda il terzo
schema tiene quello salvato. Importazione e ricostruzione del database
riconoscono la cartella; prove nuove per nomi, impostazioni, salvataggio,
importazione e ricostruzione. Schermata confrontata con il mockup 08.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-13 11:39:58 +01:00
1 parent 305791f57b
commit 72deb212a7
19 files changed
+340 -69

No files matched your search

+9 -4
View File
@@ -3,7 +3,7 @@ using Febe.Core.Storage;
namespace Febe.Core.Library;
/// <summary>
/// Settings of the library (spec §4.7, mockup 08): the library folder, the two naming schemes and whether the file
/// Settings of the library (spec §4.7, mockup 08): the library folder, the three naming schemes and whether the file
/// modification time is set to the publication time. Stored in the <c>setting</c> table.
/// </summary>
public sealed record LibrarySettings(string LibraryRoot, LibraryNaming Naming, bool SetFileTimeToPublication = true)
@@ -18,12 +18,16 @@ public sealed record LibrarySettings(string LibraryRoot, LibraryNaming Naming, b
ArgumentException.ThrowIfNullOrWhiteSpace(defaultLibraryRoot);
var values = await store.GetAllAsync(ct).ConfigureAwait(false);
var root = values.GetValueOrDefault(SettingKeys.LibraryRoot);
var general = NamingScheme.Validate(values.GetValueOrDefault(SettingKeys.NamingScheme) ?? NamingScheme.DefaultGeneral, forHighlights: false);
var highlight = NamingScheme.Validate(values.GetValueOrDefault(SettingKeys.HighlightNamingScheme) ?? NamingScheme.DefaultHighlight, forHighlights: true);
NamingScheme Scheme(string key, NamingSchemeUse use) =>
NamingScheme.Validate(values.GetValueOrDefault(key) ?? NamingScheme.Default(use).Text, use).Scheme ?? NamingScheme.Default(use);
var setTime = !values.TryGetValue(SettingKeys.SetFileTimeToPublication, out var text) || !bool.TryParse(text, out var parsed) || parsed;
return new LibrarySettings(
string.IsNullOrWhiteSpace(root) ? defaultLibraryRoot : root,
new LibraryNaming(general.Scheme ?? NamingScheme.General, highlight.Scheme ?? NamingScheme.Highlight),
new LibraryNaming(
Scheme(SettingKeys.NamingScheme, NamingSchemeUse.General),
Scheme(SettingKeys.HighlightNamingScheme, NamingSchemeUse.Highlight),
Scheme(SettingKeys.ProfilePictureNamingScheme, NamingSchemeUse.ProfilePicture)),
setTime);
}
@@ -37,6 +41,7 @@ public sealed record LibrarySettings(string LibraryRoot, LibraryNaming Naming, b
[SettingKeys.LibraryRoot] = LibraryRoot,
[SettingKeys.NamingScheme] = Naming.General.Text,
[SettingKeys.HighlightNamingScheme] = Naming.Highlight.Text,
[SettingKeys.ProfilePictureNamingScheme] = Naming.ProfilePicture.Text,
[SettingKeys.SetFileTimeToPublication] = SetFileTimeToPublication ? "true" : "false",
},
ct);
+32 -12
View File
@@ -9,7 +9,7 @@ public sealed record NamingPreviewFile(string Name, MediaKind Kind);
public sealed record NamingPreviewFolder(IReadOnlyList<string> Path, IReadOnlyList<NamingPreviewFile> Files);
/// <summary>
/// The «Risultato» tree of the settings screen (mockup 08): an account folder with sample files rendered by the two
/// The «Risultato» tree of the settings screen (mockup 08): an account folder with sample files rendered by the three
/// schemes. The interface shows each folder path joined by « \ ».
/// </summary>
public sealed record NamingPreview(
@@ -21,21 +21,25 @@ public sealed record NamingPreview(
public bool IsValid => Errors.Count == 0;
/// <summary>
/// Renders three sample files — a post photo (second of a series), a story video and a highlight photo — with the
/// given schemes. Sample times are local times in <paramref name="zone"/>, so the preview reads the same anywhere.
/// Renders four sample files — a post photo (second of a series), a story video, a highlight photo and a profile
/// picture — with the given schemes. Sample times are local times in <paramref name="zone"/>, so the preview reads
/// the same anywhere. Each error and warning starts with the name of its scheme (<see cref="Prefix"/>).
/// </summary>
public static NamingPreview Build(string? generalScheme, string? highlightScheme, TimeZoneInfo zone, string sampleAccount = "nome.utente")
public static NamingPreview Build(string? generalScheme, string? highlightScheme, string? profilePictureScheme, TimeZoneInfo zone, string sampleAccount = "nome.utente")
{
ArgumentNullException.ThrowIfNull(zone);
ArgumentException.ThrowIfNullOrWhiteSpace(sampleAccount);
var general = NamingScheme.Validate(generalScheme, forHighlights: false);
var highlight = NamingScheme.Validate(highlightScheme, forHighlights: true);
var errors = general.Errors.Select(e => "Schema: " + e)
.Concat(highlight.Errors.Select(e => "Schema per le raccolte in evidenza: " + e))
.ToList();
var warnings = general.Warnings.Select(e => "Schema: " + e)
.Concat(highlight.Warnings.Select(e => "Schema per le raccolte in evidenza: " + e))
.ToList();
var general = NamingScheme.Validate(generalScheme, NamingSchemeUse.General);
var highlight = NamingScheme.Validate(highlightScheme, NamingSchemeUse.Highlight);
var profile = NamingScheme.Validate(profilePictureScheme, NamingSchemeUse.ProfilePicture);
(NamingSchemeValidation Validation, string Prefix)[] all =
[
(general, Prefix(NamingSchemeUse.General)),
(highlight, Prefix(NamingSchemeUse.Highlight)),
(profile, Prefix(NamingSchemeUse.ProfilePicture)),
];
var errors = all.SelectMany(s => s.Validation.Errors.Select(e => s.Prefix + e)).ToList();
var warnings = all.SelectMany(s => s.Validation.Warnings.Select(e => s.Prefix + e)).ToList();
var folders = new List<NamingPreviewFolder>();
void Add(NamingScheme scheme, EntryKind kind, DateTime local, string code, int n, MediaKind media, string? collection)
@@ -73,6 +77,22 @@ public sealed record NamingPreview(
Add(h, EntryKind.Highlight, new DateTime(2025, 8, 2, 10, 11, 12), "3391207", 1, MediaKind.Photo, "Estate 2025");
}
if (profile.Scheme is { } p)
{
Add(p, EntryKind.ProfilePicture, new DateTime(2026, 9, 30, 21, 4, 33), "a3f9c2e1", 1, MediaKind.Photo, null);
}
return new NamingPreview(WindowsFileNames.SanitizeSegment(sampleAccount), folders, errors, warnings);
}
/// <summary>
/// The start of the errors and warnings of a scheme («Schema: », «Schema per le raccolte in evidenza: », «Schema
/// per le foto del profilo: »): the settings screen uses it to mark the field in error.
/// </summary>
public static string Prefix(NamingSchemeUse use) => use switch
{
NamingSchemeUse.Highlight => "Schema per le raccolte in evidenza: ",
NamingSchemeUse.ProfilePicture => "Schema per le foto del profilo: ",
_ => "Schema: ",
};
}
+75 -20
View File
@@ -9,7 +9,8 @@ namespace Febe.Core.Library;
/// <para>
/// A backslash (or a slash) separates folders on every operating system. Placeholders: <c>account</c>, <c>tipo</c>,
/// <c>anno</c>, <c>mese</c>, <c>data</c>, <c>ora</c>, <c>codice</c>, <c>n</c>, <c>raccolta</c> (only in the scheme of
/// highlight collections). Dates and times are in Alberto's time zone: <c>data</c> is yyyy-MM-dd and <c>ora</c> is
/// highlight collections). There are three schemes (<see cref="NamingSchemeUse"/>): general, highlight collections and
/// profile pictures, so that each of the last two keeps its own folder whatever the general scheme says. Dates and times are in Alberto's time zone: <c>data</c> is yyyy-MM-dd and <c>ora</c> is
/// HH-mm-ss. The file extension is added to the last segment.
/// </para>
/// <para>
@@ -23,33 +24,57 @@ public sealed class NamingScheme
public const string DefaultHighlight = @"{account}\evidenza\{raccolta}\{data}_{ora}_{codice}_{n}";
/// <summary>
/// Profile pictures: few per account, so no year folder. <c>{codice}</c> is the start of the SHA-256 (spec §4.3);
/// <c>{n}</c> is always 1, kept so that the names read like the others and the import recognizes them.
/// </summary>
public const string DefaultProfilePicture = @"{account}\profilo\{data}_{ora}_{codice}_{n}";
/// <summary>Placeholders accepted, in the order shown in the interface.</summary>
public static IReadOnlyList<string> Placeholders { get; } = ["account", "tipo", "anno", "mese", "data", "ora", "codice", "n", "raccolta"];
private readonly IReadOnlyList<IReadOnlyList<Token>> _segments;
private NamingScheme(string text, bool forHighlights, IReadOnlyList<IReadOnlyList<Token>> segments)
private NamingScheme(string text, NamingSchemeUse use, IReadOnlyList<IReadOnlyList<Token>> segments)
{
Text = text;
ForHighlights = forHighlights;
Use = use;
_segments = segments;
}
/// <summary>The scheme as written.</summary>
public string Text { get; }
/// <summary>Which files the scheme names.</summary>
public NamingSchemeUse Use { get; }
/// <summary>True for the scheme of highlight collections (accepts <c>{raccolta}</c>).</summary>
public bool ForHighlights { get; }
public bool ForHighlights => Use == NamingSchemeUse.Highlight;
public static NamingScheme General { get; } = Parse(DefaultGeneral, forHighlights: false);
public static NamingScheme General { get; } = Parse(DefaultGeneral, NamingSchemeUse.General);
public static NamingScheme Highlight { get; } = Parse(DefaultHighlight, forHighlights: true);
public static NamingScheme Highlight { get; } = Parse(DefaultHighlight, NamingSchemeUse.Highlight);
/// <summary>Parses a scheme. </summary>
/// <exception cref="FormatException">The scheme is not valid; the message (Italian) says why.</exception>
public static NamingScheme Parse(string text, bool forHighlights)
public static NamingScheme ProfilePicture { get; } = Parse(DefaultProfilePicture, NamingSchemeUse.ProfilePicture);
/// <summary>The default scheme for a use.</summary>
public static NamingScheme Default(NamingSchemeUse use) => use switch
{
var validation = Validate(text, forHighlights);
NamingSchemeUse.Highlight => Highlight,
NamingSchemeUse.ProfilePicture => ProfilePicture,
_ => General,
};
/// <summary>Parses the general scheme or the one of highlight collections.</summary>
/// <exception cref="FormatException">The scheme is not valid; the message (Italian) says why.</exception>
public static NamingScheme Parse(string text, bool forHighlights) =>
Parse(text, forHighlights ? NamingSchemeUse.Highlight : NamingSchemeUse.General);
/// <summary>Parses a scheme.</summary>
/// <exception cref="FormatException">The scheme is not valid; the message (Italian) says why.</exception>
public static NamingScheme Parse(string text, NamingSchemeUse use)
{
var validation = Validate(text, use);
if (!validation.IsValid)
{
throw new FormatException(validation.Errors[0]);
@@ -58,8 +83,12 @@ public sealed class NamingScheme
return validation.Scheme!;
}
/// <summary>Checks the general scheme or the one of highlight collections.</summary>
public static NamingSchemeValidation Validate(string? text, bool forHighlights) =>
Validate(text, forHighlights ? NamingSchemeUse.Highlight : NamingSchemeUse.General);
/// <summary>Checks a scheme for the settings screen: errors block saving, warnings are shown.</summary>
public static NamingSchemeValidation Validate(string? text, bool forHighlights)
public static NamingSchemeValidation Validate(string? text, NamingSchemeUse use)
{
var errors = new List<string>();
var warnings = new List<string>();
@@ -90,7 +119,7 @@ public sealed class NamingScheme
{
errors.Add($"Segnaposto sconosciuto: {{{token.Value}}}. Quelli ammessi sono: {string.Join(", ", Placeholders)}.");
}
else if (token.Value == "raccolta" && !forHighlights)
else if (token.Value == "raccolta" && use != NamingSchemeUse.Highlight)
{
errors.Add("{raccolta} si usa solo nello schema per le raccolte in evidenza.");
}
@@ -110,7 +139,15 @@ public sealed class NamingScheme
segments.RemoveAt(0);
}
if (!used.Contains("codice") && !used.Contains("n"))
if (use == NamingSchemeUse.ProfilePicture)
{
// One file per picture: {n} is always 1, and {codice} (the start of the SHA-256) tells the pictures apart.
if (!used.Contains("codice"))
{
warnings.Add("Senza {codice} due foto del profilo possono avere lo stesso nome: Febe aggiunge un numero per distinguerle.");
}
}
else if (!used.Contains("codice") && !used.Contains("n"))
{
warnings.Add("Senza {codice} e {n} più file possono avere lo stesso nome: Febe aggiunge un numero per distinguerli.");
}
@@ -119,12 +156,12 @@ public sealed class NamingScheme
warnings.Add("Senza {n} i file di un post con più foto o video hanno lo stesso nome: Febe aggiunge un numero per distinguerli.");
}
if (forHighlights && !used.Contains("raccolta"))
if (use == NamingSchemeUse.Highlight && !used.Contains("raccolta"))
{
warnings.Add("Senza {raccolta} i contenuti delle diverse raccolte finiscono nella stessa cartella.");
}
return new NamingSchemeValidation(new NamingScheme(text.Trim(), forHighlights, segments), [], warnings);
return new NamingSchemeValidation(new NamingScheme(text.Trim(), use, segments), [], warnings);
}
/// <summary>
@@ -241,7 +278,20 @@ public sealed class NamingScheme
private readonly record struct Token(bool IsPlaceholder, string Value);
}
/// <summary>Result of <see cref="NamingScheme.Validate"/>.</summary>
/// <summary>Which files a naming scheme names (spec §4.7).</summary>
public enum NamingSchemeUse
{
/// <summary>Posts, stories and tagged posts.</summary>
General,
/// <summary>Contents of highlight collections (accepts <c>{raccolta}</c>).</summary>
Highlight,
/// <summary>Profile pictures.</summary>
ProfilePicture,
}
/// <summary>Result of <see cref="NamingScheme.Validate(string?, NamingSchemeUse)"/>.</summary>
public sealed record NamingSchemeValidation(NamingScheme? Scheme, IReadOnlyList<string> Errors, IReadOnlyList<string> Warnings)
{
public bool IsValid => Scheme is not null && Errors.Count == 0;
@@ -272,11 +322,16 @@ public sealed record NamingValues(
}
}
/// <summary>The two configurable schemes (spec §4.7): general and for highlight collections.</summary>
public sealed record LibraryNaming(NamingScheme General, NamingScheme Highlight)
/// <summary>The three configurable schemes (spec §4.7): general, highlight collections and profile pictures.</summary>
public sealed record LibraryNaming(NamingScheme General, NamingScheme Highlight, NamingScheme ProfilePicture)
{
public static LibraryNaming Default { get; } = new(NamingScheme.General, NamingScheme.Highlight);
public static LibraryNaming Default { get; } = new(NamingScheme.General, NamingScheme.Highlight, NamingScheme.ProfilePicture);
/// <summary>The scheme that applies to an entry kind.</summary>
public NamingScheme For(EntryKind kind) => kind == EntryKind.Highlight ? Highlight : General;
public NamingScheme For(EntryKind kind) => kind switch
{
EntryKind.Highlight => Highlight,
EntryKind.ProfilePicture => ProfilePicture,
_ => General,
};
}
+3
View File
@@ -28,6 +28,9 @@ public static class SettingKeys
/// <summary>Naming scheme for highlight collections.</summary>
public const string HighlightNamingScheme = "libreria.schema-evidenza";
/// <summary>Naming scheme for profile pictures.</summary>
public const string ProfilePictureNamingScheme = "libreria.schema-profilo";
/// <summary>«Imposta la data del file a quella di pubblicazione» (true/false).</summary>
public const string SetFileTimeToPublication = "libreria.data-file-pubblicazione";
}