Skip to content

armgit / Filee

Public Imported from GitHub
0

Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.

Merge pull request #381: Add iCalendar (.ics) to CSV conversion and back (#340) (schema 36)

KnifeLemon39538f9af0fc
diff --cc src/Filee.Core/Formats/FormatRegistry.cs
index 97939fbd,ac0549df..2542fed9
--- a/src/Filee.Core/Formats/FormatRegistry.cs
+++ b/src/Filee.Core/Formats/FormatRegistry.cs
@@@ -165,8 -163,7 +165,9 @@@ public static class FormatRegistr
new("toml", "TOML", FormatCategory.Data, ["toml"]),
new("xml", "XML", FormatCategory.Data, ["xml"]),
new("vcf", "vCard", FormatCategory.Data, ["vcf", "vcard"]),
+ // A browser's recorded network requests (HTTP Archive): JSON, read as one table row per request (issue #328).
+ new("har", "HAR", FormatCategory.Data, ["har"], Writable: false),
+ new("ics", "iCalendar", FormatCategory.Data, ["ics", "ical"]),
// E-books
new("epub", "EPUB", FormatCategory.Ebook, ["epub"]),
diff --cc src/Filee.Core/Settings/UserDataStore.cs
index 25d2b604,69a4c909..d9a1016b
--- a/src/Filee.Core/Settings/UserDataStore.cs
+++ b/src/Filee.Core/Settings/UserDataStore.cs
@@@ -750,34 -750,35 +750,63 @@@ internal static class SettingsMigration
// v32: logs and script source, Video CD DAT and Workbench archives learn their donuts; custom claims stay put.
if (from < 32)
changed |= LearnExtensions(profiles, out _, ["log", "py", "pac", "bat", "command", "dat", "wbpz"]);
+ // v33: HAR network logs and raw H.265 / H.264 camera streams learn their donuts (custom claims stay put), and
+ // "Trim transparent borders" comes in after "Remove background".
+ if (from < 33)
+ {
+ changed |= LearnExtensions(profiles, out _, ["har", "h265", "265", "hevc", "h264", "264"]);
+ // "Trim transparent borders" after "Remove background", in the library and on the images donut's back face
+ // when it has room and the user hasn't put it there.
+ if (BuiltInData.TrimPresets().Single() is var trim && presets.All(p => p.Id != trim.Id))
+ {
+ var at = presets.FindIndex(p => p.Id == "remove-background");
+ presets.Insert(at < 0 ? presets.Count : at + 1, trim);
+ changed = true;
+ }
+ if (profiles.FirstOrDefault(p => p.Id == "images") is { BackPresetIds: { } back } images
+ && !back.Contains("trim-transparent") && !images.PresetIds.Contains("trim-transparent")
+ && back.Count < ToolbarProfile.MaxSlices)
+ {
+ var after = back.IndexOf("remove-background");
+ back.Insert(after < 0 ? back.Count(id => id != "zip-all") : after + 1, "trim-transparent");
+ changed = true;
+ }
+ }
+ // v34: Lua scripts and CSS style sheets learn the text donut; custom claims stay put.
+ if (from < 34)
+ changed |= LearnExtensions(profiles, out _, ["lua", "css"]);
+ // v35: HP-GL plot files learn their donut; custom claims stay put.
+ if (from < 35)
+ changed |= LearnExtensions(profiles, out _, ["plt", "hpgl", "hpg", "hgl"]);
+ // v33: iCalendar (.ics, .ical) on the data donut, and "iCalendar" (CSV → ICS) after "vCard" on the back of the
+ // spreadsheets donut when it has room; custom claims stay put.
+ if (from < 33)
+ {
+ changed |= LearnExtensions(profiles, out _, ["ics", "ical"]);
+ changed |= AddCalendarPreset(presets, profiles);
+ }
+ return changed;
+ }
+
+ private static bool AddCalendarPreset(List<Preset> presets, List<ToolbarProfile> profiles)
+ {
+ var changed = false;
+ if (presets.All(p => p.Id != "to-ics"))
+ {
+ var preset = BuiltInData.DataPresets().Single(p => p.Id == "to-ics");
+ var after = presets.FindIndex(p => p.Id == "to-vcf");
+ presets.Insert(after < 0 ? presets.Count : after + 1, preset);
+ changed = true;
+ }
+
+ if (profiles.FirstOrDefault(p => p.Id == "spreadsheets") is { BackPresetIds: { } back }
+ && !back.Contains("to-ics") && back.Count < ToolbarProfile.MaxSlices)
+ {
+ var after = back.IndexOf("to-vcf");
+ var beforeZip = back.IndexOf("zip-all");
+ back.Insert(after >= 0 ? after + 1 : beforeZip >= 0 ? beforeZip : back.Count, "to-ics");
+ changed = true;
+ }
return changed;
}
diff --cc src/Filee.Engines/Data/DataConverter.cs
index 9053186e,c0b81dba..5ded238d
--- a/src/Filee.Engines/Data/DataConverter.cs
+++ b/src/Filee.Engines/Data/DataConverter.cs
@@@ -2,8 -2,7 +2,8 @@@
// in-process. Every format is read into one tree (DataTree) and written from it, so structure and types carry over as
// far as the target can hold them; see the format files for what each one loses (TOML has no null, XML no types,
// CSV only tables). Output is UTF-8 without BOM (CSV: with BOM, like the spreadsheet engine), indented by two spaces.
- // Spreadsheets reach JSON and the others through CSV (XLSX → CSV → JSON), contacts through CSV as well. HAR network
- // logs are read as JSON, and become a table of their requests (HarData).
-// Spreadsheets reach JSON and the others through CSV (XLSX → CSV → JSON), contacts and calendars through CSV as well.
++// Spreadsheets reach JSON and the others through CSV (XLSX → CSV → JSON), contacts and calendars through CSV as well. HAR
++// network logs are read as JSON, and become a table of their requests (HarData).
using System.Text;
using Filee.Core.Conversion;
@@@ -13,7 -12,7 +13,7 @@@ using Filee.Engines.Office.Sheets
namespace Filee.Engines.Data;
- /// <summary>JSON, JSON Lines, YAML, TOML, XML and CSV into each other; vCard ↔ CSV; HAR → all of them.</summary>
-/// <summary>JSON, JSON Lines, YAML, TOML, XML and CSV into each other; vCard and iCalendar ↔ CSV.</summary>
++/// <summary>JSON, JSON Lines, YAML, TOML, XML and CSV into each other; vCard and iCalendar ↔ CSV; HAR → all of them.</summary>
public sealed class DataConverter : IConverter
{
private static readonly string[] Trees = ["json", "jsonl", "yaml", "toml", "xml"];
@@@ -29,7 -28,8 +29,9 @@@
.. Trees.Select(to => new ConversionEdge("csv", to)),
new("vcf", "csv"),
new("csv", "vcf"),
+ .. Trees.Append("csv").Select(to => new ConversionEdge("har", to)),
+ new("ics", "csv"),
+ new("csv", "ics"),
];
public EngineStatus GetStatus() =>