Fix icons, external file rename
This commit is contained in:
@ -23,6 +23,7 @@ struct LabelsCommandProcessor: CommandProcessor {
|
||||
results.invalid(command: .labels, markdown)
|
||||
return nil
|
||||
}
|
||||
results.requiredIcons.insert(icon)
|
||||
return .init(icon: icon, value: parts[1])
|
||||
}
|
||||
return ContentLabels(labels: labels).content
|
||||
|
@ -1,32 +0,0 @@
|
||||
import Ink
|
||||
|
||||
#warning("Remove if unused")
|
||||
final class PageCommandExtractor {
|
||||
|
||||
private var occurrences: [(full: String, command: String, arguments: [String])] = []
|
||||
|
||||
func findOccurrences(of command: ShorthandMarkdownKey, in content: String) -> [(full: String, arguments: [String])] {
|
||||
findOccurrences(of: command.rawValue, in: content)
|
||||
}
|
||||
|
||||
func findOccurrences(of command: String, in content: String) -> [(full: String, arguments: [String])] {
|
||||
let parser = MarkdownParser(modifiers: [
|
||||
Modifier(target: .images, closure: processMarkdownImage),
|
||||
])
|
||||
_ = parser.html(from: content)
|
||||
|
||||
return occurrences
|
||||
.filter { $0.command == command }
|
||||
.map { ($0.full, $0.arguments) }
|
||||
}
|
||||
|
||||
private func processMarkdownImage(html: String, markdown: Substring) -> String {
|
||||
let argumentList = markdown.between(first: "](", andLast: ")").removingPercentEncoding ?? markdown.between(first: "](", andLast: ")")
|
||||
let arguments = argumentList.components(separatedBy: ";")
|
||||
|
||||
|
||||
let command = markdown.between("![", and: "]").trimmed
|
||||
occurrences.append((full: String(markdown), command: command, arguments: arguments))
|
||||
return ""
|
||||
}
|
||||
}
|
@ -1,14 +1,15 @@
|
||||
import SwiftUI
|
||||
import SFSafeSymbols
|
||||
|
||||
#warning("Fix podcast")
|
||||
#warning("Allow selection of pages as navigation bar items")
|
||||
#warning("Add link to other language")
|
||||
#warning("Transfer images of posts to other language")
|
||||
#warning("Show tag selection view for pages")
|
||||
#warning("Button to replace files")
|
||||
#warning("Add external pages")
|
||||
#warning("Convert statistics into key-value pairs")
|
||||
#warning("Replace links to files inside pages when id changes")
|
||||
#warning("Calculate file sizes")
|
||||
#warning("Specify image aspect ratio to prevent page jumps")
|
||||
|
||||
@main
|
||||
struct MainView: App {
|
||||
|
@ -116,6 +116,23 @@ final class FileResource: Item {
|
||||
default: return content.settings.paths.filesOutputFolderPath
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: File
|
||||
|
||||
func update(id newId: String) -> Bool {
|
||||
guard !isExternallyStored else {
|
||||
id = newId
|
||||
return true
|
||||
}
|
||||
do {
|
||||
try content.storage.move(file: id, to: newId)
|
||||
id = newId
|
||||
return true
|
||||
} catch {
|
||||
print("Failed to move file \(id) to \(newId)")
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension FileResource: Identifiable {
|
||||
|
@ -55,14 +55,9 @@ struct FileDetailView: View {
|
||||
}
|
||||
|
||||
private func setNewId() {
|
||||
do {
|
||||
try file.content.storage.move(file: file.id, to: newId)
|
||||
} catch {
|
||||
print("Failed to move file \(file.id)")
|
||||
if !file.update(id: newId) {
|
||||
newId = file.id
|
||||
return
|
||||
}
|
||||
file.id = newId
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user