Move required files to settings
This commit is contained in:
@ -312,8 +312,6 @@ extension Content {
|
||||
let results = results.makeResults(for: page, in: language)
|
||||
let pageGenerator = PageGenerator(content: self)
|
||||
|
||||
results.require(files: page.requiredFiles)
|
||||
|
||||
let relativePageUrl = page.absoluteUrl(in: language)
|
||||
let filePath = relativePageUrl + ".html"
|
||||
let pageUrl = settings.general.url + relativePageUrl
|
||||
|
@ -40,10 +40,6 @@ final class Page: Item, DateItem, LocalizedItem {
|
||||
@Published
|
||||
var tags: [Tag]
|
||||
|
||||
/// Additional files to copy, because the page content references them
|
||||
@Published
|
||||
var requiredFiles: [FileResource]
|
||||
|
||||
var savedData: Data?
|
||||
|
||||
init(content: Content,
|
||||
@ -56,8 +52,7 @@ final class Page: Item, DateItem, LocalizedItem {
|
||||
endDate: Date?,
|
||||
german: LocalizedPage,
|
||||
english: LocalizedPage,
|
||||
tags: [Tag],
|
||||
requiredFiles: [FileResource]) {
|
||||
tags: [Tag]) {
|
||||
self.externalLink = externalLink
|
||||
self.isDraft = isDraft
|
||||
self.createdDate = createdDate
|
||||
@ -68,7 +63,6 @@ final class Page: Item, DateItem, LocalizedItem {
|
||||
self.german = german
|
||||
self.english = english
|
||||
self.tags = tags
|
||||
self.requiredFiles = requiredFiles
|
||||
|
||||
super.init(content: content, id: id)
|
||||
}
|
||||
@ -186,9 +180,6 @@ final class Page: Item, DateItem, LocalizedItem {
|
||||
}
|
||||
|
||||
func remove(_ file: FileResource) {
|
||||
if requiredFiles.contains(file) {
|
||||
requiredFiles.remove(file)
|
||||
}
|
||||
english.linkPreview.remove(file)
|
||||
german.linkPreview.remove(file)
|
||||
}
|
||||
@ -210,8 +201,7 @@ extension Page: StorageItem {
|
||||
endDate: data.endDate,
|
||||
german: .init(context: context, data: data.german),
|
||||
english: .init(context: context, data: data.english),
|
||||
tags: data.tags.compactMap(context.tag),
|
||||
requiredFiles: data.requiredFiles?.compactMap(context.file) ?? [])
|
||||
tags: data.tags.compactMap(context.tag))
|
||||
savedData = data
|
||||
}
|
||||
|
||||
@ -226,7 +216,6 @@ extension Page: StorageItem {
|
||||
let endDate: Date?
|
||||
let german: LocalizedPage.Data
|
||||
let english: LocalizedPage.Data
|
||||
let requiredFiles: [String]?
|
||||
}
|
||||
|
||||
|
||||
@ -240,8 +229,7 @@ extension Page: StorageItem {
|
||||
startDate: startDate,
|
||||
endDate: endDate,
|
||||
german: german.data,
|
||||
english: english.data,
|
||||
requiredFiles: requiredFiles.nonEmpty?.map { $0.id }.sorted())
|
||||
english: english.data)
|
||||
}
|
||||
|
||||
func saveToDisk(_ data: Data) -> Bool {
|
||||
|
@ -172,8 +172,7 @@ final class Post: Item, DateItem, LocalizedItem {
|
||||
endDate: endDate,
|
||||
german: german,
|
||||
english: english,
|
||||
tags: tags,
|
||||
requiredFiles: [])
|
||||
tags: tags)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,10 @@ final class GeneralSettings: ObservableObject {
|
||||
@Published
|
||||
var urlForPushNotification: String?
|
||||
|
||||
init(url: String, linkPreviewImageWidth: Int, linkPreviewImageHeight: Int, remoteUserForUpload: String, remotePortForUpload: Int, remotePathForUpload: String, urlForPushNotification: String?) {
|
||||
@Published
|
||||
var requiredFiles: [FileResource]
|
||||
|
||||
init(url: String, linkPreviewImageWidth: Int, linkPreviewImageHeight: Int, remoteUserForUpload: String, remotePortForUpload: Int, remotePathForUpload: String, urlForPushNotification: String?, requiredFiles: [FileResource]) {
|
||||
self.url = url
|
||||
self.linkPreviewImageWidth = linkPreviewImageWidth
|
||||
self.linkPreviewImageHeight = linkPreviewImageHeight
|
||||
@ -35,12 +38,13 @@ final class GeneralSettings: ObservableObject {
|
||||
self.remotePortForUpload = remotePortForUpload
|
||||
self.remotePathForUpload = remotePathForUpload
|
||||
self.urlForPushNotification = urlForPushNotification
|
||||
self.requiredFiles = requiredFiles
|
||||
}
|
||||
}
|
||||
|
||||
extension GeneralSettings {
|
||||
|
||||
convenience init(data: Data) {
|
||||
convenience init(context: LoadingContext, data: Data) {
|
||||
self.init(
|
||||
url: data.url,
|
||||
linkPreviewImageWidth: data.linkPreviewImageWidth,
|
||||
@ -48,7 +52,8 @@ extension GeneralSettings {
|
||||
remoteUserForUpload: data.remoteUserForUpload,
|
||||
remotePortForUpload: data.remotePortForUpload,
|
||||
remotePathForUpload: data.remotePathForUpload,
|
||||
urlForPushNotification: data.urlForPushNotification)
|
||||
urlForPushNotification: data.urlForPushNotification,
|
||||
requiredFiles: data.requiredFiles?.compactMap(context.file) ?? [])
|
||||
}
|
||||
|
||||
var data: Data {
|
||||
@ -59,7 +64,8 @@ extension GeneralSettings {
|
||||
remoteUserForUpload: remoteUserForUpload,
|
||||
remotePortForUpload: remotePortForUpload,
|
||||
remotePathForUpload: remotePathForUpload,
|
||||
urlForPushNotification: urlForPushNotification)
|
||||
urlForPushNotification: urlForPushNotification,
|
||||
requiredFiles: requiredFiles.nonEmpty?.map { $0.id }.sorted())
|
||||
}
|
||||
|
||||
struct Data: Codable, Equatable {
|
||||
@ -70,5 +76,6 @@ extension GeneralSettings {
|
||||
let remotePortForUpload: Int
|
||||
let remotePathForUpload: String
|
||||
let urlForPushNotification: String?
|
||||
let requiredFiles: [String]?
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ extension Settings {
|
||||
|
||||
convenience init(context: LoadingContext, data: Settings.Data) {
|
||||
self.init(
|
||||
general: .init(data: data.general),
|
||||
general: .init(context: context, data: data.general),
|
||||
paths: .init(data: data.paths),
|
||||
navigation: .init(context: context, data: data.navigation),
|
||||
posts: .init(context: context, data: data.posts),
|
||||
@ -112,7 +112,8 @@ extension GeneralSettings {
|
||||
remoteUserForUpload: "user",
|
||||
remotePortForUpload: 22,
|
||||
remotePathForUpload: "/home/user/web",
|
||||
urlForPushNotification: nil)
|
||||
urlForPushNotification: nil,
|
||||
requiredFiles: [])
|
||||
}
|
||||
|
||||
extension AudioPlayerSettings {
|
||||
|
Reference in New Issue
Block a user