Improve tag and images view, save website settings
This commit is contained in:
@ -242,8 +242,26 @@ final class Storage {
|
||||
try fileNames(in: videosFolder)
|
||||
}
|
||||
|
||||
// MARK: Website data
|
||||
|
||||
private var websiteDataUrl: URL {
|
||||
baseFolder.appending(path: "website-data.json", directoryHint: .notDirectory)
|
||||
}
|
||||
|
||||
func loadWebsiteData() throws -> WebsiteDataFile {
|
||||
try read(at: websiteDataUrl)
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
func save(websiteData: WebsiteDataFile) -> Bool {
|
||||
write(websiteData, type: "Website Data", id: "-", to: websiteDataUrl)
|
||||
}
|
||||
|
||||
// MARK: Writing files
|
||||
|
||||
/**
|
||||
Encode a value and write it to a file, if the content changed
|
||||
*/
|
||||
private func write<T>(_ value: T, type: String, id: String, to file: URL) -> Bool where T: Encodable {
|
||||
let content: Data
|
||||
do {
|
||||
@ -255,6 +273,9 @@ final class Storage {
|
||||
return write(data: content, type: type, id: id, to: file)
|
||||
}
|
||||
|
||||
/**
|
||||
Write data to a file if the content changed
|
||||
*/
|
||||
private func write(data: Data, type: String, id: String, to file: URL) -> Bool {
|
||||
if fm.fileExists(atPath: file.path()) {
|
||||
// Check if content is the same, to prevent unnecessary writes
|
||||
|
@ -2,6 +2,8 @@ import Foundation
|
||||
|
||||
struct WebsiteDataFile {
|
||||
|
||||
let navigationTags: [String]
|
||||
|
||||
let german: LocalizedWebsiteDataFile
|
||||
|
||||
let english: LocalizedWebsiteDataFile
|
||||
@ -24,26 +26,3 @@ struct LocalizedWebsiteDataFile {
|
||||
extension LocalizedWebsiteDataFile: Codable {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
let navigationItems: [FeedNavigationLink] = [
|
||||
.init(text: .init(en: "Projects", de: "Projekte"),
|
||||
url: .init(en: "/projects", de: "/projekte")),
|
||||
.init(text: .init(en: "Adventures", de: "Abenteuer"),
|
||||
url: .init(en: "/adventures", de: "/abenteuer")),
|
||||
.init(text: .init(en: "Services", de: "Dienste"),
|
||||
url: .init(en: "/services", de: "/dienste")),
|
||||
.init(text: .init(en: "Tags", de: "Kategorien"),
|
||||
url: .init(en: "/tags", de: "/kategorien")),
|
||||
]
|
||||
|
||||
let feed = Feed(
|
||||
language: language,
|
||||
title: .init(en: "Blog | CH", de: "Blog | CH"),
|
||||
description: .init(en: "The latests posts, projects and adventures",
|
||||
de: "Die neusten Beiträge, Projekte und Abenteuer"),
|
||||
iconDescription: .init(en: "An icon consisting of the letters C and H in blue and orange",
|
||||
de: "Ein Logo aus den Buchstaben C und H in Blau und Orange"),
|
||||
navigationItems: navigationItems,
|
||||
posts: posts)
|
||||
*/
|
||||
|
Reference in New Issue
Block a user