Explicit asset property
This commit is contained in:
@ -43,6 +43,10 @@ final class FileResource: Item, LocalizedItem {
|
||||
@Published
|
||||
var modifiedDate: Date
|
||||
|
||||
/// Identify this file as an asset to be placed in the `asset` folder on generation
|
||||
@Published
|
||||
var isAsset: Bool
|
||||
|
||||
/// The dimensions of the image
|
||||
@Published
|
||||
var imageDimensions: CGSize? = nil
|
||||
@ -63,7 +67,8 @@ final class FileResource: Item, LocalizedItem {
|
||||
generatedImageVersions: Set<String> = [],
|
||||
customOutputPath: String? = nil,
|
||||
addedDate: Date = .now,
|
||||
modifiedDate: Date = .now) {
|
||||
modifiedDate: Date = .now,
|
||||
isAsset: Bool = false) {
|
||||
self.type = FileType(fileExtension: id.fileExtension)
|
||||
self.isExternallyStored = isExternallyStored
|
||||
self.german = german
|
||||
@ -74,6 +79,7 @@ final class FileResource: Item, LocalizedItem {
|
||||
self.customOutputPath = customOutputPath
|
||||
self.addedDate = addedDate
|
||||
self.modifiedDate = modifiedDate
|
||||
self.isAsset = isAsset
|
||||
super.init(content: content, id: id)
|
||||
}
|
||||
|
||||
@ -91,6 +97,7 @@ final class FileResource: Item, LocalizedItem {
|
||||
self.customOutputPath = nil
|
||||
self.addedDate = Date.now
|
||||
self.modifiedDate = Date.now
|
||||
self.isAsset = false
|
||||
super.init(content: content, id: resourceImage)
|
||||
}
|
||||
|
||||
@ -306,6 +313,9 @@ final class FileResource: Item, LocalizedItem {
|
||||
}
|
||||
|
||||
private var pathPrefix: String {
|
||||
if isAsset {
|
||||
return content.settings.paths.assetsOutputFolderPath
|
||||
}
|
||||
if type.isImage {
|
||||
return content.settings.paths.imagesOutputFolderPath
|
||||
}
|
||||
@ -315,9 +325,6 @@ final class FileResource: Item, LocalizedItem {
|
||||
if type.isAudio {
|
||||
return content.settings.paths.audioOutputFolderPath
|
||||
}
|
||||
if type.isAsset {
|
||||
return content.settings.paths.assetsOutputFolderPath
|
||||
}
|
||||
return content.settings.paths.filesOutputFolderPath
|
||||
}
|
||||
|
||||
@ -365,7 +372,8 @@ extension FileResource: StorageItem {
|
||||
generatedImageVersions: Set(data.generatedImages ?? []),
|
||||
customOutputPath: data.customOutputPath,
|
||||
addedDate: data.addedDate,
|
||||
modifiedDate: data.modifiedDate)
|
||||
modifiedDate: data.modifiedDate,
|
||||
isAsset: data.isAsset ?? false)
|
||||
savedData = data
|
||||
}
|
||||
|
||||
@ -378,7 +386,8 @@ extension FileResource: StorageItem {
|
||||
version: version,
|
||||
sourceUrl: sourceUrl,
|
||||
addedDate: addedDate,
|
||||
modifiedDate: modifiedDate)
|
||||
modifiedDate: modifiedDate,
|
||||
isAsset: isAsset ? true : nil)
|
||||
}
|
||||
|
||||
/// This struct holds metadata about a file resource that is stored in the content folder.
|
||||
@ -391,6 +400,7 @@ extension FileResource: StorageItem {
|
||||
let sourceUrl: String?
|
||||
let addedDate: Date
|
||||
let modifiedDate: Date
|
||||
let isAsset: Bool?
|
||||
}
|
||||
|
||||
func saveToDisk(_ data: Data) -> Bool {
|
||||
|
Reference in New Issue
Block a user