2022-08-19 18:05:06 +02:00
|
|
|
import Foundation
|
|
|
|
|
|
|
|
extension GenericMetadata {
|
|
|
|
|
|
|
|
/**
|
|
|
|
Metadata localized for a specific language.
|
|
|
|
*/
|
|
|
|
struct LocalizedMetadata {
|
|
|
|
|
|
|
|
/**
|
|
|
|
The language for which the content is specified.
|
|
|
|
- Note: This field is mandatory
|
|
|
|
*/
|
|
|
|
let language: String?
|
|
|
|
|
|
|
|
/**
|
|
|
|
The title used in the page header.
|
2022-12-01 14:50:26 +01:00
|
|
|
- Note: This field is mandatory
|
2022-08-19 18:05:06 +02:00
|
|
|
*/
|
|
|
|
let title: String?
|
|
|
|
|
|
|
|
/**
|
|
|
|
The subtitle used in the page header.
|
|
|
|
*/
|
|
|
|
let subtitle: String?
|
|
|
|
|
|
|
|
/**
|
|
|
|
The description text used in the page header
|
|
|
|
*/
|
|
|
|
let description: String?
|
|
|
|
|
|
|
|
/**
|
|
|
|
The title to use for the link preview.
|
|
|
|
|
|
|
|
If `nil` is specified, then the localized element `title` is used.
|
|
|
|
*/
|
|
|
|
let linkPreviewTitle: String?
|
|
|
|
|
|
|
|
/**
|
|
|
|
The file name of the link preview image.
|
|
|
|
- Note: The image must be located in the element folder.
|
|
|
|
- Note: If `nil` is specified, then the (localized) thumbnail is used.
|
|
|
|
*/
|
|
|
|
let linkPreviewImage: String?
|
|
|
|
|
|
|
|
/**
|
|
|
|
The description text for the link preview.
|
|
|
|
- Note: If `nil` is specified, then first the (localized) element `subtitle` is used.
|
|
|
|
If this is `nil` too, then the localized `description` of the element is used.
|
|
|
|
*/
|
|
|
|
let linkPreviewDescription: String?
|
|
|
|
|
|
|
|
/**
|
|
|
|
The text on the link to show the section page when previewing multiple sections on an overview page.
|
|
|
|
- Note: If this value is inherited from the parent, if it is not defined. There must be at least one
|
|
|
|
element in the path that defines this property.
|
|
|
|
*/
|
|
|
|
let moreLinkText: String?
|
|
|
|
|
|
|
|
/**
|
|
|
|
The text on the back navigation link of **contained** elements.
|
|
|
|
|
|
|
|
This text does not appear on the section page, but on the pages contained within the section.
|
|
|
|
- Note: If this property is not specified, then the root `backLinkText` is used.
|
|
|
|
- Note: The root element must specify this property.
|
|
|
|
*/
|
|
|
|
let backLinkText: String?
|
|
|
|
|
|
|
|
/**
|
|
|
|
The text to show as a title for placeholder boxes
|
|
|
|
|
|
|
|
Placeholders are included in missing pages.
|
|
|
|
- Note: If no value is specified, then this property is inherited from the parent. The root element must specify this property.
|
|
|
|
*/
|
|
|
|
let placeholderTitle: String?
|
|
|
|
|
|
|
|
/**
|
|
|
|
The text to show as a description for placeholder boxes
|
|
|
|
|
|
|
|
Placeholders are included in missing pages.
|
|
|
|
- Note: If no value is specified, then this property is inherited from the parent. The root element must specify this property.
|
|
|
|
*/
|
|
|
|
let placeholderText: String?
|
|
|
|
|
|
|
|
/**
|
|
|
|
An optional suffix to add to the title on a page.
|
|
|
|
|
|
|
|
This can be useful to express a different author, project grouping, etc.
|
|
|
|
*/
|
|
|
|
let titleSuffix: String?
|
|
|
|
|
|
|
|
/**
|
|
|
|
An optional suffix to add to the thumbnail title of a page.
|
|
|
|
|
|
|
|
This can be useful to express a different author, project grouping, etc.
|
|
|
|
*/
|
|
|
|
let thumbnailSuffix: String?
|
|
|
|
|
|
|
|
/**
|
|
|
|
A text to place in the top right corner of a large thumbnail.
|
|
|
|
|
|
|
|
The text should be a very short string to fit into the corner, like `soon`, or `draft`
|
|
|
|
|
|
|
|
- Note: This property is ignored if `thumbnailStyle` is not `large`.
|
|
|
|
*/
|
|
|
|
let cornerText: String?
|
|
|
|
|
|
|
|
/**
|
|
|
|
The external url to use instead of automatically generating the page.
|
|
|
|
|
|
|
|
This property can be used for links to other parts of the site, like additional services.
|
|
|
|
It can also be set to manually write a page.
|
|
|
|
*/
|
|
|
|
let externalUrl: String?
|
2022-09-25 17:19:07 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
The text to display for content related to the current page.
|
|
|
|
|
|
|
|
This property is mandatory at root level, and is propagated to child elements.
|
|
|
|
*/
|
|
|
|
let relatedContentText: String?
|
2022-09-25 22:07:34 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
The text to display on a navigation element pointing to this element as the previous page.
|
|
|
|
|
|
|
|
This property is mandatory at root level, and is propagated to child elements.
|
|
|
|
*/
|
|
|
|
let navigationTextAsPreviousPage: String?
|
|
|
|
|
|
|
|
/**
|
|
|
|
The text to display on the navigation element pointing to this element as the next page.
|
|
|
|
|
|
|
|
This property is mandatory at root level, and is propagated to child elements.
|
|
|
|
*/
|
|
|
|
let navigationTextAsNextPage: String?
|
2022-12-07 01:01:13 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
The text to display above a slideshow for most recent items.
|
|
|
|
Only used for elements that define `showMostRecentSection = true`
|
|
|
|
*/
|
|
|
|
let mostRecentTitle: String?
|
|
|
|
|
|
|
|
/**
|
|
|
|
The text to display above a slideshow for featured items.
|
|
|
|
Only used for elements that define `showFeaturedSection = true`
|
|
|
|
*/
|
|
|
|
let featuredTitle: String?
|
2022-08-19 18:05:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extension GenericMetadata.LocalizedMetadata: Codable {
|
|
|
|
|
|
|
|
private static var knownKeyList: [CodingKeys] {
|
|
|
|
[
|
|
|
|
.language,
|
|
|
|
.title,
|
|
|
|
.subtitle,
|
|
|
|
.description,
|
|
|
|
.linkPreviewTitle,
|
|
|
|
.linkPreviewImage,
|
|
|
|
.linkPreviewDescription,
|
|
|
|
.moreLinkText,
|
|
|
|
.backLinkText,
|
|
|
|
.placeholderTitle,
|
2022-08-25 00:12:05 +02:00
|
|
|
.placeholderText,
|
|
|
|
.titleSuffix,
|
|
|
|
.thumbnailSuffix,
|
|
|
|
.cornerText,
|
|
|
|
.externalUrl,
|
2022-09-25 17:19:07 +02:00
|
|
|
.relatedContentText,
|
2022-09-25 22:07:34 +02:00
|
|
|
.navigationTextAsPreviousPage,
|
|
|
|
.navigationTextAsNextPage,
|
2022-12-07 01:01:13 +01:00
|
|
|
.mostRecentTitle,
|
|
|
|
.featuredTitle,
|
2022-08-19 18:05:06 +02:00
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
static var knownKeys: Set<String> {
|
|
|
|
Set(knownKeyList.map { $0.stringValue })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extension GenericMetadata.LocalizedMetadata {
|
|
|
|
|
|
|
|
/**
|
|
|
|
The mandatory minimum for a site element.
|
|
|
|
*/
|
|
|
|
static var mandatory: GenericMetadata.LocalizedMetadata {
|
|
|
|
.init(
|
|
|
|
language: "",
|
|
|
|
title: "",
|
|
|
|
subtitle: nil,
|
|
|
|
description: nil,
|
|
|
|
linkPreviewTitle: nil,
|
|
|
|
linkPreviewImage: nil,
|
|
|
|
linkPreviewDescription: nil,
|
|
|
|
moreLinkText: nil,
|
|
|
|
backLinkText: nil,
|
|
|
|
placeholderTitle: nil,
|
|
|
|
placeholderText: nil,
|
|
|
|
titleSuffix: nil,
|
|
|
|
thumbnailSuffix: nil,
|
|
|
|
cornerText: nil,
|
2022-09-25 17:19:07 +02:00
|
|
|
externalUrl: nil,
|
2022-09-25 22:07:34 +02:00
|
|
|
relatedContentText: nil,
|
|
|
|
navigationTextAsPreviousPage: nil,
|
2022-12-07 01:01:13 +01:00
|
|
|
navigationTextAsNextPage: nil,
|
|
|
|
mostRecentTitle: nil,
|
|
|
|
featuredTitle: nil)
|
2022-08-19 18:05:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
The mandatory minimum for the root element of a site.
|
|
|
|
*/
|
|
|
|
static var mandatoryAtRoot: GenericMetadata.LocalizedMetadata {
|
|
|
|
.init(language: "",
|
|
|
|
title: "",
|
|
|
|
subtitle: nil,
|
|
|
|
description: nil,
|
|
|
|
linkPreviewTitle: nil,
|
|
|
|
linkPreviewImage: nil,
|
|
|
|
linkPreviewDescription: nil,
|
|
|
|
moreLinkText: nil,
|
|
|
|
backLinkText: "",
|
|
|
|
placeholderTitle: "",
|
|
|
|
placeholderText: "",
|
|
|
|
titleSuffix: nil,
|
|
|
|
thumbnailSuffix: nil,
|
|
|
|
cornerText: nil,
|
2022-09-25 17:19:07 +02:00
|
|
|
externalUrl: nil,
|
2022-09-25 22:07:34 +02:00
|
|
|
relatedContentText: "",
|
|
|
|
navigationTextAsPreviousPage: "",
|
2022-12-07 01:01:13 +01:00
|
|
|
navigationTextAsNextPage: "",
|
|
|
|
mostRecentTitle: nil,
|
|
|
|
featuredTitle: nil)
|
2022-08-19 18:05:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static var full: GenericMetadata.LocalizedMetadata {
|
|
|
|
.init(language: "",
|
|
|
|
title: "",
|
|
|
|
subtitle: "",
|
|
|
|
description: "",
|
|
|
|
linkPreviewTitle: "",
|
|
|
|
linkPreviewImage: "",
|
|
|
|
linkPreviewDescription: "",
|
|
|
|
moreLinkText: "",
|
|
|
|
backLinkText: "",
|
|
|
|
placeholderTitle: "",
|
|
|
|
placeholderText: "",
|
|
|
|
titleSuffix: "",
|
|
|
|
thumbnailSuffix: "",
|
|
|
|
cornerText: "",
|
2022-09-25 17:19:07 +02:00
|
|
|
externalUrl: "",
|
2022-09-25 22:07:34 +02:00
|
|
|
relatedContentText: "",
|
|
|
|
navigationTextAsPreviousPage: "",
|
2022-12-07 01:01:13 +01:00
|
|
|
navigationTextAsNextPage: "",
|
|
|
|
mostRecentTitle: "",
|
|
|
|
featuredTitle: "")
|
2022-08-19 18:05:06 +02:00
|
|
|
}
|
|
|
|
}
|