-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
196 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import Foundation | ||
|
||
public enum PublishDefaults { | ||
public static let contentDirectoryName = "Content" | ||
public static let resourcesDirectoryName = "Resources" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
import Contribute | ||
import Foundation | ||
|
||
extension Settings { | ||
public init( | ||
rootPublishSiteURL: URL, | ||
exportsDirectoryURL: URL, | ||
assetImportSetting: AssetImportSetting = .download, | ||
overwriteAssets: Bool = false, | ||
assetRelativePath: String = WordPressSite.wpContentUploadsRelativePath, | ||
markdownFromHTML: @escaping (String) throws -> String = { $0 } | ||
) { | ||
self.init( | ||
contentPathURL: | ||
rootPublishSiteURL.appendingPathComponent(PublishDefaults.contentDirectoryName), | ||
resourcesPathURL: | ||
rootPublishSiteURL.appendingPathComponent(PublishDefaults.resourcesDirectoryName), | ||
exportsDirectoryURL: exportsDirectoryURL, | ||
assetImportSetting: assetImportSetting, | ||
overwriteAssets: overwriteAssets, | ||
assetRelativePath: assetRelativePath, | ||
markdownFromHTML: markdownFromHTML | ||
) | ||
} | ||
|
||
public init( | ||
contentPathURL: URL, | ||
resourcesPathURL: URL, | ||
exportsDirectoryURL: URL, | ||
markdownGenerator: MarkdownGenerator, | ||
assetImportSetting: AssetImportSetting = .download, | ||
overwriteAssets: Bool = false, | ||
assetRelativePath: String = WordPressSite.wpContentUploadsRelativePath | ||
) { | ||
self.init( | ||
contentPathURL: contentPathURL, | ||
resourcesPathURL: resourcesPathURL, | ||
exportsDirectoryURL: exportsDirectoryURL, | ||
assetImportSetting: assetImportSetting, | ||
overwriteAssets: overwriteAssets, | ||
assetRelativePath: assetRelativePath, | ||
markdownFromHTML: markdownGenerator.markdown(fromHTML:) | ||
) | ||
} | ||
|
||
public init( | ||
rootPublishSiteURL: URL, | ||
exportsDirectoryURL: URL, | ||
markdownGenerator: MarkdownGenerator, | ||
assetImportSetting: AssetImportSetting = .download, | ||
overwriteAssets: Bool = false, | ||
assetRelativePath: String = WordPressSite.wpContentUploadsRelativePath | ||
) { | ||
self.init( | ||
contentPathURL: | ||
rootPublishSiteURL.appendingPathComponent(PublishDefaults.contentDirectoryName), | ||
resourcesPathURL: | ||
rootPublishSiteURL.appendingPathComponent(PublishDefaults.resourcesDirectoryName), | ||
exportsDirectoryURL: exportsDirectoryURL, | ||
markdownGenerator: markdownGenerator, | ||
assetImportSetting: assetImportSetting, | ||
overwriteAssets: overwriteAssets, | ||
assetRelativePath: assetRelativePath | ||
) | ||
} | ||
|
||
public init( | ||
contentPathURL: URL, | ||
resourcesPathURL: URL, | ||
exportsDirectoryURL: URL, | ||
assetImportSetting: AssetImportSetting = .download, | ||
overwriteAssets: Bool = false, | ||
assetRelativePath: String = WordPressSite.wpContentUploadsRelativePath, | ||
temporaryFile: @escaping (String) throws -> URL = | ||
PandocMarkdownGenerator.Temporary.file(fromContent:), | ||
shellOut: @escaping (String, [String]) throws -> String | ||
) { | ||
self.init( | ||
contentPathURL: contentPathURL, | ||
resourcesPathURL: resourcesPathURL, | ||
exportsDirectoryURL: exportsDirectoryURL, | ||
markdownGenerator: | ||
PandocMarkdownGenerator(shellOut: shellOut, temporaryFile: temporaryFile), | ||
assetImportSetting: assetImportSetting, | ||
overwriteAssets: overwriteAssets, | ||
assetRelativePath: assetRelativePath | ||
) | ||
} | ||
|
||
public init( | ||
rootPublishSiteURL: URL, | ||
exportsDirectoryURL: URL, | ||
assetImportSetting: AssetImportSetting = .download, | ||
overwriteAssets: Bool = false, | ||
assetRelativePath: String = WordPressSite.wpContentUploadsRelativePath, | ||
temporaryFile: @escaping (String) throws -> URL = | ||
PandocMarkdownGenerator.Temporary.file(fromContent:), | ||
shellOut: @escaping (String, [String]) throws -> String | ||
) { | ||
self.init( | ||
contentPathURL: | ||
rootPublishSiteURL.appendingPathComponent(PublishDefaults.contentDirectoryName), | ||
resourcesPathURL: | ||
rootPublishSiteURL.appendingPathComponent(PublishDefaults.resourcesDirectoryName), | ||
exportsDirectoryURL: exportsDirectoryURL, | ||
assetImportSetting: assetImportSetting, | ||
overwriteAssets: overwriteAssets, | ||
assetRelativePath: assetRelativePath, | ||
temporaryFile: temporaryFile, | ||
shellOut: shellOut | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import Contribute | ||
import Foundation | ||
|
||
public struct Settings: ProcessorSettings { | ||
public let contentPathURL: URL | ||
|
||
public let resourcesPathURL: URL | ||
|
||
public let exportsDirectoryURL: URL | ||
|
||
public let assetImportSetting: AssetImportSetting | ||
|
||
public let overwriteAssets: Bool | ||
|
||
public let assetRelativePath: String | ||
|
||
public let markdownFromHTML: (String) throws -> String | ||
|
||
public init( | ||
contentPathURL: URL, | ||
resourcesPathURL: URL, | ||
exportsDirectoryURL: URL, | ||
assetImportSetting: AssetImportSetting = .download, | ||
overwriteAssets: Bool = false, | ||
assetRelativePath: String = WordPressSite.wpContentUploadsRelativePath, | ||
markdownFromHTML: @escaping (String) throws -> String = { $0 } | ||
) { | ||
self.contentPathURL = contentPathURL | ||
self.resourcesPathURL = resourcesPathURL | ||
self.exportsDirectoryURL = exportsDirectoryURL | ||
self.assetImportSetting = assetImportSetting | ||
self.overwriteAssets = overwriteAssets | ||
self.assetRelativePath = assetRelativePath | ||
self.markdownFromHTML = markdownFromHTML | ||
} | ||
|
||
public func markdownFrom(html: String) throws -> String { | ||
try markdownFromHTML(html) | ||
} | ||
} |