Convert Xcode project to swift package
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import Foundation
|
||||
|
||||
struct BackNavigationTemplate: Template {
|
||||
|
||||
enum Key: String, CaseIterable {
|
||||
case url = "URL"
|
||||
case text = "TEXT"
|
||||
}
|
||||
|
||||
static let templateName = "back.html"
|
||||
|
||||
let raw: String
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
import Foundation
|
||||
|
||||
struct OverviewSectionCleanTemplate: Template {
|
||||
|
||||
enum Key: String, CaseIterable {
|
||||
case items = "ITEMS"
|
||||
}
|
||||
|
||||
static let templateName = "overview-section-clean.html"
|
||||
|
||||
let raw: String
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
import Foundation
|
||||
|
||||
struct OverviewSectionTemplate: Template {
|
||||
|
||||
enum Key: String, CaseIterable {
|
||||
case url = "URL"
|
||||
case title = "TITLE"
|
||||
case items = "ITEMS"
|
||||
case more = "MORE"
|
||||
}
|
||||
|
||||
static let templateName = "overview-section.html"
|
||||
|
||||
let raw: String
|
||||
}
|
16
Sources/Generator/Templates/Elements/PageHeadTemplate.swift
Normal file
16
Sources/Generator/Templates/Elements/PageHeadTemplate.swift
Normal file
@@ -0,0 +1,16 @@
|
||||
import Foundation
|
||||
|
||||
struct PageHeadTemplate: Template {
|
||||
|
||||
enum Key: String, CaseIterable {
|
||||
case author = "AUTHOR"
|
||||
case title = "TITLE"
|
||||
case description = "DESCRIPTION"
|
||||
case image = "IMAGE"
|
||||
case customPageContent = "CUSTOM"
|
||||
}
|
||||
|
||||
let raw: String
|
||||
|
||||
static let templateName = "head.html"
|
||||
}
|
18
Sources/Generator/Templates/Elements/PageImageTemplate.swift
Normal file
18
Sources/Generator/Templates/Elements/PageImageTemplate.swift
Normal file
@@ -0,0 +1,18 @@
|
||||
import Foundation
|
||||
|
||||
struct PageImageTemplate: Template {
|
||||
|
||||
enum Key: String, CaseIterable {
|
||||
case image = "IMAGE"
|
||||
case image2x = "IMAGE_2X"
|
||||
case width = "WIDTH"
|
||||
case height = "HEIGHT"
|
||||
case leftText = "LEFT_TEXT"
|
||||
case rightText = "RIGHT_TEXT"
|
||||
}
|
||||
|
||||
static let templateName = "image.html"
|
||||
|
||||
let raw: String
|
||||
|
||||
}
|
37
Sources/Generator/Templates/Elements/PageVideoTemplate.swift
Normal file
37
Sources/Generator/Templates/Elements/PageVideoTemplate.swift
Normal file
@@ -0,0 +1,37 @@
|
||||
import Foundation
|
||||
|
||||
struct PageVideoTemplate: Template {
|
||||
|
||||
typealias VideoSource = (url: String, type: VideoType)
|
||||
|
||||
enum Key: String, CaseIterable {
|
||||
case options = "OPTIONS"
|
||||
case sources = "SOURCES"
|
||||
}
|
||||
|
||||
enum VideoOption: String {
|
||||
case controls
|
||||
case autoplay
|
||||
case muted
|
||||
case loop
|
||||
case playsinline
|
||||
case poster
|
||||
case preload
|
||||
}
|
||||
|
||||
static let templateName = "video.html"
|
||||
|
||||
let raw: String
|
||||
|
||||
func generate<T>(sources: [VideoSource], options: T) -> String where T: Sequence, T.Element == VideoOption {
|
||||
let sourcesCode = sources.map(makeSource).joined(separator: "\n")
|
||||
let optionCode = options.map { $0.rawValue }.joined(separator: " ")
|
||||
return generate([.sources: sourcesCode, .options: optionCode])
|
||||
}
|
||||
|
||||
private func makeSource(_ source: VideoSource) -> String {
|
||||
"""
|
||||
<source src="\(source.url)" type="\(source.type.htmlType)">
|
||||
"""
|
||||
}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
import Foundation
|
||||
|
||||
struct PlaceholderTemplate: Template {
|
||||
|
||||
enum Key: String, CaseIterable {
|
||||
case title = "TITLE"
|
||||
case text = "TEXT"
|
||||
}
|
||||
|
||||
static let templateName = "empty.html"
|
||||
|
||||
var raw: String
|
||||
}
|
50
Sources/Generator/Templates/Elements/ThumbnailTemplate.swift
Normal file
50
Sources/Generator/Templates/Elements/ThumbnailTemplate.swift
Normal file
@@ -0,0 +1,50 @@
|
||||
import Foundation
|
||||
|
||||
protocol ThumbnailTemplate {
|
||||
|
||||
func generate(_ content: [ThumbnailKey : String], shouldIndent: Bool) -> String
|
||||
}
|
||||
|
||||
enum ThumbnailKey: String, CaseIterable {
|
||||
case url = "URL"
|
||||
case image = "IMAGE"
|
||||
case image2x = "IMAGE_2X"
|
||||
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
|
||||
}
|
||||
|
15
Sources/Generator/Templates/Elements/TopBarTemplate.swift
Normal file
15
Sources/Generator/Templates/Elements/TopBarTemplate.swift
Normal file
@@ -0,0 +1,15 @@
|
||||
import Foundation
|
||||
|
||||
struct TopBarTemplate: Template {
|
||||
|
||||
enum Key: String, CaseIterable {
|
||||
case title = "TITLE"
|
||||
case titleLink = "TITLE_URL"
|
||||
case elements = "ELEMENTS"
|
||||
case languageButton = "LANG_BUTTON"
|
||||
}
|
||||
|
||||
static let templateName = "bar.html"
|
||||
|
||||
var raw: String
|
||||
}
|
Reference in New Issue
Block a user