feat(microblog): show Micro.blog publish status
The publish sheet flipped a draft live and remembered nothing, so nothing on disk said a piece was out and the library could not show it. A successful Publish now stamps `micropub_published` in the piece's frontmatter; the row and the sheet read `published <date>` or `draft on Micro.blog`, and a published piece's menu opens the live post. Sending a piece again no longer creates a second post: a piece that remembers its post updates it in place (name and content only, so categories set on Micro.blog survive). An image whose bytes are unchanged rides its earlier upload through a per-piece memo. When Micro.blog answers 404 the piece forgets both keys and the sheet offers a fresh draft; a clear that cannot land says so instead of claiming the link is gone. Museion's micropub keys are dropped at the import boundary. An imported `micropub_url` passes the format gate and would aim the in-place update at one of the writer's own posts under their token, so the keys are treated like `origin`: ours to set, never a foreign file's to carry in. Publish is model-owned and trust-gates its URL before anything is stamped. Tests read recorded requests through an optional accessor: an out-of-range subscript after a failed count expectation trapped the hosted runner and reported every queued test as crashed. +16 tests net (17 new pins in MicropubStatusTests, one retired whose premise the in-place design voids); every new pin was watched fail on its own guard. Rail 752/752; SwiftFormat and SwiftLint clean. Reviews: standards + spec during the build, then a three-reviewer finish audit. Docs: AGENTS.md bullets and learnings, GLOSSARY terms, CHANGELOG [Unreleased], README, and the devlog. Closes #206
This commit is contained in:
1 parent
6938826101
commit
6aa31a419a
21 files changed
+1151
-225
No files matched your search
@@ -43,6 +43,18 @@ final class MicropubRequestLog: @unchecked Sendable {
|
||||
defer { lock.unlock() }
|
||||
return items
|
||||
}
|
||||
|
||||
/// The request at `index`, nil when fewer traveled. Read recorded
|
||||
/// requests through here, never `requests[index]`: an out-of-range
|
||||
/// subscript TRAPS, one trap kills the hosted runner, and every
|
||||
/// queued test reports `Crash:` beside it (#206 flip cycle). A nil
|
||||
/// here fails the pin's OWN expectation — `#require` it when the
|
||||
/// value feeds a non-optional parameter.
|
||||
func request(_ index: Int) -> URLRequest? {
|
||||
lock.lock()
|
||||
defer { lock.unlock() }
|
||||
return index < items.count ? items[index] : nil
|
||||
}
|
||||
}
|
||||
|
||||
nonisolated func micropubHTTP(_ status: Int, headers: [String: String]? = nil) -> HTTPURLResponse {
|
||||
@@ -266,7 +278,7 @@ struct MicropubTests {
|
||||
|
||||
// MARK: The stamp + scan (the remembered draft URL)
|
||||
|
||||
@Test func `stampMicropubURL stamps in place and scan reads it back`() throws {
|
||||
@Test func `stampMicropub stamps in place and scan reads it back`() throws {
|
||||
let home = FileManager.default.temporaryDirectory
|
||||
.appendingPathComponent("micropub-\(UUID().uuidString)", isDirectory: true)
|
||||
try FileManager.default.createDirectory(at: home, withIntermediateDirectories: true)
|
||||
@@ -292,7 +304,7 @@ struct MicropubTests {
|
||||
].joined(separator: "\n").write(to: fileURL, atomically: true, encoding: .utf8)
|
||||
let before = try String(contentsOf: fileURL, encoding: .utf8)
|
||||
|
||||
try PostStore.stampMicropubURL(id: post.id, url: "https://example.micro.blog/hello.html", home: home)
|
||||
try PostStore.stampMicropub(post.id, home: home, [("micropub_url", "https://example.micro.blog/hello.html")])
|
||||
|
||||
let after = try String(contentsOf: fileURL, encoding: .utf8)
|
||||
#expect(after.contains("micropub_url: https://example.micro.blog/hello.html"))
|
||||
@@ -305,11 +317,11 @@ struct MicropubTests {
|
||||
#expect(scanned?.title == "Kept Title") // the stamp disturbs nothing else
|
||||
}
|
||||
|
||||
@Test func `stampMicropubURL throws on a vanished piece`() throws {
|
||||
@Test func `stampMicropub throws on a vanished piece`() throws {
|
||||
let home = FileManager.default.temporaryDirectory
|
||||
.appendingPathComponent("micropub-\(UUID().uuidString)", isDirectory: true)
|
||||
#expect(throws: (any Error).self) {
|
||||
try PostStore.stampMicropubURL(id: "ghost", url: "https://x.example/", home: home)
|
||||
try PostStore.stampMicropub("ghost", home: home, [("micropub_url", "https://x.example/")])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user