Full generation, file type cleanup
This commit is contained in:
@ -0,0 +1,148 @@
|
||||
import SwiftUI
|
||||
|
||||
struct GenerationContentView: View {
|
||||
|
||||
@Environment(\.language)
|
||||
private var language
|
||||
|
||||
@EnvironmentObject
|
||||
private var content: Content
|
||||
|
||||
@Binding
|
||||
private var selectedSection: SettingsSection
|
||||
|
||||
init(selected: Binding<SettingsSection>) {
|
||||
self._selectedSection = selected
|
||||
}
|
||||
|
||||
@State
|
||||
private var isGeneratingWebsite = false
|
||||
|
||||
@State
|
||||
private var generatorText: String = ""
|
||||
|
||||
var body: some View {
|
||||
switch selectedSection {
|
||||
case .folders, .navigationBar, .postFeed, .tagOverview:
|
||||
generationView
|
||||
case .pages:
|
||||
PageSettingsContentView()
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var generationView: some View {
|
||||
VStack(alignment: .leading) {
|
||||
Text("Website Generation")
|
||||
.font(.largeTitle)
|
||||
.bold()
|
||||
Text("Regenerate the website and monitor the output")
|
||||
.foregroundStyle(.secondary)
|
||||
.padding(.bottom, 30)
|
||||
|
||||
HStack {
|
||||
Button(action: generateFullWebsite) {
|
||||
Text("Generate")
|
||||
}
|
||||
Text(generatorText)
|
||||
Spacer()
|
||||
if isGeneratingWebsite {
|
||||
ProgressView()
|
||||
.progressViewStyle(.circular)
|
||||
.frame(height: 25)
|
||||
}
|
||||
}
|
||||
.disabled(isGeneratingWebsite)
|
||||
Text(content.generationStatus)
|
||||
.font(.subheadline)
|
||||
.padding()
|
||||
HStack(spacing: 8) {
|
||||
Text("\(content.results.imagesToGenerate.count) images")
|
||||
Text("\(content.results.externalLinks.count) external links")
|
||||
Text("\(content.results.resultCount) items processed")
|
||||
Text("\(content.results.requiredFiles.count) files")
|
||||
}
|
||||
List {
|
||||
Section("Inaccessible files") {
|
||||
ForEach(content.results.inaccessibleFiles.sorted()) { file in
|
||||
Text(file.id)
|
||||
}
|
||||
}
|
||||
Section("Unparsable files") {
|
||||
ForEach(content.results.unparsableFiles.sorted()) { file in
|
||||
Text(file.id)
|
||||
}
|
||||
}
|
||||
Section("Missing files") {
|
||||
ForEach(content.results.missingFiles.sorted(), id: \.self) { file in
|
||||
Text(file)
|
||||
}
|
||||
}
|
||||
Section("Missing tags") {
|
||||
ForEach(content.results.missingTags.sorted(), id: \.self) { tag in
|
||||
Text(tag)
|
||||
}
|
||||
}
|
||||
Section("Missing pages") {
|
||||
ForEach(content.results.missingPages.sorted(), id: \.self) { page in
|
||||
Text(page)
|
||||
}
|
||||
}
|
||||
Section("Invalid commands") {
|
||||
ForEach(content.results.invalidCommands.sorted(), id: \.self) { markdown in
|
||||
Text(markdown)
|
||||
}
|
||||
}
|
||||
Section("Warnings") {
|
||||
ForEach(content.results.warnings.sorted(), id: \.self) { warning in
|
||||
Text(warning)
|
||||
}
|
||||
}
|
||||
Section("Unsaved output files") {
|
||||
ForEach(content.results.unsavedOutputFiles.sorted(), id: \.self) { file in
|
||||
Text(file)
|
||||
}
|
||||
}
|
||||
}
|
||||
}.padding()
|
||||
}
|
||||
|
||||
private func generateFullWebsite() {
|
||||
DispatchQueue.main.async {
|
||||
content.generateWebsiteInAllLanguages()
|
||||
}
|
||||
#warning("Update feed generation")
|
||||
/*
|
||||
guard let url = content.storage.outputPath else {
|
||||
print("Invalid output path")
|
||||
return
|
||||
}
|
||||
|
||||
guard FileManager.default.fileExists(atPath: url.path) else {
|
||||
print("Missing output folder")
|
||||
return
|
||||
}
|
||||
isGeneratingWebsite = true
|
||||
DispatchQueue.global(qos: .userInitiated).async {
|
||||
let generator = LocalizedWebsiteGenerator(
|
||||
content: content,
|
||||
language: language)
|
||||
_ = generator.generateWebsite { text in
|
||||
DispatchQueue.main.async {
|
||||
self.generatorText = text
|
||||
}
|
||||
}
|
||||
DispatchQueue.main.async {
|
||||
isGeneratingWebsite = false
|
||||
self.generatorText = "Generation complete"
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
GenerationContentView(selected: .constant(.folders))
|
||||
.environmentObject(Content.mock)
|
||||
.padding()
|
||||
}
|
Reference in New Issue
Block a user