Rework path storage, add start screen
This commit is contained in:
@@ -4,10 +4,8 @@ import Combine
|
||||
|
||||
final class Content: ObservableObject {
|
||||
|
||||
let storage = Storage()
|
||||
|
||||
@Published
|
||||
var storageIsInitialized = false
|
||||
@ObservedObject
|
||||
var storage = Storage()
|
||||
|
||||
@Published
|
||||
var settings: Settings
|
||||
@@ -28,10 +26,10 @@ final class Content: ObservableObject {
|
||||
var tagOverview: TagOverviewPage?
|
||||
|
||||
@Published
|
||||
var results: [ItemId : PageGenerationResults] = [:]
|
||||
private(set) var results: [ItemId : PageGenerationResults] = [:]
|
||||
|
||||
@Published
|
||||
var isGeneratingWebsite = false
|
||||
private(set) var isGeneratingWebsite = false
|
||||
|
||||
init(settings: Settings,
|
||||
posts: [Post],
|
||||
@@ -45,8 +43,6 @@ final class Content: ObservableObject {
|
||||
self.tags = tags
|
||||
self.files = files
|
||||
self.tagOverview = tagOverview
|
||||
|
||||
initialize()
|
||||
}
|
||||
|
||||
init() {
|
||||
@@ -56,28 +52,25 @@ final class Content: ObservableObject {
|
||||
self.tags = []
|
||||
self.files = []
|
||||
self.tagOverview = nil
|
||||
|
||||
initialize()
|
||||
}
|
||||
|
||||
private func initialize() {
|
||||
guard storage.check(contentPath: settings.paths.contentDirectoryPath) == .nominal else {
|
||||
storageIsInitialized = false
|
||||
return
|
||||
}
|
||||
|
||||
storage.check(outputPath: settings.paths.outputDirectoryPath)
|
||||
|
||||
do {
|
||||
try storage.createFolderStructure()
|
||||
storageIsInitialized = true
|
||||
} catch {
|
||||
print("Failed to initialize storage: \(error)")
|
||||
storageIsInitialized = false
|
||||
}
|
||||
}
|
||||
|
||||
var images: [FileResource] {
|
||||
files.filter { $0.type.isImage }
|
||||
}
|
||||
|
||||
func set(isGenerating: Bool) {
|
||||
DispatchQueue.main.async {
|
||||
self.isGeneratingWebsite = isGenerating
|
||||
}
|
||||
}
|
||||
|
||||
func add(_ file: FileResource) {
|
||||
// TODO: Insert at correct index?
|
||||
files.insert(file, at: 0)
|
||||
}
|
||||
|
||||
func add(_ page: Page) {
|
||||
// TODO: Insert at correct index?
|
||||
pages.insert(page, at: 0)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user