2022-08-16 10:39:05 +02:00
|
|
|
import Foundation
|
|
|
|
|
|
|
|
protocol ThumbnailTemplate {
|
|
|
|
|
2022-08-26 17:40:51 +02:00
|
|
|
func generate(_ content: [ThumbnailKey : String], shouldIndent: Bool) -> String
|
2022-08-16 10:39:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
enum ThumbnailKey: String, CaseIterable {
|
|
|
|
case url = "URL"
|
|
|
|
case image = "IMAGE"
|
|
|
|
case title = "TITLE"
|
|
|
|
case corner = "CORNER"
|
|
|
|
}
|
|
|
|
|
|
|
|
struct LargeThumbnailTemplate: Template, ThumbnailTemplate {
|
|
|
|
|
|
|
|
typealias Key = ThumbnailKey
|
|
|
|
|
|
|
|
static let templateName = "thumbnail-large.html"
|
|
|
|
|
|
|
|
let raw: String
|
|
|
|
|
|
|
|
func makeCorner(text: String) -> String {
|
|
|
|
"<span class=\"corner\"><span>\(text)</span></span>"
|
|
|
|
}
|
|
|
|
|
|
|
|
func makeTitleSuffix(_ suffix: String) -> String {
|
|
|
|
"<span class=\"suffix\">\(suffix)</span>"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SquareThumbnailTemplate: Template, ThumbnailTemplate {
|
|
|
|
|
|
|
|
typealias Key = ThumbnailKey
|
|
|
|
|
|
|
|
static let templateName = "thumbnail-square.html"
|
|
|
|
|
|
|
|
let raw: String
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SmallThumbnailTemplate: Template, ThumbnailTemplate {
|
|
|
|
|
|
|
|
typealias Key = ThumbnailKey
|
|
|
|
|
|
|
|
static let templateName = "thumbnail-small.html"
|
|
|
|
|
|
|
|
let raw: String
|
|
|
|
}
|
|
|
|
|