Lichtkasten v0.1: Culling, IPTC (PM-kompatibel), Vorlagen, FTP/Immich, Lightroom-Bridge

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012bGzgsxrmbBhDzeMV2L57D
This commit is contained in:
Lichtkasten DevandClaude Opus 5.5 committed 2026-11-03 22:40:28 +00:00
commit e13cbf416d
37 files changed
+4431

No files matched your search

@@ -0,0 +1,81 @@
import Foundation
import LichtkastenCore
enum KeyScheme: String, Codable, CaseIterable {
case lightroom = "Lightroom (0–5 Sterne, 6–9 Farben)"
case photoMechanic = "Photo Mechanic (1–8 Farbklassen, ⌥1–5 Sterne)"
}
struct LightroomSettings: Codable, Hashable {
var developPreset = ""
var collection = "Lichtkasten"
var exportFolder = ""
var jpegQuality = 90
var longEdge = 0
var sharpening = "none"
var colorSpace = "sRGB"
var rewriteIPTCAfterExport = true
/// Upload targets after export: FTP destination ids and/or "immich".
var autoUploadTargets: [String] = []
}
struct AppSettings: Codable {
var exiftoolPath = ""
var dateFormat = "dd.MM.yyyy"
var keyScheme: KeyScheme = .lightroom
var thumbnailSize: Double = 200
var autoAdvance = true // after rating/tagging jump to next image (PM: "Auto-advance")
var ftpDestinations: [FTPDestination] = []
var immich = ImmichSettings()
var lightroom = LightroomSettings()
var ingest = IngestSettings()
var recentFolders: [String] = []
var favoriteFolders: [String] = []
var lastTemplateID: UUID?
init() {}
// Tolerant decoding so new settings never wipe old ones.
init(from decoder: Decoder) throws {
let c = try decoder.container(keyedBy: CodingKeys.self)
let d = AppSettings()
exiftoolPath = (try? c.decode(String.self, forKey: .exiftoolPath)) ?? d.exiftoolPath
dateFormat = (try? c.decode(String.self, forKey: .dateFormat)) ?? d.dateFormat
keyScheme = (try? c.decode(KeyScheme.self, forKey: .keyScheme)) ?? d.keyScheme
thumbnailSize = (try? c.decode(Double.self, forKey: .thumbnailSize)) ?? d.thumbnailSize
autoAdvance = (try? c.decode(Bool.self, forKey: .autoAdvance)) ?? d.autoAdvance
ftpDestinations = (try? c.decode([FTPDestination].self, forKey: .ftpDestinations)) ?? d.ftpDestinations
immich = (try? c.decode(ImmichSettings.self, forKey: .immich)) ?? d.immich
lightroom = (try? c.decode(LightroomSettings.self, forKey: .lightroom)) ?? d.lightroom
ingest = (try? c.decode(IngestSettings.self, forKey: .ingest)) ?? d.ingest
recentFolders = (try? c.decode([String].self, forKey: .recentFolders)) ?? d.recentFolders
favoriteFolders = (try? c.decode([String].self, forKey: .favoriteFolders)) ?? d.favoriteFolders
lastTemplateID = try? c.decode(UUID.self, forKey: .lastTemplateID)
}
}
enum Storage {
static var appSupport: URL {
let u = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0]
.appendingPathComponent("Lichtkasten", isDirectory: true)
try? FileManager.default.createDirectory(at: u, withIntermediateDirectories: true)
return u
}
static var settingsURL: URL { appSupport.appendingPathComponent("settings.json") }
static var templatesURL: URL { appSupport.appendingPathComponent("templates.json") }
static var codesURL: URL { appSupport.appendingPathComponent("codes.json") }
static func load<T: Decodable>(_ type: T.Type, from url: URL) -> T? {
guard let d = try? Data(contentsOf: url) else { return nil }
let dec = JSONDecoder()
dec.dateDecodingStrategy = .iso8601
return try? dec.decode(T.self, from: d)
}
static func save<T: Encodable>(_ value: T, to url: URL) {
let enc = JSONEncoder()
enc.outputFormatting = [.prettyPrinted, .sortedKeys]
enc.dateEncodingStrategy = .iso8601
if let d = try? enc.encode(value) { try? d.write(to: url, options: .atomic) }
}
}