Full page content, fixes, cleaner settings

This commit is contained in:
Christoph Hagen
2024-12-13 11:26:34 +01:00
parent efc9234917
commit b3b8c9a610
50 changed files with 1351 additions and 607 deletions

View File

@ -16,4 +16,10 @@ final class LocalizedPostSettings: ObservableObject {
self.description = description
self.feedUrlPrefix = feedUrlPrefix
}
init(file: LocalizedPostSettingsFile) {
self.title = file.feedTitle
self.description = file.feedDescription
self.feedUrlPrefix = file.feedUrlPrefix
}
}

View File

@ -1,15 +0,0 @@
import Foundation
final class LocalizedSettings: ObservableObject {
@Published
var navigationBarIconDescription: String
@Published
var posts: LocalizedPostSettings
init(navigationBarIconDescription: String, posts: LocalizedPostSettings) {
self.navigationBarIconDescription = navigationBarIconDescription
self.posts = posts
}
}

View File

@ -1,17 +0,0 @@
import Foundation
final class NavigationBarSettings: ObservableObject {
/// The path to the main icon in the navigation bar
@Published
var iconPath: String
/// The tags to show in the navigation bar
@Published
var tags: [Tag]
init(iconPath: String, tags: [Tag]) {
self.iconPath = iconPath
self.tags = tags
}
}

View File

@ -13,9 +13,17 @@ final class PageSettings: ObservableObject {
@Published
var largeImageWidth: Int
init(pageUrlPrefix: String, contentWidth: Int, largeImageWidth: Int) {
self.pageUrlPrefix = pageUrlPrefix
self.contentWidth = contentWidth
self.largeImageWidth = largeImageWidth
@Published
var pageLinkImageSize: Int
@Published
var javascriptFilesPath: String
init(file: PageSettingsFile) {
self.pageUrlPrefix = file.pageUrlPrefix
self.contentWidth = file.contentWidth
self.largeImageWidth = file.largeImageWidth
self.pageLinkImageSize = file.pageLinkImageSize
self.javascriptFilesPath = file.javascriptFilesPath
}
}

View File

@ -0,0 +1,31 @@
import Foundation
final class PathSettings: ObservableObject {
@Published
var outputDirectoryPath: String
@Published
var pagesOutputFolderPath: String
@Published
var imagesOutputFolderPath: String
@Published
var filesOutputFolderPath: String
@Published
var videosOutputFolderPath: String
@Published
var tagsOutputFolderPath: String
init(file: PathSettingsFile) {
self.outputDirectoryPath = file.outputDirectoryPath
self.pagesOutputFolderPath = file.pagesOutputFolderPath
self.imagesOutputFolderPath = file.imagesOutputFolderPath
self.filesOutputFolderPath = file.filesOutputFolderPath
self.videosOutputFolderPath = file.videosOutputFolderPath
self.tagsOutputFolderPath = file.tagsOutputFolderPath
}
}

View File

@ -14,4 +14,9 @@ final class PostSettings: ObservableObject {
self.postsPerPage = postsPerPage
self.contentWidth = contentWidth
}
init(file: PostSettingsFile) {
self.postsPerPage = file.postsPerPage
self.contentWidth = file.contentWidth
}
}

View File

@ -3,10 +3,11 @@ import Foundation
final class Settings: ObservableObject {
@Published
var outputDirectoryPath: String
var paths: PathSettings
/// The tags to show in the navigation bar
@Published
var navigationBar: NavigationBarSettings
var navigationTags: [Tag]
@Published
var posts: PostSettings
@ -15,24 +16,28 @@ final class Settings: ObservableObject {
var pages: PageSettings
@Published
var german: LocalizedSettings
var german: LocalizedPostSettings
@Published
var english: LocalizedSettings
var english: LocalizedPostSettings
init(outputDirectoryPath: String, navigationBar: NavigationBarSettings, posts: PostSettings, pages: PageSettings, german: LocalizedSettings, english: LocalizedSettings) {
self.outputDirectoryPath = outputDirectoryPath
self.navigationBar = navigationBar
init(paths: PathSettings, navigationTags: [Tag], posts: PostSettings, pages: PageSettings, german: LocalizedPostSettings, english: LocalizedPostSettings) {
self.paths = paths
self.navigationTags = navigationTags
self.posts = posts
self.pages = pages
self.german = german
self.english = english
}
func localized(in language: ContentLanguage) -> LocalizedSettings {
func localized(in language: ContentLanguage) -> LocalizedPostSettings {
switch language {
case .english: return english
case .german: return german
}
}
var outputDirectory: URL {
URL(fileURLWithPath: paths.outputDirectoryPath)
}
}