Begin configuration for constants
This commit is contained in:
parent
50519762a9
commit
3f1971c5bd
6
WebsiteGenerator/Files/Configuration.swift
Normal file
6
WebsiteGenerator/Files/Configuration.swift
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import Foundation
|
||||||
|
|
||||||
|
struct Configuration {
|
||||||
|
|
||||||
|
let pageImageWidth: Int
|
||||||
|
}
|
@ -4,9 +4,6 @@ import Splash
|
|||||||
|
|
||||||
struct PageContentGenerator {
|
struct PageContentGenerator {
|
||||||
|
|
||||||
#warning("Specify page image width in configuration")
|
|
||||||
let pageImageWidth = 748
|
|
||||||
|
|
||||||
private let factory: TemplateFactory
|
private let factory: TemplateFactory
|
||||||
|
|
||||||
private let swift = SyntaxHighlighter(format: HTMLOutputFormat())
|
private let swift = SyntaxHighlighter(format: HTMLOutputFormat())
|
||||||
@ -83,11 +80,11 @@ struct PageContentGenerator {
|
|||||||
private func handleImage(page: Element, file: String, rightTitle: String?, leftTitle: String?) -> String {
|
private func handleImage(page: Element, file: String, rightTitle: String?, leftTitle: String?) -> String {
|
||||||
let imagePath = page.pathRelativeToRootForContainedInputFile(file)
|
let imagePath = page.pathRelativeToRootForContainedInputFile(file)
|
||||||
|
|
||||||
let size = files.requireImage(source: imagePath, destination: imagePath, width: pageImageWidth)
|
let size = files.requireImage(source: imagePath, destination: imagePath, width: configuration.pageImageWidth)
|
||||||
|
|
||||||
let imagePath2x = imagePath.insert("@2x", beforeLast: ".")
|
let imagePath2x = imagePath.insert("@2x", beforeLast: ".")
|
||||||
let file2x = file.insert("@2x", beforeLast: ".")
|
let file2x = file.insert("@2x", beforeLast: ".")
|
||||||
files.requireImage(source: imagePath, destination: imagePath2x, width: 2 * pageImageWidth)
|
files.requireImage(source: imagePath, destination: imagePath2x, width: 2 * configuration.pageImageWidth)
|
||||||
|
|
||||||
let content: [PageImageTemplate.Key : String] = [
|
let content: [PageImageTemplate.Key : String] = [
|
||||||
.image: file,
|
.image: file,
|
||||||
|
@ -3,6 +3,8 @@ import Foundation
|
|||||||
private let contentDirectory = URL(fileURLWithPath: "/Users/ch/Projects/MakerSpace")
|
private let contentDirectory = URL(fileURLWithPath: "/Users/ch/Projects/MakerSpace")
|
||||||
private let outputDirectory = URL(fileURLWithPath: "/Users/ch/Projects/MakerSpace/Site")
|
private let outputDirectory = URL(fileURLWithPath: "/Users/ch/Projects/MakerSpace/Site")
|
||||||
|
|
||||||
|
let configuration = Configuration(pageImageWidth: 748)
|
||||||
|
|
||||||
let log = ValidationLog()
|
let log = ValidationLog()
|
||||||
let files = FileSystem(in: contentDirectory, to: outputDirectory)
|
let files = FileSystem(in: contentDirectory, to: outputDirectory)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user