Add draft indicator, filter drafts, show issue count

This commit is contained in:
Christoph Hagen
2025-01-07 14:03:07 +01:00
parent 9d95e7d210
commit 508483071a
10 changed files with 124 additions and 32 deletions

View File

@ -72,7 +72,7 @@ struct HtmlCommand: CommandProcessor {
}
for src in srcAttributes {
results.warning("Found image in html: \(src)")
findFile(path: src, source: "src of <img>")
}
}
@ -93,7 +93,7 @@ struct HtmlCommand: CommandProcessor {
if url.hasPrefix("http://") || url.hasPrefix("https://") {
results.externalLink(to: url)
} else {
results.warning("Relative link in HTML: \(url)")
findFile(path: url, source: "href of <a>")
}
}
}
@ -122,7 +122,7 @@ struct HtmlCommand: CommandProcessor {
}
for src in srcSets {
results.warning("Found source set in html: \(src)")
findFile(path: src, source: "srcset of <source>")
}
}
@ -138,17 +138,57 @@ struct HtmlCommand: CommandProcessor {
}
for src in srcAttributes {
guard content.isValidIdForFile(src) else {
results.warning("Found source in html: \(src)")
continue
}
guard let file = content.file(src) else {
results.warning("Found source in html: \(src)")
continue
}
#warning("Either find files by their full path, or replace file id with full path")
results.require(file: file)
findFile(path: src, source: "src of <source>")
}
}
private func findFile(path: String, source: String) {
let type = FileType(fileExtension: path.fileExtension)
guard path.hasPrefix("/") else {
findFileWith(relativePath: path, type: type, source: source)
return
}
guard !type.generatesImageVersions else {
// Try to determine image version needed
findImageVersion(path: path, type: type, source: source)
return
}
if findFile(withAbsolutePath: path) {
return
}
let fileId = path.dropBeforeLast("/")
if content.isValidIdForFile(fileId) {
results.missing(file: fileId, source: "HTML: \(source)")
} else {
results.warning("Could not find file '\(path)' for \(source)")
}
}
private func findFile(withAbsolutePath absolutePath: String) -> Bool {
guard let file = content.file(withOutputPath: absolutePath) else {
return false
}
results.require(file: file)
return true
}
private func findImageVersion(path: String, type: FileType, source: String) {
// First check if image original should be used
if findFile(withAbsolutePath: path) {
return
}
let fileId = path.dropAfterLast("/").dropBeforeLast("/")
guard let file = content.file(fileId) else {
results.missing(file: fileId, source: "HTML: \(source)")
return
}
results.warning("Could not determine image version for file '\(file.id)' for \(source)")
}
private func findFileWith(relativePath: String, type: FileType, source: String) {
results.warning("Could not determine relative file '\(relativePath)' for \(source)")
}
}