Commit 0bed6d0637
Verified · cmc
Changed files (13)
- Sources/OrgApp/CaptureModel.swift +14 −2
- Sources/OrgApp/XCallback.swift added +476
- Sources/OrgApp/XCallbackSettings.swift added +59
- Sources/Orgstar/CaptureView.swift +15
- Sources/Orgstar/OrgstarApp.swift +64 −1
- Sources/OrgstarMobile/CaptureScreen.swift +3
- Sources/OrgstarMobile/OrgstarMobileApp.swift +76 −2
- Sources/OrgstarMobile/SettingsScreen.swift +1
- Tests/OrgAppTests/XCallbackTests.swift added +227
- docs/manual/guide/08-capture.org +2
- docs/manual/guide/14-ios.org +2
- docs/manual/guide/15-alongside-emacs.org +137
- l10n/Localizable.xcstrings +340
Sources/OrgApp/CaptureModel.swift +14 −2 · view
| @@ -228,19 +228,31 @@ extension DocumentSession { | |||
| 228 | _ text: String, templateKey key: String?, templates: [CaptureTemplate], workspace: WorkspaceModel, clock: ClockModel, | 228 | _ text: String, templateKey key: String?, templates: [CaptureTemplate], workspace: WorkspaceModel, clock: ClockModel, |
| 229 | clipboard: String, userName: String | 229 | clipboard: String, userName: String |
| 230 | ) -> Result<CaptureTemplate, CaptureError> { | 230 | ) -> Result<CaptureTemplate, CaptureError> { |
| 231 | capture(text, templateKey: key, templates: templates, workspace: workspace, clock: clock, clipboard: clipboard, userName: userName).map(\.template) | ||
| 232 | } | ||
| 233 | |||
| 234 | /// `capture(_:templateKey:…)` with prompts answered by their prompt text (`%^{What}` by | ||
| 235 | /// `answers["What"]`, empty when missing) and org-protocol's link properties for `%a`, | ||
| 236 | /// `%:link` and the like. The template used, and the file and offset of the entry. | ||
| 237 | public func capture( | ||
| 238 | _ text: String, templateKey key: String?, templates: [CaptureTemplate], workspace: WorkspaceModel, clock: ClockModel, | ||
| 239 | clipboard: String, userName: String, answers: [String: String] = [:], properties: [String: String] = [:] | ||
| 240 | ) -> Result<(template: CaptureTemplate, path: String, offset: Int), CaptureError> { | ||
| 231 | let key = key.flatMap { $0.isEmpty ? nil : $0 } | 241 | let key = key.flatMap { $0.isEmpty ? nil : $0 } |
| 232 | guard let chosen = key.map({ key in templates.first { $0.key == key } }) ?? templates.first else { | 242 | guard let chosen = key.map({ key in templates.first { $0.key == key } }) ?? templates.first else { |
| 233 | return .failure(CaptureError(message: "No capture template \"\(key ?? "")\"")) | 243 | return .failure(CaptureError(message: "No capture template \"\(key ?? "")\"")) |
| 234 | } | 244 | } |
| 235 | var context = CaptureContext(initial: text, clipboard: clipboard, userName: userName, allTags: (try? workspace.index.tags()) ?? []) | 245 | var context = CaptureContext(initial: text, clipboard: clipboard, userName: userName, allTags: (try? workspace.index.tags()) ?? []) |
| 246 | if let annotation = properties["annotation"] { context.annotation = annotation } | ||
| 247 | context.linkProperties = properties | ||
| 236 | context.readsTemplateFiles() | 248 | context.readsTemplateFiles() |
| 237 | let answers = Capture.questions(chosen.template, context: context).map { _ in "" } | 249 | let answers = Capture.questions(chosen.template, context: context).map { answers[$0.prompt] ?? "" } |
| 238 | guard case .success(let filled) = Capture.fill(chosen.template, context: context, answers: answers) else { | 250 | guard case .success(let filled) = Capture.fill(chosen.template, context: context, answers: answers) else { |
| 239 | return .failure(CaptureError(message: "Can't fill template \"\(chosen.key)\"")) | 251 | return .failure(CaptureError(message: "Can't fill template \"\(chosen.key)\"")) |
| 240 | } | 252 | } |
| 241 | return chosen.resolved(workspace: workspace, session: self, clock: clock).flatMap { resolved in | 253 | return chosen.resolved(workspace: workspace, session: self, clock: clock).flatMap { resolved in |
| 242 | capture(filled.text, template: resolved.template, root: workspace.rootPaths.first, file: resolved.file) | 254 | capture(filled.text, template: resolved.template, root: workspace.rootPaths.first, file: resolved.file) |
| 243 | }.map { _ in chosen } | 255 | }.map { (chosen, $0.path, $0.offset) } |
| 244 | } | 256 | } |
| 245 | } | 257 | } |
| 246 | 258 | ||
Sources/OrgApp/XCallback.swift added +476 · view
| @@ -0,0 +1,476 @@ | |||
| 1 | import Foundation | ||
| 2 | import Observation | ||
| 3 | import OrgCore | ||
| 4 | import OrgPresentation | ||
| 5 | |||
| 6 | /// An x-callback-url 1.0 request on the app's scheme: | ||
| 7 | /// `orgstar://x-callback-url/<action>?…&x-success=…&x-error=…&x-cancel=…&x-source=…`. | ||
| 8 | public struct XCallbackRequest: Equatable, Sendable { | ||
| 9 | public enum Action: String, CaseIterable, Sendable { | ||
| 10 | case capture, open, agenda | ||
| 11 | case clockIn = "clock-in" | ||
| 12 | case clockOut = "clock-out" | ||
| 13 | case clockStatus = "clock-status" | ||
| 14 | } | ||
| 15 | |||
| 16 | public static let host = "x-callback-url" | ||
| 17 | |||
| 18 | /// The path after the host, as given. | ||
| 19 | public let action: String | ||
| 20 | /// The query's parameters other than the `x-` ones; the first of repeated names wins. | ||
| 21 | public let parameters: [String: String] | ||
| 22 | public let success: URL? | ||
| 23 | public let failure: URL? | ||
| 24 | public let cancel: URL? | ||
| 25 | /// `x-source`: the calling app's name, as it gives it. | ||
| 26 | public let source: String? | ||
| 27 | |||
| 28 | public init?(url: URL) { | ||
| 29 | guard url.scheme?.lowercased() == AppLink.scheme, url.host?.lowercased() == Self.host, | ||
| 30 | let components = URLComponents(url: url, resolvingAgainstBaseURL: false) else { return nil } | ||
| 31 | action = components.path.trimmingCharacters(in: CharacterSet(charactersIn: "/")) | ||
| 32 | var parameters: [String: String] = [:] | ||
| 33 | for item in components.queryItems ?? [] where parameters[item.name] == nil { | ||
| 34 | parameters[item.name] = item.value ?? "" | ||
| 35 | } | ||
| 36 | func callback(_ name: String) -> URL? { | ||
| 37 | parameters.removeValue(forKey: name).flatMap { $0.isEmpty ? nil : URL(string: $0) } | ||
| 38 | } | ||
| 39 | success = callback("x-success") | ||
| 40 | failure = callback("x-error") | ||
| 41 | cancel = callback("x-cancel") | ||
| 42 | source = parameters.removeValue(forKey: "x-source").flatMap { $0.isEmpty ? nil : $0 } | ||
| 43 | self.parameters = parameters | ||
| 44 | } | ||
| 45 | |||
| 46 | public var known: Action? { Action(rawValue: action) } | ||
| 47 | |||
| 48 | /// A parameter, nil when missing or empty. | ||
| 49 | public func value(_ name: String) -> String? { | ||
| 50 | parameters[name].flatMap { $0.isEmpty ? nil : $0 } | ||
| 51 | } | ||
| 52 | |||
| 53 | /// The URL to open for `reply`: its callback with the reply's parameters added; nil when the | ||
| 54 | /// request gave none or its scheme is refused (`XCallback.allows`). | ||
| 55 | public func callbackURL(for reply: XCallbackReply) -> URL? { | ||
| 56 | let url: URL? | ||
| 57 | switch reply { | ||
| 58 | case .success(let parameters): url = success.flatMap { XCallback.url($0, adding: parameters) } | ||
| 59 | case .failure(let code, let message): url = failure.flatMap { XCallback.url($0, adding: ["errorCode": code, "errorMessage": message]) } | ||
| 60 | case .cancel: url = cancel | ||
| 61 | } | ||
| 62 | return url.flatMap { XCallback.allows($0) ? $0 : nil } | ||
| 63 | } | ||
| 64 | |||
| 65 | /// Who an approval is for: the name the request gives and the schemes its callbacks open. | ||
| 66 | public var approvalSource: XCallbackApprovals.Source { | ||
| 67 | let schemes = Set([success, failure, cancel].compactMap { $0?.scheme?.lowercased() }) | ||
| 68 | return XCallbackApprovals.Source(name: source ?? "", schemes: schemes.sorted()) | ||
| 69 | } | ||
| 70 | } | ||
| 71 | |||
| 72 | /// What an action ends with. | ||
| 73 | public enum XCallbackReply: Equatable, Sendable { | ||
| 74 | /// For `x-success`, with the result's parameters. | ||
| 75 | case success([String: String]) | ||
| 76 | /// For `x-error`, as `errorCode` and `errorMessage`. | ||
| 77 | case failure(code: String, message: String) | ||
| 78 | /// For `x-cancel`. | ||
| 79 | case cancel | ||
| 80 | |||
| 81 | public static func failure(_ code: XCallback.ErrorCode, _ message: String) -> XCallbackReply { | ||
| 82 | .failure(code: code.rawValue, message: message) | ||
| 83 | } | ||
| 84 | } | ||
| 85 | |||
| 86 | public enum XCallback { | ||
| 87 | public enum ErrorCode: String, Sendable { | ||
| 88 | case unknownAction = "unknown-action" | ||
| 89 | case missingParameter = "missing-parameter" | ||
| 90 | case invalidParameter = "invalid-parameter" | ||
| 91 | case notFound = "not-found" | ||
| 92 | case captureFailed = "capture-failed" | ||
| 93 | case clockFailed = "clock-failed" | ||
| 94 | case noClock = "no-clock" | ||
| 95 | case notAllowed = "not-allowed" | ||
| 96 | case needsPro = "needs-orgstar-plus" | ||
| 97 | case notReady = "not-ready" | ||
| 98 | } | ||
| 99 | |||
| 100 | /// Callback schemes never opened: the app's own (a loop), org-protocol (it would capture), | ||
| 101 | /// and web and file URLs, which would hand results to a web server or download a file. | ||
| 102 | public static let refusedSchemes: Set<String> = ["orgstar", "org-protocol", "http", "https", "file", "ftp", "javascript", "data", "about", "blob"] | ||
| 103 | |||
| 104 | public static func allows(_ url: URL) -> Bool { | ||
| 105 | guard let scheme = url.scheme?.lowercased(), !scheme.isEmpty else { return false } | ||
| 106 | return !refusedSchemes.contains(scheme) | ||
| 107 | } | ||
| 108 | |||
| 109 | /// Characters left as they are in a query value: `&`, `=`, `+`, `?`, `#` and `/` are encoded. | ||
| 110 | static let valueCharacters = CharacterSet.alphanumerics.union(CharacterSet(charactersIn: "-._~")) | ||
| 111 | |||
| 112 | /// `base` with `parameters` added to its query, after any it has, in name order. | ||
| 113 | public static func url(_ base: URL, adding parameters: [String: String]) -> URL? { | ||
| 114 | guard var components = URLComponents(url: base, resolvingAgainstBaseURL: false) else { return nil } | ||
| 115 | let added = parameters.sorted { $0.key < $1.key }.map { name, value in | ||
| 116 | URLQueryItem(name: name.addingPercentEncoding(withAllowedCharacters: valueCharacters) ?? name, | ||
| 117 | value: value.addingPercentEncoding(withAllowedCharacters: valueCharacters) ?? value) | ||
| 118 | } | ||
| 119 | guard !added.isEmpty else { return base } | ||
| 120 | components.percentEncodedQueryItems = (components.percentEncodedQueryItems ?? []) + added | ||
| 121 | return components.url | ||
| 122 | } | ||
| 123 | } | ||
| 124 | |||
| 125 | /// The apps allowed to capture, clock and read the agenda and clock through x-callback-url | ||
| 126 | /// links, kept on the device. An app is the name it gives in `x-source` with the schemes its | ||
| 127 | /// callbacks open, so a link that names an allowed app but sends results elsewhere asks again. | ||
| 128 | @MainActor | ||
| 129 | @Observable | ||
| 130 | public final class XCallbackApprovals { | ||
| 131 | public static let shared = XCallbackApprovals() | ||
| 132 | static let key = "xCallbackApprovals" | ||
| 133 | |||
| 134 | public struct Source: Codable, Hashable, Sendable, Identifiable { | ||
| 135 | public let name: String | ||
| 136 | public let schemes: [String] | ||
| 137 | public var id: String { ([name] + schemes).joined(separator: "\u{0}") } | ||
| 138 | |||
| 139 | public init(name: String, schemes: [String]) { | ||
| 140 | self.name = name | ||
| 141 | self.schemes = schemes | ||
| 142 | } | ||
| 143 | } | ||
| 144 | |||
| 145 | public private(set) var sources: [Source] = [] | ||
| 146 | private let defaults: UserDefaults | ||
| 147 | |||
| 148 | public init(defaults: UserDefaults = .standard) { | ||
| 149 | self.defaults = defaults | ||
| 150 | if let data = defaults.data(forKey: Self.key), let saved = try? JSONDecoder().decode([Source].self, from: data) { sources = saved } | ||
| 151 | } | ||
| 152 | |||
| 153 | public func allows(_ source: Source) -> Bool { sources.contains(source) } | ||
| 154 | |||
| 155 | public func allow(_ source: Source) { | ||
| 156 | guard !allows(source) else { return } | ||
| 157 | sources.append(source) | ||
| 158 | save() | ||
| 159 | } | ||
| 160 | |||
| 161 | public func forget(_ source: Source) { | ||
| 162 | sources.removeAll { $0 == source } | ||
| 163 | save() | ||
| 164 | } | ||
| 165 | |||
| 166 | private func save() { | ||
| 167 | if sources.isEmpty { | ||
| 168 | defaults.removeObject(forKey: Self.key) | ||
| 169 | } else if let data = try? JSONEncoder().encode(sources) { | ||
| 170 | defaults.set(data, forKey: Self.key) | ||
| 171 | } | ||
| 172 | } | ||
| 173 | } | ||
| 174 | |||
| 175 | /// Runs x-callback-url actions against the app's models. What needs the app (a sheet, a | ||
| 176 | /// question, showing a file) comes back as a step for it to take. | ||
| 177 | @MainActor | ||
| 178 | public struct XCallbackRunner { | ||
| 179 | public let workspace: WorkspaceModel | ||
| 180 | public let session: DocumentSession | ||
| 181 | public let clock: ClockModel | ||
| 182 | public var approvals: XCallbackApprovals | ||
| 183 | public var templates: () -> [CaptureTemplate] = { CaptureTemplates.load().templates } | ||
| 184 | public var views: () -> [AgendaViewDefinition] = { AgendaViewLoader.load().views } | ||
| 185 | public var isUnlocked: () -> Bool = { ProAccess.shared.isUnlocked } | ||
| 186 | /// `%c` and `%n` for captures without the sheet. | ||
| 187 | public var clipboard: () -> String = { "" } | ||
| 188 | public var userName = "" | ||
| 189 | public var now: () -> Date = Date.init | ||
| 190 | public var calendar = Calendar.current | ||
| 191 | |||
| 192 | /// Agenda entries returned when the request sets no `limit`, and the most it may set. | ||
| 193 | public static let defaultLimit = 50 | ||
| 194 | public static let maximumLimit = 200 | ||
| 195 | |||
| 196 | public init(workspace: WorkspaceModel, session: DocumentSession, clock: ClockModel, approvals: XCallbackApprovals = .shared) { | ||
| 197 | self.workspace = workspace | ||
| 198 | self.session = session | ||
| 199 | self.clock = clock | ||
| 200 | self.approvals = approvals | ||
| 201 | } | ||
| 202 | |||
| 203 | public enum Step: Equatable { | ||
| 204 | /// Open the reply's callback, if any. | ||
| 205 | case reply(XCallbackReply) | ||
| 206 | /// Ask whether the request's source may write to files and read them through links; | ||
| 207 | /// then `allow` and run again, or reply `notAllowed`. | ||
| 208 | case approve(XCallbackApprovals.Source) | ||
| 209 | /// Show the capture sheet or window with this template (nil for the list) and link | ||
| 210 | /// properties; reply with `captured` when it files, `.cancel` when it is dismissed. | ||
| 211 | case capture(template: String?, properties: [String: String]) | ||
| 212 | /// Show the entry, then reply. | ||
| 213 | case open(path: String, offset: Int, reply: XCallbackReply) | ||
| 214 | } | ||
| 215 | |||
| 216 | public func run(_ request: XCallbackRequest, ask: @escaping ClockModel.Ask = { _ in nil }) async -> Step { | ||
| 217 | guard let action = request.known else { | ||
| 218 | return .reply(.failure(.unknownAction, "Unknown action \"\(request.action)\"")) | ||
| 219 | } | ||
| 220 | // Capture and open show what they do; the others write to files or send what they hold | ||
| 221 | // to the caller without showing anything. | ||
| 222 | let interactive: Bool | ||
| 223 | switch action { | ||
| 224 | case .open: interactive = true | ||
| 225 | case .capture: interactive = captureNeedsSheet(request) | ||
| 226 | case .agenda, .clockIn, .clockOut, .clockStatus: interactive = false | ||
| 227 | } | ||
| 228 | if !interactive { | ||
| 229 | guard isUnlocked() else { return .reply(.failure(.needsPro, "x-callback-url actions need orgstar+")) } | ||
| 230 | guard approvals.allows(request.approvalSource) else { return .approve(request.approvalSource) } | ||
| 231 | } | ||
| 232 | // A link that launched the app can come before the folders were first read. | ||
| 233 | if workspace.files.isEmpty { await workspace.refresh() } | ||
| 234 | switch action { | ||
| 235 | case .capture: return capture(request, sheet: interactive) | ||
| 236 | case .open: return open(request) | ||
| 237 | case .agenda: return .reply(await agenda(request)) | ||
| 238 | case .clockIn: return .reply(await clockIn(request, ask: ask)) | ||
| 239 | case .clockOut: return .reply(clockOut()) | ||
| 240 | case .clockStatus: return .reply(.success(clockStatus())) | ||
| 241 | } | ||
| 242 | } | ||
| 243 | |||
| 244 | // MARK: - Capture | ||
| 245 | |||
| 246 | /// The template a capture names, its link properties and its text as org-protocol gives | ||
| 247 | /// them: `%a`, `%i`, `%:link`, `%:description`. | ||
| 248 | static func properties(_ request: XCallbackRequest) -> [String: String] { | ||
| 249 | let link = OrgProtocol.captureURL(template: nil, url: request.value("url"), title: request.value("title") ?? "", body: request.value("text") ?? "") | ||
| 250 | guard case .capture(_, let properties)? = OrgProtocol.parse(link) else { return [:] } | ||
| 251 | return properties | ||
| 252 | } | ||
| 253 | |||
| 254 | static let reservedCaptureParameters: Set<String> = ["template", "text", "url", "title"] | ||
| 255 | |||
| 256 | /// Without the sheet only when the template and text are given and every prompt in the | ||
| 257 | /// template has a parameter named for it; templates that make a Denote note or ask for a | ||
| 258 | /// date tree's day always show it. | ||
| 259 | func captureNeedsSheet(_ request: XCallbackRequest) -> Bool { | ||
| 260 | guard let key = request.value("template"), let text = request.parameters["text"], | ||
| 261 | let template = templates().first(where: { $0.key == key }) else { return true } | ||
| 262 | if template.options.denote || template.asksTreeDate { return true } | ||
| 263 | var context = CaptureContext(initial: text) | ||
| 264 | context.linkProperties = Self.properties(request) | ||
| 265 | return Capture.questions(template.template, context: context).contains { question in | ||
| 266 | if case .clipboard = question.kind { return false } | ||
| 267 | return request.parameters[question.prompt] == nil | ||
| 268 | } | ||
| 269 | } | ||
| 270 | |||
| 271 | private func capture(_ request: XCallbackRequest, sheet: Bool) -> Step { | ||
| 272 | let properties = Self.properties(request) | ||
| 273 | if sheet { return .capture(template: request.value("template"), properties: properties) } | ||
| 274 | var answers = request.parameters | ||
| 275 | for name in Self.reservedCaptureParameters { answers[name] = nil } | ||
| 276 | let placed = session.capture( | ||
| 277 | request.parameters["text"] ?? "", templateKey: request.value("template"), templates: templates(), workspace: workspace, clock: clock, | ||
| 278 | clipboard: clipboard(), userName: userName, answers: answers, properties: properties | ||
| 279 | ) | ||
| 280 | switch placed { | ||
| 281 | case .failure(let error): return .reply(.failure(.captureFailed, error.message)) | ||
| 282 | case .success(let placed): return .reply(captured(placed.template, path: placed.path)) | ||
| 283 | } | ||
| 284 | } | ||
| 285 | |||
| 286 | /// The reply to a capture filed from the sheet or without it. | ||
| 287 | public func captured(_ template: CaptureTemplate, path: String) -> XCallbackReply { | ||
| 288 | .success(["template": template.key, "file": relative(path)]) | ||
| 289 | } | ||
| 290 | |||
| 291 | // MARK: - Open | ||
| 292 | |||
| 293 | private func open(_ request: XCallbackRequest) -> Step { | ||
| 294 | switch target(request) { | ||
| 295 | case .failed(let reply): return .reply(reply) | ||
| 296 | case .none: return .reply(.failure(.missingParameter, "Give file or id")) | ||
| 297 | case .found(let path, let offset): return .open(path: path, offset: offset, reply: .success(["file": relative(path)])) | ||
| 298 | } | ||
| 299 | } | ||
| 300 | |||
| 301 | /// The heading with `id`, or the file `file` (relative to a folder, or absolute inside one) | ||
| 302 | /// and in it the first heading titled `heading`. | ||
| 303 | func target(_ request: XCallbackRequest) -> Target { | ||
| 304 | if let id = request.value("id") { | ||
| 305 | guard let location = try? workspace.index.headings(withID: id).first else { return .failed(.failure(.notFound, "No heading with ID \"\(id)\"")) } | ||
| 306 | return .found(path: location.path, offset: location.start) | ||
| 307 | } | ||
| 308 | guard let file = request.value("file") else { return .none } | ||
| 309 | guard let path = resolve(file) else { return .failed(.failure(.notFound, "No file \"\(file)\" in orgstar's folders")) } | ||
| 310 | guard let heading = request.value("heading") else { return .found(path: path, offset: 0) } | ||
| 311 | guard let text = session.text(of: path), | ||
| 312 | let found = DocumentModel(tree: OrgParser.parse(text)).headings.first(where: { $0.title == heading }) else { | ||
| 313 | return .failed(.failure(.notFound, "No heading \"\(heading)\" in \(file)")) | ||
| 314 | } | ||
| 315 | return .found(path: path, offset: found.headingRange.lowerBound) | ||
| 316 | } | ||
| 317 | |||
| 318 | enum Target: Equatable { | ||
| 319 | case found(path: String, offset: Int) | ||
| 320 | /// The request names no entry. | ||
| 321 | case none | ||
| 322 | case failed(XCallbackReply) | ||
| 323 | } | ||
| 324 | |||
| 325 | /// A path relative to one of the folders, the first that has it, or an absolute path inside | ||
| 326 | /// one; nil for anything else. | ||
| 327 | func resolve(_ file: String) -> String? { | ||
| 328 | let roots = workspace.rootPaths | ||
| 329 | if file.hasPrefix("/") || file.hasPrefix("~") { | ||
| 330 | let path = (OrgPaths.expandingTilde(file) as NSString).standardizingPath | ||
| 331 | return roots.contains(where: { path.hasPrefix($0.hasSuffix("/") ? $0 : $0 + "/") }) && exists(path) ? path : nil | ||
| 332 | } | ||
| 333 | for root in roots { | ||
| 334 | let path = ((root as NSString).appendingPathComponent(file) as NSString).standardizingPath | ||
| 335 | if path.hasPrefix(root.hasSuffix("/") ? root : root + "/"), exists(path) { return path } | ||
| 336 | } | ||
| 337 | return nil | ||
| 338 | } | ||
| 339 | |||
| 340 | private func exists(_ path: String) -> Bool { | ||
| 341 | session.isOpen(path) || FileManager.default.fileExists(atPath: path) | ||
| 342 | } | ||
| 343 | |||
| 344 | /// `path` relative to the first folder holding it, or as it is. | ||
| 345 | func relative(_ path: String) -> String { | ||
| 346 | // `/tmp` and `/private/tmp` are one folder. | ||
| 347 | let resolved = URL(fileURLWithPath: path).resolvingSymlinksInPath().path | ||
| 348 | for root in workspace.rootPaths { | ||
| 349 | for (path, root) in [(path, root), (resolved, URL(fileURLWithPath: root).resolvingSymlinksInPath().path)] { | ||
| 350 | let prefix = root.hasSuffix("/") ? root : root + "/" | ||
| 351 | if path.hasPrefix(prefix) { return String(path.dropFirst(prefix.count)) } | ||
| 352 | } | ||
| 353 | } | ||
| 354 | return path | ||
| 355 | } | ||
| 356 | |||
| 357 | // MARK: - Agenda | ||
| 358 | |||
| 359 | /// One agenda line as the `result` JSON gives it. | ||
| 360 | struct Entry: Encodable, Equatable { | ||
| 361 | var section: String? | ||
| 362 | var date: String? | ||
| 363 | var time: String? | ||
| 364 | var end: String? | ||
| 365 | var kind: String? | ||
| 366 | var status: String | ||
| 367 | var todo: String? | ||
| 368 | var priority: String? | ||
| 369 | var title: String | ||
| 370 | var tags: [String]? | ||
| 371 | var category: String | ||
| 372 | var file: String? | ||
| 373 | } | ||
| 374 | |||
| 375 | private func agenda(_ request: XCallbackRequest) async -> XCallbackReply { | ||
| 376 | let name = request.value("view") ?? AgendaViewLoader.builtIn[0].name | ||
| 377 | let views = views() | ||
| 378 | guard let view = views.first(where: { $0.name == name }) ?? views.first(where: { $0.name.lowercased() == name.lowercased() }) else { | ||
| 379 | return .failure(.notFound, "No agenda view \"\(name)\"") | ||
| 380 | } | ||
| 381 | var limit = Self.defaultLimit | ||
| 382 | if let given = request.value("limit") { | ||
| 383 | guard let number = Int(given), number > 0 else { return .failure(.invalidParameter, "limit must be a number above 0") } | ||
| 384 | limit = min(number, Self.maximumLimit) | ||
| 385 | } | ||
| 386 | let model = AgendaModel(workspace: workspace) | ||
| 387 | model.viewSettings = AgendaViewLoader.settings(views) | ||
| 388 | model.mode = view.mode | ||
| 389 | model.span = OrgPreferences.agendaSpan() | ||
| 390 | model.startOffset = OrgPreferences.agendaStartOffset() | ||
| 391 | model.startOnWeekday = OrgPreferences.agendaStartOnWeekday() | ||
| 392 | model.includeSubfolders = OrgPreferences.agendaSubfolders() | ||
| 393 | model.excludeArchives = OrgPreferences.agendaExcludeArchives() | ||
| 394 | model.hiddenFolders = HiddenFolders.shared.all | ||
| 395 | model.agendaFiles = OrgPreferences.agendaFiles() | ||
| 396 | model.options = OrgPreferences.agendaOptions(model.options) | ||
| 397 | await model.refresh(open: session.openTexts, now: now(), calendar: calendar) | ||
| 398 | let entries = entries(model) | ||
| 399 | let kept = Array(entries.prefix(limit)) | ||
| 400 | let encoder = JSONEncoder() | ||
| 401 | encoder.outputFormatting = [.sortedKeys, .withoutEscapingSlashes] | ||
| 402 | let json = (try? encoder.encode(kept)).map { String(decoding: $0, as: UTF8.self) } ?? "[]" | ||
| 403 | return .success(["view": view.name, "result": json, "count": String(kept.count), "total": String(entries.count)]) | ||
| 404 | } | ||
| 405 | |||
| 406 | /// The view's lines, in order: each day's overdue entries and then its rows, or the list. | ||
| 407 | func entries(_ model: AgendaModel) -> [Entry] { | ||
| 408 | let today = model.today | ||
| 409 | func make(_ results: [(header: String?, days: [AgendaDay], list: [AgendaItem])]) -> [Entry] { | ||
| 410 | results.flatMap { result -> [Entry] in | ||
| 411 | let days = AgendaRows.groups(result.days, today: today, calendar: calendar).flatMap { group in | ||
| 412 | (group.overdue + group.rows).map { line($0, day: group.day, section: result.header) } | ||
| 413 | } | ||
| 414 | let list = result.list.compactMap { AgendaRow(item: $0, day: today, today: today) }.map { line($0, day: nil, section: result.header) } | ||
| 415 | return days + list | ||
| 416 | } | ||
| 417 | } | ||
| 418 | if case .blocks = model.mode { | ||
| 419 | return make(model.blocks.map { ($0.header, $0.days, $0.list) }) | ||
| 420 | } | ||
| 421 | return make([(nil, model.days, model.list)]) | ||
| 422 | } | ||
| 423 | |||
| 424 | private func line(_ row: AgendaRow, day: Int?, section: String?) -> Entry { | ||
| 425 | func date(_ day: Int) -> String { | ||
| 426 | let d = Days.date(day) | ||
| 427 | return String(format: "%04d-%02d-%02d", d.year, d.month, d.day) | ||
| 428 | } | ||
| 429 | func time(_ hhmm: Int?) -> String? { hhmm.map { String(format: "%02d:%02d", $0 / 100, $0 % 100) } } | ||
| 430 | return Entry( | ||
| 431 | section: section, date: day.map(date), time: time(row.start), end: time(row.end), kind: row.icon?.rawValue, status: row.status.rawValue, | ||
| 432 | todo: row.todo, priority: row.priority, title: row.title, tags: row.tags.isEmpty ? nil : row.tags, category: row.category, | ||
| 433 | file: row.item?.path.map(relative) | ||
| 434 | ) | ||
| 435 | } | ||
| 436 | |||
| 437 | // MARK: - Clock | ||
| 438 | |||
| 439 | private func clockIn(_ request: XCallbackRequest, ask: @escaping ClockModel.Ask) async -> XCallbackReply { | ||
| 440 | let target: ClockModel.Target | ||
| 441 | switch self.target(request) { | ||
| 442 | case .failed(let reply): return reply | ||
| 443 | case .found(let path, let offset): target = .entry(path: path, offset: offset) | ||
| 444 | case .none: target = .last | ||
| 445 | } | ||
| 446 | let paths = workspace.files.filter { $0.kind == .org }.map(\.path) | ||
| 447 | let outcome = await clock.clockIn(session, target: target, paths: paths, ask: ask, now: now) | ||
| 448 | if let running = clock.running { | ||
| 449 | if case .entry(let path, _) = target, running.path != path { | ||
| 450 | return .failure(.clockFailed, outcome.messages.last ?? "Can't clock in there") | ||
| 451 | } | ||
| 452 | return .success(clockStatus()) | ||
| 453 | } | ||
| 454 | return .failure(.clockFailed, outcome.messages.last ?? "Can't clock in there") | ||
| 455 | } | ||
| 456 | |||
| 457 | private func clockOut() -> XCallbackReply { | ||
| 458 | guard let running = clock.running else { return .failure(.noClock, "No active clock") } | ||
| 459 | let stopped = now() | ||
| 460 | let message = clock.clockOut(session, now: stopped) | ||
| 461 | guard clock.running == nil else { return .failure(.clockFailed, message) } | ||
| 462 | return .success([ | ||
| 463 | "heading": running.heading, "file": relative(running.path), | ||
| 464 | "minutes": String(max(0, Int(stopped.timeIntervalSince(running.startedAt) / 60))), | ||
| 465 | ]) | ||
| 466 | } | ||
| 467 | |||
| 468 | func clockStatus() -> [String: String] { | ||
| 469 | guard let running = clock.running else { return ["running": "false"] } | ||
| 470 | return [ | ||
| 471 | "running": "true", "heading": running.heading, "file": relative(running.path), | ||
| 472 | "started": ISO8601DateFormatter().string(from: running.startedAt), | ||
| 473 | "minutes": String(max(0, Int(now().timeIntervalSince(running.startedAt) / 60))), | ||
| 474 | ] | ||
| 475 | } | ||
| 476 | } | ||
Sources/OrgApp/XCallbackSettings.swift added +59 · view
| @@ -0,0 +1,59 @@ | |||
| 1 | import SwiftUI | ||
| 2 | |||
| 3 | /// The apps allowed to capture, clock and read through x-callback-url links, each with | ||
| 4 | /// Forget, for a settings form. | ||
| 5 | public struct XCallbackSettings: View { | ||
| 6 | @Bindable var approvals: XCallbackApprovals | ||
| 7 | |||
| 8 | public init(approvals: XCallbackApprovals = .shared) { | ||
| 9 | self.approvals = approvals | ||
| 10 | } | ||
| 11 | |||
| 12 | public var body: some View { | ||
| 13 | Section { | ||
| 14 | if approvals.sources.isEmpty { | ||
| 15 | Text("None").foregroundStyle(.secondary) | ||
| 16 | } | ||
| 17 | ForEach(approvals.sources) { source in | ||
| 18 | HStack { | ||
| 19 | VStack(alignment: .leading, spacing: 2) { | ||
| 20 | Text(XCallbackApprovals.name(source)) | ||
| 21 | Text(XCallbackApprovals.destination(source)).font(.caption).foregroundStyle(.secondary) | ||
| 22 | } | ||
| 23 | Spacer() | ||
| 24 | Button("Forget") { approvals.forget(source) }.buttonStyle(.borderless) | ||
| 25 | } | ||
| 26 | } | ||
| 27 | } header: { | ||
| 28 | Text("Apps Allowed to Use Links") | ||
| 29 | } footer: { | ||
| 30 | Text("Apps that may capture, clock in and out, and read your agenda and clock through orgstar:// x-callback-url links without asking.") | ||
| 31 | .font(.caption) | ||
| 32 | .foregroundStyle(.secondary) | ||
| 33 | .fixedSize(horizontal: false, vertical: true) | ||
| 34 | } | ||
| 35 | } | ||
| 36 | } | ||
| 37 | |||
| 38 | extension XCallbackApprovals { | ||
| 39 | /// The name the app gave, or a stand-in when it gave none. | ||
| 40 | public static func name(_ source: Source) -> String { | ||
| 41 | source.name.isEmpty ? String(localized: "An app that doesn't give its name") : source.name | ||
| 42 | } | ||
| 43 | |||
| 44 | /// Where results go: `Results go to shortcuts:`. | ||
| 45 | public static func destination(_ source: Source) -> String { | ||
| 46 | source.schemes.isEmpty | ||
| 47 | ? String(localized: "No results are sent back") | ||
| 48 | : String(localized: "Results go to \(source.schemes.map { $0 + ":" }.joined(separator: ", "))") | ||
| 49 | } | ||
| 50 | |||
| 51 | /// The question asked before an app's first link that writes to files or reads them. | ||
| 52 | public static func question(_ source: Source) -> String { | ||
| 53 | source.name.isEmpty ? String(localized: "Allow links from an app that doesn't give its name?") : String(localized: "Allow “\(source.name)” to use orgstar?") | ||
| 54 | } | ||
| 55 | |||
| 56 | public static func explanation(_ source: Source) -> String { | ||
| 57 | String(localized: "Its links will be able to capture, clock in and out, and read your agenda and clock without asking again. \(destination(source)). You can forget it in Settings.") | ||
| 58 | } | ||
| 59 | } | ||
Sources/Orgstar/CaptureView.swift +15 · view
| @@ -35,6 +35,8 @@ struct CaptureView: View { | |||
| 35 | @State private var day: Int? | 35 | @State private var day: Int? |
| 36 | /// An org-roam capture: its templates in place of capture.toml's, filed through it. | 36 | /// An org-roam capture: its templates in place of capture.toml's, filed through it. |
| 37 | @State private var roam: RoamCapture? | 37 | @State private var roam: RoamCapture? |
| 38 | /// The `captureRequest` serial of an x-callback-url capture, whose caller hears how it ends. | ||
| 39 | @State private var callbackSerial: Int? | ||
| 38 | @FocusState private var focused: Bool | 40 | @FocusState private var focused: Bool |
| 39 | @Environment(\.dismissWindow) private var dismissWindow | 41 | @Environment(\.dismissWindow) private var dismissWindow |
| 40 | @Environment(\.openWindow) private var openWindow | 42 | @Environment(\.openWindow) private var openWindow |
| @@ -136,6 +138,7 @@ struct CaptureView: View { | |||
| 136 | reset() | 138 | reset() |
| 137 | takeRequest() | 139 | takeRequest() |
| 138 | } | 140 | } |
| 141 | .onDisappear { endCallback(filed: nil) } | ||
| 139 | } | 142 | } |
| 140 | 143 | ||
| 141 | /// What an empty answer means. | 144 | /// What an empty answer means. |
| @@ -200,6 +203,9 @@ struct CaptureView: View { | |||
| 200 | private func takeRequest() { | 203 | private func takeRequest() { |
| 201 | guard let request = commands.captureRequest else { return } | 204 | guard let request = commands.captureRequest else { return } |
| 202 | commands.captureRequest = nil | 205 | commands.captureRequest = nil |
| 206 | // Another capture takes the window from an x-callback-url one, which ends cancelled. | ||
| 207 | endCallback(filed: nil) | ||
| 208 | if commands.captureCallback?.serial == request.serial { callbackSerial = request.serial } | ||
| 203 | if let roam = commands.roamCapture { | 209 | if let roam = commands.roamCapture { |
| 204 | commands.roamCapture = nil | 210 | commands.roamCapture = nil |
| 205 | self.roam = roam | 211 | self.roam = roam |
| @@ -315,6 +321,7 @@ struct CaptureView: View { | |||
| 315 | return | 321 | return |
| 316 | case .success(let entry): | 322 | case .success(let entry): |
| 317 | commands.show("Captured to \(Self.target(template))") | 323 | commands.show("Captured to \(Self.target(template))") |
| 324 | endCallback(filed: (template, entry.path)) | ||
| 318 | let options = template.options | 325 | let options = template.options |
| 319 | let paths = workspace.files.filter { $0.kind == .org }.map(\.path) | 326 | let paths = workspace.files.filter { $0.kind == .org }.map(\.path) |
| 320 | Task { [commands, clock, session, workspace] in | 327 | Task { [commands, clock, session, workspace] in |
| @@ -345,9 +352,17 @@ struct CaptureView: View { | |||
| 345 | } | 352 | } |
| 346 | 353 | ||
| 347 | private func close() { | 354 | private func close() { |
| 355 | endCallback(filed: nil) | ||
| 348 | reset() | 356 | reset() |
| 349 | dismissWindow(id: "capture") | 357 | dismissWindow(id: "capture") |
| 350 | } | 358 | } |
| 359 | |||
| 360 | /// Tells an x-callback-url capture's caller it was filed, or cancelled when `filed` is nil. | ||
| 361 | private func endCallback(filed: (template: CaptureTemplate, path: String)?) { | ||
| 362 | guard let serial = callbackSerial else { return } | ||
| 363 | callbackSerial = nil | ||
| 364 | commands.captureEnded(serial: serial, filed: filed) | ||
| 365 | } | ||
| 351 | } | 366 | } |
| 352 | 367 | ||
| 353 | /// A system-wide shortcut, registered with Carbon so it needs no accessibility permission. | 368 | /// A system-wide shortcut, registered with Carbon so it needs no accessibility permission. |
Sources/Orgstar/OrgstarApp.swift +64 −1 · view
| @@ -166,8 +166,66 @@ final class AppCommands { | |||
| 166 | captureRequest = (nil, [:], day, captureSerial) | 166 | captureRequest = (nil, [:], day, captureSerial) |
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | /// Runs x-callback-url actions; the main window sets it. | ||
| 170 | @ObservationIgnored var xCallbackRunner: XCallbackRunner? | ||
| 171 | /// The x-callback-url capture the capture window shows, with its `captureRequest` serial. | ||
| 172 | @ObservationIgnored private(set) var captureCallback: (request: XCallbackRequest, serial: Int)? | ||
| 173 | |||
| 174 | /// An `orgstar://x-callback-url/…` link. | ||
| 175 | func handle(xCallback request: XCallbackRequest) { | ||
| 176 | guard let runner = xCallbackRunner else { return reply(request, .failure(.notReady, "orgstar isn't ready")) } | ||
| 177 | Task { await take(runner.run(request, ask: askClock), for: request, runner: runner) } | ||
| 178 | } | ||
| 179 | |||
| 180 | private func take(_ step: XCallbackRunner.Step, for request: XCallbackRequest, runner: XCallbackRunner) async { | ||
| 181 | switch step { | ||
| 182 | case .reply(let reply): | ||
| 183 | self.reply(request, reply) | ||
| 184 | case .approve(let source): | ||
| 185 | NSApp.activate() | ||
| 186 | let alert = NSAlert() | ||
| 187 | alert.messageText = XCallbackApprovals.question(source) | ||
| 188 | alert.informativeText = XCallbackApprovals.explanation(source) | ||
| 189 | alert.addButton(withTitle: String(localized: "Allow")) | ||
| 190 | alert.addButton(withTitle: String(localized: "Don’t Allow")) | ||
| 191 | guard alert.runModal() == .alertFirstButtonReturn else { return reply(request, .failure(.notAllowed, "Not allowed")) } | ||
| 192 | runner.approvals.allow(source) | ||
| 193 | await take(runner.run(request, ask: askClock), for: request, runner: runner) | ||
| 194 | case .capture(let template, let properties): | ||
| 195 | if let pending = captureCallback { captureEnded(serial: pending.serial, filed: nil) } | ||
| 196 | captureSerial += 1 | ||
| 197 | captureRequest = (template, properties, nil, captureSerial) | ||
| 198 | captureCallback = (request, captureSerial) | ||
| 199 | run("app.capture") | ||
| 200 | case .open(let path, let offset, let reply): | ||
| 201 | NSApp.activate() | ||
| 202 | jump(path: path, offset: offset) | ||
| 203 | self.reply(request, reply) | ||
| 204 | } | ||
| 205 | } | ||
| 206 | |||
| 207 | /// Opens the request's callback for `reply`; a failure without one shows its message. | ||
| 208 | private func reply(_ request: XCallbackRequest, _ reply: XCallbackReply) { | ||
| 209 | if let url = request.callbackURL(for: reply) { | ||
| 210 | NSWorkspace.shared.open(url) | ||
| 211 | } else if case .failure(_, let message) = reply { | ||
| 212 | show(message) | ||
| 213 | } | ||
| 214 | } | ||
| 215 | |||
| 216 | /// The capture window filed the capture with this serial, or closed without filing it. | ||
| 217 | func captureEnded(serial: Int, filed: (template: CaptureTemplate, path: String)?) { | ||
| 218 | guard let pending = captureCallback, pending.serial == serial else { return } | ||
| 219 | captureCallback = nil | ||
| 220 | reply(pending.request, filed.map { xCallbackRunner?.captured($0.template, path: $0.path) ?? .success([:]) } ?? .cancel) | ||
| 221 | } | ||
| 222 | |||
| 169 | /// `org-protocol://capture` and `store-link`, and the widgets' `orgstar://` links. | 223 | /// `org-protocol://capture` and `store-link`, and the widgets' `orgstar://` links. |
| 170 | func handle(protocolURL url: String) { | 224 | func handle(protocolURL url: String) { |
| 225 | if let request = URL(string: url).flatMap(XCallbackRequest.init(url:)) { | ||
| 226 | handle(xCallback: request) | ||
| 227 | return | ||
| 228 | } | ||
| 171 | if let link = URL(string: url).flatMap(AppLink.init(url:)) { | 229 | if let link = URL(string: url).flatMap(AppLink.init(url:)) { |
| 172 | switch link { | 230 | switch link { |
| 173 | case .agenda: run("app.agenda") | 231 | case .agenda: run("app.agenda") |
| @@ -563,6 +621,10 @@ struct OrgstarApp: App { | |||
| 563 | session.fileWritten = { GitAutoCommit.shared.fileWritten($0) } | 621 | session.fileWritten = { GitAutoCommit.shared.fileWritten($0) } |
| 564 | #endif | 622 | #endif |
| 565 | CaptureIntent.environment = (model, session, clock, commands) | 623 | CaptureIntent.environment = (model, session, clock, commands) |
| 624 | var runner = XCallbackRunner(workspace: model, session: session, clock: clock) | ||
| 625 | runner.clipboard = { NSPasteboard.general.string(forType: .string) ?? "" } | ||
| 626 | runner.userName = NSFullUserName() | ||
| 627 | commands.xCallbackRunner = runner | ||
| 566 | } | 628 | } |
| 567 | case .failure(let error): | 629 | case .failure(let error): |
| 568 | ContentUnavailableView("Can't Open the Index", systemImage: "exclamationmark.triangle", description: Text(error.localizedDescription)) | 630 | ContentUnavailableView("Can't Open the Index", systemImage: "exclamationmark.triangle", description: Text(error.localizedDescription)) |
| @@ -1438,9 +1500,10 @@ struct SettingsView: View { | |||
| 1438 | Text("Templates go in \(CaptureTemplates.userFile.path).") | 1500 | Text("Templates go in \(CaptureTemplates.userFile.path).") |
| 1439 | .settingsFooter() | 1501 | .settingsFooter() |
| 1440 | } | 1502 | } |
| 1503 | XCallbackSettings() | ||
| 1441 | } | 1504 | } |
| 1442 | .formStyle(.grouped) | 1505 | .formStyle(.grouped) |
| 1443 | .frame(height: 160) | 1506 | .frame(height: 360) |
| 1444 | } | 1507 | } |
| 1445 | } | 1508 | } |
| 1446 | 1509 | ||
Sources/OrgstarMobile/CaptureScreen.swift +3 · view
| @@ -11,6 +11,8 @@ struct CaptureScreen: View { | |||
| 11 | let workspace: WorkspaceModel | 11 | let workspace: WorkspaceModel |
| 12 | let session: DocumentSession | 12 | let session: DocumentSession |
| 13 | let request: CaptureRequest | 13 | let request: CaptureRequest |
| 14 | /// Called with the template and file once the entry is filed. | ||
| 15 | var filed: (CaptureTemplate, String) -> Void = { _, _ in } | ||
| 14 | @Environment(\.dismiss) private var dismiss | 16 | @Environment(\.dismiss) private var dismiss |
| 15 | @Environment(ClockModel.self) private var clock | 17 | @Environment(ClockModel.self) private var clock |
| 16 | @Environment(MobileModel.self) private var model | 18 | @Environment(MobileModel.self) private var model |
| @@ -223,6 +225,7 @@ struct CaptureScreen: View { | |||
| 223 | problem = error.message | 225 | problem = error.message |
| 224 | editing = true | 226 | editing = true |
| 225 | case .success(let entry): | 227 | case .success(let entry): |
| 228 | filed(template, entry.path) | ||
| 226 | // Clocked from when capture began. | 229 | // Clocked from when capture began. |
| 227 | let paths = workspace.files.filter { $0.kind == .org }.map(\.path) | 230 | let paths = workspace.files.filter { $0.kind == .org }.map(\.path) |
| 228 | Task { [clock, session, opened = context.now] in | 231 | Task { [clock, session, opened = context.now] in |
Sources/OrgstarMobile/OrgstarMobileApp.swift +76 −2 · view
| @@ -166,11 +166,34 @@ extension CaptureRequest { | |||
| 166 | } | 166 | } |
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | /// Asks whether an app may use x-callback-url links that write to files or read them. | ||
| 170 | private struct XCallbackApproval: ViewModifier { | ||
| 171 | typealias Pending = (request: XCallbackRequest, source: XCallbackApprovals.Source) | ||
| 172 | @Binding var pending: Pending? | ||
| 173 | let allow: (Pending) -> Void | ||
| 174 | let deny: (Pending) -> Void | ||
| 175 | |||
| 176 | func body(content: Content) -> some View { | ||
| 177 | content.alert(pending.map { XCallbackApprovals.question($0.source) } ?? "", isPresented: Binding { pending != nil } set: { if !$0 { pending = nil } }, | ||
| 178 | presenting: pending) { pending in | ||
| 179 | Button("Allow") { allow(pending) } | ||
| 180 | Button("Don’t Allow", role: .cancel) { deny(pending) } | ||
| 181 | } message: { pending in | ||
| 182 | Text(XCallbackApprovals.explanation(pending.source)) | ||
| 183 | } | ||
| 184 | } | ||
| 185 | } | ||
| 186 | |||
| 169 | struct RootView: View { | 187 | struct RootView: View { |
| 170 | let model: MobileModel | 188 | let model: MobileModel |
| 171 | let workspace: WorkspaceModel | 189 | let workspace: WorkspaceModel |
| 172 | let agenda: AgendaModel | 190 | let agenda: AgendaModel |
| 173 | @State private var capture: CaptureRequest? | 191 | @State private var capture: CaptureRequest? |
| 192 | /// An x-callback-url capture in the sheet: its request, the sheet's request, and the reply | ||
| 193 | /// once it is filed. | ||
| 194 | @State private var xCallbackCapture: (request: XCallbackRequest, id: UUID, filed: XCallbackReply?)? | ||
| 195 | /// An x-callback-url request waiting for the answer to whether its app may use links. | ||
| 196 | @State private var approval: (request: XCallbackRequest, source: XCallbackApprovals.Source)? | ||
| 174 | /// The share extension's link whose capture sheet is showing, with its request's id. The link | 197 | /// The share extension's link whose capture sheet is showing, with its request's id. The link |
| 175 | /// stays in the inbox until the sheet is dismissed. | 198 | /// stays in the inbox until the sheet is dismissed. |
| 176 | @State private var shared: (link: CaptureInbox.Link, request: UUID)? | 199 | @State private var shared: (link: CaptureInbox.Link, request: UUID)? |
| @@ -407,8 +430,16 @@ struct RootView: View { | |||
| 407 | if let id, id != shared?.request { shared = nil } | 430 | if let id, id != shared?.request { shared = nil } |
| 408 | } | 431 | } |
| 409 | .sheet(item: $capture, onDismiss: captureDismissed) { request in | 432 | .sheet(item: $capture, onDismiss: captureDismissed) { request in |
| 410 | CaptureScreen(workspace: workspace, session: session, request: request) | 433 | CaptureScreen(workspace: workspace, session: session, request: request) { template, path in |
| 434 | if xCallbackCapture?.id == request.id { xCallbackCapture?.filed = xCallbackRunner.captured(template, path: path) } | ||
| 435 | } | ||
| 411 | } | 436 | } |
| 437 | .modifier(XCallbackApproval(pending: $approval, allow: { pending in | ||
| 438 | XCallbackApprovals.shared.allow(pending.source) | ||
| 439 | run(pending.request) | ||
| 440 | }, deny: { pending in | ||
| 441 | reply(pending.request, .failure(.notAllowed, "Not allowed")) | ||
| 442 | })) | ||
| 412 | .sheet(item: $sharedFiles) { shared in | 443 | .sheet(item: $sharedFiles) { shared in |
| 413 | RefileSheet(targets: workspace.refileTargets(openPath: nil, document: nil, settings: RefileSettings(targets: [.init(files: .workspace, spec: .all)])), | 444 | RefileSheet(targets: workspace.refileTargets(openPath: nil, document: nil, settings: RefileSettings(targets: [.init(files: .workspace, spec: .all)])), |
| 414 | title: "Attach to") { target in | 445 | title: "Attach to") { target in |
| @@ -513,6 +544,10 @@ struct RootView: View { | |||
| 513 | 544 | ||
| 514 | /// The shared capture was saved or discarded, so its link goes; then the next one shows. | 545 | /// The shared capture was saved or discarded, so its link goes; then the next one shows. |
| 515 | private func captureDismissed() { | 546 | private func captureDismissed() { |
| 547 | if let pending = xCallbackCapture, capture?.id != pending.id { | ||
| 548 | xCallbackCapture = nil | ||
| 549 | reply(pending.request, pending.filed ?? .cancel) | ||
| 550 | } | ||
| 516 | if let shared { model.inbox?.remove(shared.link) } | 551 | if let shared { model.inbox?.remove(shared.link) } |
| 517 | shared = nil | 552 | shared = nil |
| 518 | showWaiting() | 553 | showWaiting() |
| @@ -520,7 +555,9 @@ struct RootView: View { | |||
| 520 | 555 | ||
| 521 | /// A widget's or the Live Activity's link, or an org-protocol URL. | 556 | /// A widget's or the Live Activity's link, or an org-protocol URL. |
| 522 | private func handle(_ url: URL) { | 557 | private func handle(_ url: URL) { |
| 523 | if let callback = WorkingCopy.callback(url) { | 558 | if let request = XCallbackRequest(url: url) { |
| 559 | run(request) | ||
| 560 | } else if let callback = WorkingCopy.callback(url) { | ||
| 524 | model.workingCopy.finished(callback, workspace: workspace, session: session) | 561 | model.workingCopy.finished(callback, workspace: workspace, session: session) |
| 525 | } else if let link = AppLink(url: url) { | 562 | } else if let link = AppLink(url: url) { |
| 526 | open(link) | 563 | open(link) |
| @@ -541,6 +578,43 @@ struct RootView: View { | |||
| 541 | } | 578 | } |
| 542 | } | 579 | } |
| 543 | 580 | ||
| 581 | private var xCallbackRunner: XCallbackRunner { | ||
| 582 | XCallbackRunner(workspace: workspace, session: session, clock: model.clock) | ||
| 583 | } | ||
| 584 | |||
| 585 | /// An `orgstar://x-callback-url/…` link. | ||
| 586 | private func run(_ request: XCallbackRequest) { | ||
| 587 | Task { | ||
| 588 | switch await xCallbackRunner.run(request, ask: model.clockPrompts.ask) { | ||
| 589 | case .reply(let reply): | ||
| 590 | // Captures and clocks are written at once, as Shortcuts' are. | ||
| 591 | if [.capture, .clockIn, .clockOut].contains(request.known) { | ||
| 592 | for path in session.dirtyPaths { _ = session.save(path) } | ||
| 593 | } | ||
| 594 | self.reply(request, reply) | ||
| 595 | case .approve(let source): | ||
| 596 | approval = (request, source) | ||
| 597 | case .capture(let template, let properties): | ||
| 598 | if let pending = xCallbackCapture { reply(pending.request, pending.filed ?? .cancel) } | ||
| 599 | let sheet = CaptureRequest(template: template, properties: properties) | ||
| 600 | xCallbackCapture = (request, sheet.id, nil) | ||
| 601 | capture = sheet | ||
| 602 | case .open(let path, let offset, let reply): | ||
| 603 | model.openRequest = .offset(path, offset) | ||
| 604 | self.reply(request, reply) | ||
| 605 | } | ||
| 606 | } | ||
| 607 | } | ||
| 608 | |||
| 609 | /// Opens the request's callback for `reply`; a failure without one shows its message. | ||
| 610 | private func reply(_ request: XCallbackRequest, _ reply: XCallbackReply) { | ||
| 611 | if let url = request.callbackURL(for: reply) { | ||
| 612 | UIApplication.shared.open(url) | ||
| 613 | } else if case .failure(_, let message) = reply { | ||
| 614 | self.message = message | ||
| 615 | } | ||
| 616 | } | ||
| 617 | |||
| 544 | /// A file continued from another device, in the editor at the caret's heading or line there. | 618 | /// A file continued from another device, in the editor at the caret's heading or line there. |
| 545 | private func continueHandoff(_ place: HandoffPlace) { | 619 | private func continueHandoff(_ place: HandoffPlace) { |
| 546 | let match = place.resolve(roots: workspace.rootPaths) | 620 | let match = place.resolve(roots: workspace.rootPaths) |
Sources/OrgstarMobile/SettingsScreen.swift +1 · view
| @@ -86,6 +86,7 @@ struct SettingsScreen: View { | |||
| 86 | } | 86 | } |
| 87 | } | 87 | } |
| 88 | DecryptSettings() | 88 | DecryptSettings() |
| 89 | XCallbackSettings() | ||
| 89 | Section { | 90 | Section { |
| 90 | let _ = model.settingsVersion | 91 | let _ = model.settingsVersion |
| 91 | Toggle("Show days without entries", isOn: Binding { | 92 | Toggle("Show days without entries", isOn: Binding { |
Tests/OrgAppTests/XCallbackTests.swift added +227 · view
| @@ -0,0 +1,227 @@ | |||
| 1 | import Foundation | ||
| 2 | import OrgCore | ||
| 3 | import OrgDocument | ||
| 4 | import Testing | ||
| 5 | @testable import OrgApp | ||
| 6 | |||
| 7 | struct XCallbackRequestTests { | ||
| 8 | private func request(_ string: String) -> XCallbackRequest? { XCallbackRequest(url: URL(string: string)!) } | ||
| 9 | |||
| 10 | @Test func readsTheActionParametersAndCallbacks() throws { | ||
| 11 | let parsed = try #require(request( | ||
| 12 | "orgstar://x-callback-url/capture?template=t&text=Buy%20milk%20%26%20eggs&x-source=Shortcuts" | ||
| 13 | + "&x-success=shortcuts%3A%2F%2Fx-callback-url%2Fdone%3Fid%3D1&x-error=shortcuts://error&x-cancel=shortcuts://cancel&text=second" | ||
| 14 | )) | ||
| 15 | #expect(parsed.action == "capture") | ||
| 16 | #expect(parsed.known == .capture) | ||
| 17 | #expect(parsed.parameters == ["template": "t", "text": "Buy milk & eggs"]) | ||
| 18 | #expect(parsed.success?.absoluteString == "shortcuts://x-callback-url/done?id=1") | ||
| 19 | #expect(parsed.failure?.absoluteString == "shortcuts://error") | ||
| 20 | #expect(parsed.cancel?.absoluteString == "shortcuts://cancel") | ||
| 21 | #expect(parsed.source == "Shortcuts") | ||
| 22 | #expect(parsed.approvalSource == XCallbackApprovals.Source(name: "Shortcuts", schemes: ["shortcuts"])) | ||
| 23 | } | ||
| 24 | |||
| 25 | @Test func otherLinksAreNotRequests() throws { | ||
| 26 | #expect(request("orgstar://agenda") == nil) | ||
| 27 | #expect(request("orgstar://capture?template=t") == nil) | ||
| 28 | #expect(request("org-protocol://x-callback-url/capture") == nil) | ||
| 29 | #expect(AppLink(url: URL(string: "orgstar://x-callback-url/agenda")!) == nil) | ||
| 30 | let bare = try #require(request("orgstar://x-callback-url/clock-status")) | ||
| 31 | #expect(bare.known == .clockStatus) | ||
| 32 | #expect(bare.parameters.isEmpty && bare.success == nil && bare.source == nil) | ||
| 33 | #expect(bare.approvalSource == XCallbackApprovals.Source(name: "", schemes: [])) | ||
| 34 | #expect(try #require(request("orgstar://x-callback-url/frobnicate")).known == nil) | ||
| 35 | } | ||
| 36 | |||
| 37 | @Test func buildsCallbacksWithEncodedResults() throws { | ||
| 38 | let parsed = try #require(request( | ||
| 39 | "orgstar://x-callback-url/agenda?x-success=myapp%3A%2F%2Fdone%3Fkeep%3D1&x-error=myapp://failed&x-cancel=myapp://cancelled" | ||
| 40 | )) | ||
| 41 | let success = try #require(parsed.callbackURL(for: .success(["result": "[{\"title\":\"a & b = c+d?\"}]", "count": "1"]))) | ||
| 42 | #expect(success.absoluteString == "myapp://done?keep=1&count=1&result=%5B%7B%22title%22%3A%22a%20%26%20b%20%3D%20c%2Bd%3F%22%7D%5D") | ||
| 43 | let items = URLComponents(url: success, resolvingAgainstBaseURL: false)?.queryItems ?? [] | ||
| 44 | #expect(items.first { $0.name == "result" }?.value == "[{\"title\":\"a & b = c+d?\"}]") | ||
| 45 | let failure = try #require(parsed.callbackURL(for: .failure(.notFound, "No file \"x.org\""))) | ||
| 46 | #expect(failure.absoluteString == "myapp://failed?errorCode=not-found&errorMessage=No%20file%20%22x.org%22") | ||
| 47 | #expect(parsed.callbackURL(for: .cancel)?.absoluteString == "myapp://cancelled") | ||
| 48 | } | ||
| 49 | |||
| 50 | @Test func refusesLoopsAndWebCallbacks() throws { | ||
| 51 | for callback in ["orgstar://agenda", "ORGSTAR://x-callback-url/capture", "org-protocol://capture?body=x", "https://example.com/", "http://example.com/", "file:///tmp/x"] { | ||
| 52 | let escaped = callback.addingPercentEncoding(withAllowedCharacters: .alphanumerics)! | ||
| 53 | let parsed = try #require(request("orgstar://x-callback-url/clock-status?x-success=\(escaped)&x-error=\(escaped)&x-cancel=\(escaped)")) | ||
| 54 | #expect(parsed.callbackURL(for: .success([:])) == nil, "\(callback)") | ||
| 55 | #expect(parsed.callbackURL(for: .failure(.notFound, "x")) == nil, "\(callback)") | ||
| 56 | #expect(parsed.callbackURL(for: .cancel) == nil, "\(callback)") | ||
| 57 | } | ||
| 58 | #expect(XCallback.allows(URL(string: "shortcuts://x-callback-url/run")!)) | ||
| 59 | #expect(try #require(request("orgstar://x-callback-url/agenda")).callbackURL(for: .success([:])) == nil) | ||
| 60 | } | ||
| 61 | } | ||
| 62 | |||
| 63 | @MainActor | ||
| 64 | struct XCallbackApprovalsTests { | ||
| 65 | @Test func remembersAndForgetsSources() { | ||
| 66 | let defaults = TestDefaults("xcallback") | ||
| 67 | let approvals = XCallbackApprovals(defaults: defaults) | ||
| 68 | let shortcuts = XCallbackApprovals.Source(name: "Shortcuts", schemes: ["shortcuts"]) | ||
| 69 | #expect(!approvals.allows(shortcuts)) | ||
| 70 | approvals.allow(shortcuts) | ||
| 71 | approvals.allow(shortcuts) | ||
| 72 | #expect(approvals.sources == [shortcuts]) | ||
| 73 | #expect(XCallbackApprovals(defaults: defaults).allows(shortcuts)) | ||
| 74 | // The same name sending results to another app is another source. | ||
| 75 | #expect(!approvals.allows(XCallbackApprovals.Source(name: "Shortcuts", schemes: ["evil"]))) | ||
| 76 | approvals.forget(shortcuts) | ||
| 77 | #expect(!XCallbackApprovals(defaults: defaults).allows(shortcuts)) | ||
| 78 | } | ||
| 79 | } | ||
| 80 | |||
| 81 | @MainActor | ||
| 82 | struct XCallbackRunnerTests { | ||
| 83 | let notes: Folder | ||
| 84 | let workspace: WorkspaceModel | ||
| 85 | let session: DocumentSession | ||
| 86 | let clock: ClockModel | ||
| 87 | let defaults = TestDefaults("xcallback") | ||
| 88 | var runner: XCallbackRunner | ||
| 89 | |||
| 90 | init() async throws { | ||
| 91 | notes = try Folder() | ||
| 92 | try notes.write("todo.org", "* Inbox\n* Project\n:PROPERTIES:\n:ID: project-1\n:END:\n** TODO Write report\nSCHEDULED: <2026-11-26 Thu 10:00>\n* TODO Call Sam :phone:\n") | ||
| 93 | workspace = try WorkspaceModel(directory: nil) | ||
| 94 | try await workspace.addRoot(notes.url) | ||
| 95 | await workspace.refresh() | ||
| 96 | session = DocumentSession(recovery: FileRecoveryStore(directory: notes.url.appendingPathComponent(".r"))) | ||
| 97 | clock = ClockModel(file: notes.url.appendingPathComponent("clock.json"), defaults: defaults) | ||
| 98 | runner = XCallbackRunner(workspace: workspace, session: session, clock: clock, approvals: XCallbackApprovals(defaults: defaults)) | ||
| 99 | runner.isUnlocked = { true } | ||
| 100 | runner.templates = { | ||
| 101 | [ | ||
| 102 | CaptureTemplate(key: "t", name: "Todo", target: .headline(file: "todo.org", headline: "Inbox"), template: "* TODO %i\n%a"), | ||
| 103 | CaptureTemplate(key: "e", name: "Errand", target: .headline(file: "todo.org", headline: "Inbox"), template: "* TODO %^{What|Buy milk} %^g\n%i"), | ||
| 104 | ] | ||
| 105 | } | ||
| 106 | let now = try #require(ISO8601DateFormatter().date(from: "2026-11-26T09:00:00Z")) | ||
| 107 | runner.now = { now } | ||
| 108 | runner.calendar = Calendar(identifier: .gregorian) | ||
| 109 | runner.calendar.timeZone = TimeZone(identifier: "UTC")! | ||
| 110 | } | ||
| 111 | |||
| 112 | private func request(_ string: String) -> XCallbackRequest { XCallbackRequest(url: URL(string: "orgstar://x-callback-url/" + string)!)! } | ||
| 113 | |||
| 114 | private func allowed(_ string: String) -> XCallbackRequest { | ||
| 115 | let parsed = request(string) | ||
| 116 | runner.approvals.allow(parsed.approvalSource) | ||
| 117 | return parsed | ||
| 118 | } | ||
| 119 | |||
| 120 | private var todo: String { (try? String(contentsOf: notes.url.appendingPathComponent("todo.org"), encoding: .utf8)) ?? "" } | ||
| 121 | |||
| 122 | @Test func unknownActionsFail() async { | ||
| 123 | #expect(await runner.run(request("frobnicate")) == .reply(.failure(.unknownAction, "Unknown action \"frobnicate\""))) | ||
| 124 | } | ||
| 125 | |||
| 126 | @Test func writesAndReadsAskOncePerSourceAndNeedPro() async { | ||
| 127 | let status = request("clock-status?x-source=Shortcuts&x-success=shortcuts://done") | ||
| 128 | #expect(await runner.run(status) == .approve(XCallbackApprovals.Source(name: "Shortcuts", schemes: ["shortcuts"]))) | ||
| 129 | runner.approvals.allow(status.approvalSource) | ||
| 130 | #expect(await runner.run(status) == .reply(.success(["running": "false"]))) | ||
| 131 | // Capture through the sheet and open show what they do, so they don't ask. | ||
| 132 | #expect(await runner.run(request("capture?template=t&x-source=Web")) == .capture(template: "t", properties: ["annotation": "", "description": "", "initial": ""])) | ||
| 133 | var locked = runner | ||
| 134 | locked.isUnlocked = { false } | ||
| 135 | #expect(await locked.run(status) == .reply(.failure(.needsPro, "x-callback-url actions need orgstar+"))) | ||
| 136 | } | ||
| 137 | |||
| 138 | @Test func capturesWithoutTheSheetWhenEverythingIsGiven() async { | ||
| 139 | let step = await runner.run(allowed("capture?template=e&text=for%20the%20weekend&What=Buy%20bread&Tags=shop&x-source=Shortcuts")) | ||
| 140 | #expect(step == .reply(.success(["template": "e", "file": "todo.org"]))) | ||
| 141 | #expect(todo.hasPrefix("* Inbox\n** TODO Buy bread ")) | ||
| 142 | #expect(todo.contains(" :shop:\nfor the weekend\n* Project\n")) | ||
| 143 | } | ||
| 144 | |||
| 145 | @Test func capturesALinkAsOrgProtocolDoes() async { | ||
| 146 | let step = await runner.run(allowed("capture?template=t&text=Read&url=https%3A%2F%2Fexample.com&title=Example")) | ||
| 147 | #expect(step == .reply(.success(["template": "t", "file": "todo.org"]))) | ||
| 148 | #expect(todo.hasPrefix("* Inbox\n** TODO Read\n[[https://example.com][Example]]\n* Project\n")) | ||
| 149 | } | ||
| 150 | |||
| 151 | @Test func showsTheSheetWhenSomethingIsMissing() async { | ||
| 152 | let link = ["annotation": "[[https://example.com][Example]]", "description": "Example", "initial": "x", "link": "https://example.com", "type": "https"] | ||
| 153 | // An unanswered prompt, no text, no template, an unknown template. | ||
| 154 | #expect(await runner.run(request("capture?template=e&text=x&url=https%3A%2F%2Fexample.com&title=Example")) == .capture(template: "e", properties: link)) | ||
| 155 | #expect(await runner.run(request("capture?template=t")) == .capture(template: "t", properties: ["annotation": "", "description": "", "initial": ""])) | ||
| 156 | #expect(await runner.run(request("capture?text=x")) == .capture(template: nil, properties: ["annotation": "", "description": "", "initial": "x"])) | ||
| 157 | #expect(await runner.run(request("capture?template=zz&text=x")) == .capture(template: "zz", properties: ["annotation": "", "description": "", "initial": "x"])) | ||
| 158 | #expect(todo.hasPrefix("* Inbox\n* Project\n")) | ||
| 159 | } | ||
| 160 | |||
| 161 | @Test func capturedRepliesNameTheTemplateAndFile() { | ||
| 162 | let template = runner.templates()[0] | ||
| 163 | let path = (workspace.rootPaths[0] as NSString).appendingPathComponent("todo.org") | ||
| 164 | #expect(runner.captured(template, path: path) == .success(["template": "t", "file": "todo.org"])) | ||
| 165 | } | ||
| 166 | |||
| 167 | @Test func opensAFileAHeadingOrAnID() async throws { | ||
| 168 | let root = workspace.rootPaths[0] | ||
| 169 | let path = (root as NSString).appendingPathComponent("todo.org") | ||
| 170 | #expect(await runner.run(request("open?file=todo.org")) == .open(path: path, offset: 0, reply: .success(["file": "todo.org"]))) | ||
| 171 | #expect(await runner.run(request("open?file=todo.org&heading=Project")) == .open(path: path, offset: 8, reply: .success(["file": "todo.org"]))) | ||
| 172 | #expect(await runner.run(request("open?file=\(path)&heading=Call%20Sam")) == .open(path: path, offset: 107, reply: .success(["file": "todo.org"]))) | ||
| 173 | #expect(await runner.run(request("open?id=project-1")) == .open(path: path, offset: 8, reply: .success(["file": "todo.org"]))) | ||
| 174 | #expect(await runner.run(request("open?file=todo.org&heading=Nope")) == .reply(.failure(.notFound, "No heading \"Nope\" in todo.org"))) | ||
| 175 | #expect(await runner.run(request("open?file=missing.org")) == .reply(.failure(.notFound, "No file \"missing.org\" in orgstar's folders"))) | ||
| 176 | #expect(await runner.run(request("open?file=../outside.org")) == .reply(.failure(.notFound, "No file \"../outside.org\" in orgstar's folders"))) | ||
| 177 | #expect(await runner.run(request("open?file=/etc/hosts")) == .reply(.failure(.notFound, "No file \"/etc/hosts\" in orgstar's folders"))) | ||
| 178 | #expect(await runner.run(request("open?id=nope")) == .reply(.failure(.notFound, "No heading with ID \"nope\""))) | ||
| 179 | #expect(await runner.run(request("open")) == .reply(.failure(.missingParameter, "Give file or id"))) | ||
| 180 | } | ||
| 181 | |||
| 182 | @Test func runsAViewAndReturnsItsEntries() async throws { | ||
| 183 | let step = await runner.run(allowed("agenda?view=todo%20list")) | ||
| 184 | guard case .reply(.success(let result)) = step else { Issue.record("\(step)"); return } | ||
| 185 | #expect(result["view"] == "TODO List") | ||
| 186 | #expect(result["count"] == "2" && result["total"] == "2") | ||
| 187 | #expect(result["result"] == """ | ||
| 188 | [{"category":"todo","file":"todo.org","status":"normal","title":"Write report","todo":"TODO"},\ | ||
| 189 | {"category":"todo","file":"todo.org","status":"normal","tags":["phone"],"title":"Call Sam","todo":"TODO"}] | ||
| 190 | """) | ||
| 191 | let limited = await runner.run(allowed("agenda?view=TODO%20List&limit=1")) | ||
| 192 | guard case .reply(.success(let one)) = limited else { Issue.record("\(limited)"); return } | ||
| 193 | #expect(one["count"] == "1" && one["total"] == "2") | ||
| 194 | #expect(await runner.run(allowed("agenda?view=Nope")) == .reply(.failure(.notFound, "No agenda view \"Nope\""))) | ||
| 195 | #expect(await runner.run(allowed("agenda?limit=none")) == .reply(.failure(.invalidParameter, "limit must be a number above 0"))) | ||
| 196 | } | ||
| 197 | |||
| 198 | @Test func agendaDaysCarryTheirDateAndTime() async throws { | ||
| 199 | let step = await runner.run(allowed("agenda")) | ||
| 200 | guard case .reply(.success(let result)) = step, let json = result["result"] else { Issue.record("\(step)"); return } | ||
| 201 | let entries = try JSONSerialization.jsonObject(with: Data(json.utf8)) as? [[String: Any]] ?? [] | ||
| 202 | let report = try #require(entries.first { $0["title"] as? String == "Write report" }) | ||
| 203 | #expect(report["date"] as? String == "2026-11-26") | ||
| 204 | #expect(report["time"] as? String == "10:00") | ||
| 205 | #expect(report["kind"] as? String == "scheduled") | ||
| 206 | } | ||
| 207 | |||
| 208 | @Test func clocksInReportsAndClocksOut() async throws { | ||
| 209 | #expect(await runner.run(allowed("clock-out")) == .reply(.failure(.noClock, "No active clock"))) | ||
| 210 | let step = await runner.run(allowed("clock-in?file=todo.org&heading=Call%20Sam")) | ||
| 211 | guard case .reply(.success(let started)) = step else { Issue.record("\(step)"); return } | ||
| 212 | #expect(started["running"] == "true") | ||
| 213 | #expect(started["heading"] == "Call Sam") | ||
| 214 | #expect(started["file"] == "todo.org") | ||
| 215 | #expect(started["started"] == "2026-11-26T09:00:00Z") | ||
| 216 | #expect(started["minutes"] == "0") | ||
| 217 | #expect(todo.contains("* TODO Call Sam :phone:\n:LOGBOOK:\nCLOCK: [2026-11-26")) | ||
| 218 | #expect(await runner.run(allowed("clock-status")) == .reply(.success(started))) | ||
| 219 | guard case .reply(.success(let stopped)) = await runner.run(allowed("clock-out")) else { Issue.record("not stopped"); return } | ||
| 220 | #expect(stopped == ["heading": "Call Sam", "file": "todo.org", "minutes": "0"]) | ||
| 221 | #expect(clock.running == nil) | ||
| 222 | // Without an entry, the entry clocked last. | ||
| 223 | guard case .reply(.success(let again)) = await runner.run(allowed("clock-in")) else { Issue.record("not clocked in again"); return } | ||
| 224 | #expect(again["heading"] == "Call Sam") | ||
| 225 | #expect(await runner.run(allowed("clock-in?file=todo.org&heading=Nope")) == .reply(.failure(.notFound, "No heading \"Nope\" in todo.org"))) | ||
| 226 | } | ||
| 227 | } | ||
docs/manual/guide/08-capture.org +2 · view
| @@ -332,6 +332,8 @@ Every prompt in the template takes its default (an empty answer: today for dates | |||
| 332 | 332 | ||
| 333 | On the Mac, the action opens orgstar if it isn't running and waits up to five seconds for it to be ready. | 333 | On the Mac, the action opens orgstar if it isn't running and waits up to five seconds for it to be ready. |
| 334 | 334 | ||
| 335 | Apps other than Shortcuts can capture through ~orgstar://x-callback-url/capture~ links, which also answer the template's prompts and report back; see [[file:15-alongside-emacs.org::*orgstar:// links and x-callback-url][orgstar:// links and x-callback-url]]. | ||
| 336 | |||
| 335 | * Capture on iOS | 337 | * Capture on iOS |
| 336 | 338 | ||
| 337 | The Capture button (a square with a pencil) at the top of the Agenda and Folders tabs opens the capture sheet. The + on a day's header in the Agenda tab opens it for that day, as described in [[*Capturing onto an agenda day][Capturing onto an agenda day]]; date prompts then show that day as their default. The templates come from the =capture.toml= in your synced configuration folder (see [[file:14-ios.org][iOS]]). | 339 | The Capture button (a square with a pencil) at the top of the Agenda and Folders tabs opens the capture sheet. The + on a day's header in the Agenda tab opens it for that day, as described in [[*Capturing onto an agenda day][Capturing onto an agenda day]]; date prompts then show that day as their default. The templates come from the =capture.toml= in your synced configuration folder (see [[file:14-ios.org][iOS]]). |
docs/manual/guide/14-ios.org +2 · view
| @@ -332,6 +332,8 @@ The widgets and the Live Activity open the app with these links, which also work | |||
| 332 | | =orgstar://review= | Review Flashcards | | 332 | | =orgstar://review= | Review Flashcards | |
| 333 | | ~orgstar://entry?path=/path/file.org&offset=N~ | The file in the reader, at offset N | | 333 | | ~orgstar://entry?path=/path/file.org&offset=N~ | The file in the reader, at offset N | |
| 334 | 334 | ||
| 335 | Other apps can also capture, open an entry, read the agenda and clock in and out through ~orgstar://x-callback-url/…~ links, and get results back. See [[file:15-alongside-emacs.org::*orgstar:// links and x-callback-url][orgstar:// links and x-callback-url]]. | ||
| 336 | |||
| 335 | * Apple Watch | 337 | * Apple Watch |
| 336 | 338 | ||
| 337 | The watch app shows today's agenda from your iPhone, marks entries done, shows and stops the running clock, and takes dictated captures. It comes with orgstar on iPhone and installs on a paired watch as other watch apps do. It reads nothing itself: your iPhone sends it today's agenda and the clock whenever its widgets update (when files, edits or settings change while orgstar is open, and when you return to it) and whenever the clock starts or stops, and the watch keeps the last one it got. Until it has one, it shows only =Open orgstar on your iPhone to show your agenda here.= | 339 | The watch app shows today's agenda from your iPhone, marks entries done, shows and stops the running clock, and takes dictated captures. It comes with orgstar on iPhone and installs on a paired watch as other watch apps do. It reads nothing itself: your iPhone sends it today's agenda and the clock whenever its widgets update (when files, edits or settings change while orgstar is open, and when you return to it) and whenever the clock starts or stops, and the watch keeps the last one it got. Until it has one, it shows only =Open orgstar on your iPhone to show your agenda here.= |
docs/manual/guide/15-alongside-emacs.org +137 · view
| @@ -178,6 +178,143 @@ Other sub-protocols, such as =open-source=, show "orgstar handles org-protocol c | |||
| 178 | 178 | ||
| 179 | The Shortcuts action Capture to orgstar, on the Mac and iOS, files text with a capture template without opening the capture window. See [[file:08-capture.org][Capture]]. | 179 | The Shortcuts action Capture to orgstar, on the Mac and iOS, files text with a capture template without opening the capture window. See [[file:08-capture.org][Capture]]. |
| 180 | 180 | ||
| 181 | * orgstar:// links and x-callback-url | ||
| 182 | |||
| 183 | orgstar registers the =orgstar:= URL scheme on the Mac and iOS. These links open part of the app; the widgets and the Live Activity use them, and they work from Shortcuts, a browser, a note or =open= in Terminal: | ||
| 184 | |||
| 185 | | Link | Opens | | ||
| 186 | |------------------------------------------------+-------------------------------------------------------| | ||
| 187 | | =orgstar://agenda= | The agenda | | ||
| 188 | | =orgstar://clock= | The entry of the running clock | | ||
| 189 | | =orgstar://review= | Review Flashcards | | ||
| 190 | | ~orgstar://capture?template=t~ | Capture with that template, or the template list | | ||
| 191 | | ~orgstar://entry?path=/path/file.org&offset=N~ | The file at offset N | | ||
| 192 | |||
| 193 | ** x-callback-url | ||
| 194 | |||
| 195 | Links of the form ~orgstar://x-callback-url/action?parameters~ follow [[https://x-callback-url.com][x-callback-url 1.0]]: another app asks orgstar to do something and names links to open afterwards. Besides an action's own parameters, every action takes: | ||
| 196 | |||
| 197 | | Parameter | Meaning | | ||
| 198 | |-------------+------------------------------------------------------------------------------------------| | ||
| 199 | | =x-success= | Opened when the action succeeds, with the result's parameters added to its query | | ||
| 200 | | =x-error= | Opened when it fails, with =errorCode= and =errorMessage= added | | ||
| 201 | | =x-cancel= | Opened when you close the capture window or sheet without filing | | ||
| 202 | | =x-source= | The calling app's name, shown when orgstar asks whether to allow it | | ||
| 203 | |||
| 204 | Values are percent-encoded, as in any URL; encode a =+= in a value as =%2B=. Without =x-error=, an error shows in orgstar's message area. | ||
| 205 | |||
| 206 | *** capture | ||
| 207 | |||
| 208 | | Parameter | Meaning | | ||
| 209 | |-----------------+----------------------------------------------------------------------------------| | ||
| 210 | | =template= | A template's =key= in =capture.toml= | | ||
| 211 | | =text= | The text, inserted as =%i= | | ||
| 212 | | =url=, =title= | A link, as org-protocol gives one: =%a=, =%:link=, =%:description= | | ||
| 213 | | /prompt name/ | The answer to the prompt with that text: =What= for =%^{What}=, =Tags= for =%^g=, =Date= for =%^t=, =Effort= for =%^{Effort}p= | | ||
| 214 | |||
| 215 | With =template= and =text= given and a parameter for every prompt in the template, orgstar files the entry without showing anything, as Capture to orgstar does in Shortcuts; on iOS the file is saved at once. =%^C= and =%^L= insert nothing. Otherwise the capture window (Mac) or sheet (iOS) opens with the template chosen (the template list without =template=), the text as =%i= and the link as =%a=, and asks what is missing; prompt answers given in the link aren't filled in there. Templates that make a Denote note or ask for a date tree's day (=time-prompt=) always open it. Closing it without filing opens =x-cancel=. | ||
| 216 | |||
| 217 | Result: =template= (the key) and =file= (the target, relative to its folder). | ||
| 218 | |||
| 219 | *** open | ||
| 220 | |||
| 221 | | Parameter | Meaning | | ||
| 222 | |-----------+-----------------------------------------------------------------------------------------------| | ||
| 223 | | =file= | A file relative to one of your folders (the first that has it), or an absolute path inside one | | ||
| 224 | | =heading= | With =file=: the first heading with this title | | ||
| 225 | | =id= | Instead of =file=: the heading with this =ID= property | | ||
| 226 | |||
| 227 | Shows the file or heading: in the editor on the Mac, in the reader on iOS. Result: =file=. | ||
| 228 | |||
| 229 | *** agenda | ||
| 230 | |||
| 231 | | Parameter | Meaning | | ||
| 232 | |-----------+------------------------------------------------------------------------------------------------------------| | ||
| 233 | | =view= | A view's name: =Agenda= (the default), =TODO List=, =Stuck Projects=, or one in =views.toml=; case is ignored | | ||
| 234 | | =limit= | How many entries to return: 50 when not given, at most 200 | | ||
| 235 | |||
| 236 | Runs the view with your agenda settings, as the agenda shows it. Calendar events and reminders are left out. Result: | ||
| 237 | |||
| 238 | | Parameter | Meaning | | ||
| 239 | |-----------+---------------------------------------------------------| | ||
| 240 | | =view= | The view's name | | ||
| 241 | | =result= | The entries, as a JSON array | | ||
| 242 | | =count= | How many entries =result= holds | | ||
| 243 | | =total= | How many entries the view has; more than =count= when =limit= cut it | | ||
| 244 | |||
| 245 | Each entry is an object with these keys, those without a value left out: | ||
| 246 | |||
| 247 | | Key | Value | | ||
| 248 | |------------+---------------------------------------------------------------------------------------------| | ||
| 249 | | =title= | The heading's title | | ||
| 250 | | =todo= | Its TODO keyword | | ||
| 251 | | =priority= | Its priority letter | | ||
| 252 | | =tags= | Its tags, as an array | | ||
| 253 | | =category= | Its category | | ||
| 254 | | =file= | Its file, relative to its folder | | ||
| 255 | | =status= | =overdue=, =due-soon=, =normal= or =done= | | ||
| 256 | | =date= | Agenda views: the day it shows on, =2026-11-26=; overdue entries show on today | | ||
| 257 | | =time=, =end= | Agenda views: its start and end time, =10:00= | | ||
| 258 | | =kind= | Agenda views: =scheduled=, =deadline=, =habit= or =timestamp= | | ||
| 259 | | =section= | Block views: the header of the block it is in | | ||
| 260 | |||
| 261 | To show an entry, pass its =file= and =title= to =open= as =file= and =heading=. | ||
| 262 | |||
| 263 | *** clock-in, clock-out and clock-status | ||
| 264 | |||
| 265 | =clock-in= takes =id=, or =file= and =heading=, as =open= does, and clocks in to that heading; without them, to the entry clocked last. Dangling clocks are asked about in orgstar first, as Clock In asks. =clock-out= stops the running clock. =clock-status= changes nothing. | ||
| 266 | |||
| 267 | | Action | Result | | ||
| 268 | |----------------+----------------------------------------------------------------------------------------| | ||
| 269 | | =clock-in= | As =clock-status= | | ||
| 270 | | =clock-out= | =heading=, =file= and =minutes= clocked | | ||
| 271 | | =clock-status= | =running= (=true= or =false=), and while a clock runs =heading=, =file=, =started= (ISO 8601) and =minutes= | | ||
| 272 | |||
| 273 | On iOS the file is saved at once. | ||
| 274 | |||
| 275 | *** Errors | ||
| 276 | |||
| 277 | | =errorCode= | When | | ||
| 278 | |----------------------+--------------------------------------------------------------------------| | ||
| 279 | | =unknown-action= | The action isn't one of the above | | ||
| 280 | | =missing-parameter= | =open= without =file= or =id= | | ||
| 281 | | =invalid-parameter= | =limit= isn't a number above 0 | | ||
| 282 | | =not-found= | No such file, heading, ID or view | | ||
| 283 | | =capture-failed= | The template can't be filled or filed; =errorMessage= says why | | ||
| 284 | | =clock-failed= | Clocking in or out failed; =errorMessage= says why | | ||
| 285 | | =no-clock= | =clock-out= with no clock running | | ||
| 286 | | =not-allowed= | You chose Don't Allow | | ||
| 287 | | =needs-orgstar-plus= | The action needs orgstar+ | | ||
| 288 | | =not-ready= | The Mac app's window isn't open yet | | ||
| 289 | |||
| 290 | *** Which links orgstar opens | ||
| 291 | |||
| 292 | orgstar opens =x-success=, =x-error= and =x-cancel= only for other apps' schemes. It never opens =orgstar:= links (a link could call itself), =org-protocol:= links (they would capture), or =http:=, =https:=, =file:=, =ftp:=, =javascript:=, =data:=, =about:= and =blob:= links, which would send results to a web server or open a download. Such a callback is skipped and the action still runs. | ||
| 293 | |||
| 294 | *** Allowing apps | ||
| 295 | |||
| 296 | A link from a web page or another app could write to your files or read them. So capture without the window or sheet, =clock-in=, =clock-out=, =agenda= and =clock-status= need orgstar+, as Shortcuts actions do, and the first time an app uses one of them orgstar asks: Allow "/name/" to use orgstar?, with where results go. Allow remembers the app; Don't Allow opens =x-error= with =not-allowed=. An app is the =x-source= name together with the schemes of its callbacks, so a link that gives an allowed name but sends results to another app asks again. =x-source= is whatever the link says, so allow only names you expect to see. | ||
| 297 | |||
| 298 | =open= and capture through the window or sheet never ask, as =org-protocol://capture= doesn't: they show what they do and write nothing until you file. | ||
| 299 | |||
| 300 | Allowed apps are listed under Apps Allowed to Use Links, in Settings ▸ Capture on the Mac and the Settings tab on iOS, each with Forget. | ||
| 301 | |||
| 302 | *** Shortcuts or x-callback-url | ||
| 303 | |||
| 304 | In Shortcuts, use the Capture to orgstar action: it runs without switching apps and returns its message as a value. Use x-callback-url from apps that support it (Drafts, launchers, Shortcuts' Open X-Callback URL action, =open= in Terminal), and for opening entries, the agenda and the clock, which have no Shortcuts action. | ||
| 305 | |||
| 306 | *** Examples | ||
| 307 | |||
| 308 | #+BEGIN_SRC text | ||
| 309 | orgstar://x-callback-url/capture?template=t&text=Call%20Sam&x-source=Drafts&x-success=drafts:// | ||
| 310 | orgstar://x-callback-url/capture?template=w&url=https%3A%2F%2Fexample.com&title=Example&x-cancel=myapp://cancelled | ||
| 311 | orgstar://x-callback-url/open?file=work%2Fprojects.org&heading=Website | ||
| 312 | orgstar://x-callback-url/agenda?view=TODO%20List&limit=10&x-source=My%20App&x-success=myapp://agenda | ||
| 313 | orgstar://x-callback-url/clock-in?id=5f0c1e2a&x-success=myapp://clocked | ||
| 314 | #+END_SRC | ||
| 315 | |||
| 316 | The agenda example opens a link like ~myapp://agenda?count=1&result=%5B%7B%22title%22…&total=1&view=TODO%20List~. On the Mac, try them from Terminal with =open '…'=. | ||
| 317 | |||
| 181 | * Compatibility notes | 318 | * Compatibility notes |
| 182 | 319 | ||
| 183 | ** Defaults that differ from Emacs | 320 | ** Defaults that differ from Emacs |
l10n/Localizable.xcstrings +340 · view
| @@ -5835,6 +5835,40 @@ | |||
| 5835 | } | 5835 | } |
| 5836 | } | 5836 | } |
| 5837 | }, | 5837 | }, |
| 5838 | "Allow": { | ||
| 5839 | "localizations": { | ||
| 5840 | "de": { | ||
| 5841 | "stringUnit": { | ||
| 5842 | "state": "translated", | ||
| 5843 | "value": "Erlauben" | ||
| 5844 | } | ||
| 5845 | }, | ||
| 5846 | "es": { | ||
| 5847 | "stringUnit": { | ||
| 5848 | "state": "translated", | ||
| 5849 | "value": "Permitir" | ||
| 5850 | } | ||
| 5851 | }, | ||
| 5852 | "fr": { | ||
| 5853 | "stringUnit": { | ||
| 5854 | "state": "translated", | ||
| 5855 | "value": "Autoriser" | ||
| 5856 | } | ||
| 5857 | }, | ||
| 5858 | "ja": { | ||
| 5859 | "stringUnit": { | ||
| 5860 | "state": "translated", | ||
| 5861 | "value": "許可" | ||
| 5862 | } | ||
| 5863 | }, | ||
| 5864 | "pt-BR": { | ||
| 5865 | "stringUnit": { | ||
| 5866 | "state": "translated", | ||
| 5867 | "value": "Permitir" | ||
| 5868 | } | ||
| 5869 | } | ||
| 5870 | } | ||
| 5871 | }, | ||
| 5838 | "Allow Access to Calendars…": { | 5872 | "Allow Access to Calendars…": { |
| 5839 | "localizations": { | 5873 | "localizations": { |
| 5840 | "de": { | 5874 | "de": { |
| @@ -5938,6 +5972,40 @@ | |||
| 5938 | } | 5972 | } |
| 5939 | } | 5973 | } |
| 5940 | }, | 5974 | }, |
| 5975 | "Allow links from an app that doesn't give its name?": { | ||
| 5976 | "localizations": { | ||
| 5977 | "de": { | ||
| 5978 | "stringUnit": { | ||
| 5979 | "state": "translated", | ||
| 5980 | "value": "Links von einer App erlauben, die ihren Namen nicht angibt?" | ||
| 5981 | } | ||
| 5982 | }, | ||
| 5983 | "es": { | ||
| 5984 | "stringUnit": { | ||
| 5985 | "state": "translated", | ||
| 5986 | "value": "¿Permitir enlaces de una app que no da su nombre?" | ||
| 5987 | } | ||
| 5988 | }, | ||
| 5989 | "fr": { | ||
| 5990 | "stringUnit": { | ||
| 5991 | "state": "translated", | ||
| 5992 | "value": "Autoriser les liens d’une app qui ne donne pas son nom ?" | ||
| 5993 | } | ||
| 5994 | }, | ||
| 5995 | "ja": { | ||
| 5996 | "stringUnit": { | ||
| 5997 | "state": "translated", | ||
| 5998 | "value": "名前を示さないAppからのリンクを許可しますか?" | ||
| 5999 | } | ||
| 6000 | }, | ||
| 6001 | "pt-BR": { | ||
| 6002 | "stringUnit": { | ||
| 6003 | "state": "translated", | ||
| 6004 | "value": "Permitir links de um app que não informa seu nome?" | ||
| 6005 | } | ||
| 6006 | } | ||
| 6007 | } | ||
| 6008 | }, | ||
| 5941 | "Allow orgstar to read your calendars in System Settings ▸ Privacy & Security ▸ Calendars.": { | 6009 | "Allow orgstar to read your calendars in System Settings ▸ Privacy & Security ▸ Calendars.": { |
| 5942 | "localizations": { | 6010 | "localizations": { |
| 5943 | "de": { | 6011 | "de": { |
| @@ -6006,6 +6074,40 @@ | |||
| 6006 | } | 6074 | } |
| 6007 | } | 6075 | } |
| 6008 | }, | 6076 | }, |
| 6077 | "Allow “%@” to use orgstar?": { | ||
| 6078 | "localizations": { | ||
| 6079 | "de": { | ||
| 6080 | "stringUnit": { | ||
| 6081 | "state": "translated", | ||
| 6082 | "value": "„%@“ erlauben, orgstar zu verwenden?" | ||
| 6083 | } | ||
| 6084 | }, | ||
| 6085 | "es": { | ||
| 6086 | "stringUnit": { | ||
| 6087 | "state": "translated", | ||
| 6088 | "value": "¿Permitir que «%@» use orgstar?" | ||
| 6089 | } | ||
| 6090 | }, | ||
| 6091 | "fr": { | ||
| 6092 | "stringUnit": { | ||
| 6093 | "state": "translated", | ||
| 6094 | "value": "Autoriser « %@ » à utiliser orgstar ?" | ||
| 6095 | } | ||
| 6096 | }, | ||
| 6097 | "ja": { | ||
| 6098 | "stringUnit": { | ||
| 6099 | "state": "translated", | ||
| 6100 | "value": "“%@”にorgstarの使用を許可しますか?" | ||
| 6101 | } | ||
| 6102 | }, | ||
| 6103 | "pt-BR": { | ||
| 6104 | "stringUnit": { | ||
| 6105 | "state": "translated", | ||
| 6106 | "value": "Permitir que “%@” use o orgstar?" | ||
| 6107 | } | ||
| 6108 | } | ||
| 6109 | } | ||
| 6110 | }, | ||
| 6009 | "Already in the folder, so imported under another name:": { | 6111 | "Already in the folder, so imported under another name:": { |
| 6010 | "localizations": { | 6112 | "localizations": { |
| 6011 | "de": { | 6113 | "de": { |
| @@ -6110,6 +6212,40 @@ | |||
| 6110 | } | 6212 | } |
| 6111 | } | 6213 | } |
| 6112 | }, | 6214 | }, |
| 6215 | "An app that doesn't give its name": { | ||
| 6216 | "localizations": { | ||
| 6217 | "de": { | ||
| 6218 | "stringUnit": { | ||
| 6219 | "state": "translated", | ||
| 6220 | "value": "Eine App, die ihren Namen nicht angibt" | ||
| 6221 | } | ||
| 6222 | }, | ||
| 6223 | "es": { | ||
| 6224 | "stringUnit": { | ||
| 6225 | "state": "translated", | ||
| 6226 | "value": "Una app que no da su nombre" | ||
| 6227 | } | ||
| 6228 | }, | ||
| 6229 | "fr": { | ||
| 6230 | "stringUnit": { | ||
| 6231 | "state": "translated", | ||
| 6232 | "value": "Une app qui ne donne pas son nom" | ||
| 6233 | } | ||
| 6234 | }, | ||
| 6235 | "ja": { | ||
| 6236 | "stringUnit": { | ||
| 6237 | "state": "translated", | ||
| 6238 | "value": "名前を示さないApp" | ||
| 6239 | } | ||
| 6240 | }, | ||
| 6241 | "pt-BR": { | ||
| 6242 | "stringUnit": { | ||
| 6243 | "state": "translated", | ||
| 6244 | "value": "Um app que não informa seu nome" | ||
| 6245 | } | ||
| 6246 | } | ||
| 6247 | } | ||
| 6248 | }, | ||
| 6113 | "An entry's APPT_WARNTIME property overrides the lead time.": { | 6249 | "An entry's APPT_WARNTIME property overrides the lead time.": { |
| 6114 | "localizations": { | 6250 | "localizations": { |
| 6115 | "de": { | 6251 | "de": { |
| @@ -6280,6 +6416,74 @@ | |||
| 6280 | } | 6416 | } |
| 6281 | } | 6417 | } |
| 6282 | }, | 6418 | }, |
| 6419 | "Apps Allowed to Use Links": { | ||
| 6420 | "localizations": { | ||
| 6421 | "de": { | ||
| 6422 | "stringUnit": { | ||
| 6423 | "state": "translated", | ||
| 6424 | "value": "Apps, die Links verwenden dürfen" | ||
| 6425 | } | ||
| 6426 | }, | ||
| 6427 | "es": { | ||
| 6428 | "stringUnit": { | ||
| 6429 | "state": "translated", | ||
| 6430 | "value": "Apps autorizadas a usar enlaces" | ||
| 6431 | } | ||
| 6432 | }, | ||
| 6433 | "fr": { | ||
| 6434 | "stringUnit": { | ||
| 6435 | "state": "translated", | ||
| 6436 | "value": "Apps autorisées à utiliser les liens" | ||
| 6437 | } | ||
| 6438 | }, | ||
| 6439 | "ja": { | ||
| 6440 | "stringUnit": { | ||
| 6441 | "state": "translated", | ||
| 6442 | "value": "リンクの使用を許可したApp" | ||
| 6443 | } | ||
| 6444 | }, | ||
| 6445 | "pt-BR": { | ||
| 6446 | "stringUnit": { | ||
| 6447 | "state": "translated", | ||
| 6448 | "value": "Apps Autorizados a Usar Links" | ||
| 6449 | } | ||
| 6450 | } | ||
| 6451 | } | ||
| 6452 | }, | ||
| 6453 | "Apps that may capture, clock in and out, and read your agenda and clock through orgstar:// x-callback-url links without asking.": { | ||
| 6454 | "localizations": { | ||
| 6455 | "de": { | ||
| 6456 | "stringUnit": { | ||
| 6457 | "state": "translated", | ||
| 6458 | "value": "Apps, die über orgstar://-x-callback-url-Links ohne Nachfrage erfassen, die Zeiterfassung starten und stoppen und deine Agenda und Uhr lesen dürfen." | ||
| 6459 | } | ||
| 6460 | }, | ||
| 6461 | "es": { | ||
| 6462 | "stringUnit": { | ||
| 6463 | "state": "translated", | ||
| 6464 | "value": "Apps que pueden capturar, iniciar y detener el reloj y leer tu agenda y tu reloj mediante enlaces x-callback-url de orgstar:// sin preguntar." | ||
| 6465 | } | ||
| 6466 | }, | ||
| 6467 | "fr": { | ||
| 6468 | "stringUnit": { | ||
| 6469 | "state": "translated", | ||
| 6470 | "value": "Apps qui peuvent capturer, démarrer et arrêter le chronomètre, et lire votre agenda et votre chronomètre via des liens x-callback-url orgstar:// sans demander." | ||
| 6471 | } | ||
| 6472 | }, | ||
| 6473 | "ja": { | ||
| 6474 | "stringUnit": { | ||
| 6475 | "state": "translated", | ||
| 6476 | "value": "orgstar:// の x-callback-url リンクを通じて、確認なしでキャプチャ、クロックの開始と停止、アジェンダとクロックの読み取りができるApp。" | ||
| 6477 | } | ||
| 6478 | }, | ||
| 6479 | "pt-BR": { | ||
| 6480 | "stringUnit": { | ||
| 6481 | "state": "translated", | ||
| 6482 | "value": "Apps que podem capturar, iniciar e parar o relógio e ler sua agenda e seu relógio por links x-callback-url orgstar:// sem perguntar." | ||
| 6483 | } | ||
| 6484 | } | ||
| 6485 | } | ||
| 6486 | }, | ||
| 6283 | "Archive": { | 6487 | "Archive": { |
| 6284 | "localizations": { | 6488 | "localizations": { |
| 6285 | "de": { | 6489 | "de": { |
| @@ -15908,6 +16112,40 @@ | |||
| 15908 | } | 16112 | } |
| 15909 | } | 16113 | } |
| 15910 | }, | 16114 | }, |
| 16115 | "Don’t Allow": { | ||
| 16116 | "localizations": { | ||
| 16117 | "de": { | ||
| 16118 | "stringUnit": { | ||
| 16119 | "state": "translated", | ||
| 16120 | "value": "Nicht erlauben" | ||
| 16121 | } | ||
| 16122 | }, | ||
| 16123 | "es": { | ||
| 16124 | "stringUnit": { | ||
| 16125 | "state": "translated", | ||
| 16126 | "value": "No permitir" | ||
| 16127 | } | ||
| 16128 | }, | ||
| 16129 | "fr": { | ||
| 16130 | "stringUnit": { | ||
| 16131 | "state": "translated", | ||
| 16132 | "value": "Ne pas autoriser" | ||
| 16133 | } | ||
| 16134 | }, | ||
| 16135 | "ja": { | ||
| 16136 | "stringUnit": { | ||
| 16137 | "state": "translated", | ||
| 16138 | "value": "許可しない" | ||
| 16139 | } | ||
| 16140 | }, | ||
| 16141 | "pt-BR": { | ||
| 16142 | "stringUnit": { | ||
| 16143 | "state": "translated", | ||
| 16144 | "value": "Não Permitir" | ||
| 16145 | } | ||
| 16146 | } | ||
| 16147 | } | ||
| 16148 | }, | ||
| 15911 | "Doom's keys open the list by itself and match letters in order, as Doom's corfu does; the Emacs and Mac keys do neither unless set here. Expand Word completes the word before the caret from your files whatever is set.": { | 16149 | "Doom's keys open the list by itself and match letters in order, as Doom's corfu does; the Emacs and Mac keys do neither unless set here. Expand Word completes the word before the caret from your files whatever is set.": { |
| 15912 | "localizations": { | 16150 | "localizations": { |
| 15913 | "de": { | 16151 | "de": { |
| @@ -25035,6 +25273,40 @@ | |||
| 25035 | } | 25273 | } |
| 25036 | } | 25274 | } |
| 25037 | }, | 25275 | }, |
| 25276 | "Its links will be able to capture, clock in and out, and read your agenda and clock without asking again. %@. You can forget it in Settings.": { | ||
| 25277 | "localizations": { | ||
| 25278 | "de": { | ||
| 25279 | "stringUnit": { | ||
| 25280 | "state": "translated", | ||
| 25281 | "value": "Ihre Links können dann ohne erneute Nachfrage erfassen, die Zeiterfassung starten und stoppen und deine Agenda und Uhr lesen. %@. In den Einstellungen kannst du sie vergessen." | ||
| 25282 | } | ||
| 25283 | }, | ||
| 25284 | "es": { | ||
| 25285 | "stringUnit": { | ||
| 25286 | "state": "translated", | ||
| 25287 | "value": "Sus enlaces podrán capturar, iniciar y detener el reloj y leer tu agenda y tu reloj sin volver a preguntar. %@. Puedes olvidarla en Ajustes." | ||
| 25288 | } | ||
| 25289 | }, | ||
| 25290 | "fr": { | ||
| 25291 | "stringUnit": { | ||
| 25292 | "state": "translated", | ||
| 25293 | "value": "Ses liens pourront capturer, démarrer et arrêter le chronomètre, et lire votre agenda et votre chronomètre sans redemander. %@. Vous pouvez l’oublier dans les Réglages." | ||
| 25294 | } | ||
| 25295 | }, | ||
| 25296 | "ja": { | ||
| 25297 | "stringUnit": { | ||
| 25298 | "state": "translated", | ||
| 25299 | "value": "このAppのリンクは、再確認なしでキャプチャ、クロックの開始と停止、アジェンダとクロックの読み取りができるようになります。%@。設定で削除できます。" | ||
| 25300 | } | ||
| 25301 | }, | ||
| 25302 | "pt-BR": { | ||
| 25303 | "stringUnit": { | ||
| 25304 | "state": "translated", | ||
| 25305 | "value": "Os links dele poderão capturar, iniciar e parar o relógio e ler sua agenda e seu relógio sem perguntar de novo. %@. Você pode esquecê-lo em Ajustes." | ||
| 25306 | } | ||
| 25307 | } | ||
| 25308 | } | ||
| 25309 | }, | ||
| 25038 | "Kanban": { | 25310 | "Kanban": { |
| 25039 | "localizations": { | 25311 | "localizations": { |
| 25040 | "de": { | 25312 | "de": { |
| @@ -32027,6 +32299,40 @@ | |||
| 32027 | } | 32299 | } |
| 32028 | } | 32300 | } |
| 32029 | }, | 32301 | }, |
| 32302 | "No results are sent back": { | ||
| 32303 | "localizations": { | ||
| 32304 | "de": { | ||
| 32305 | "stringUnit": { | ||
| 32306 | "state": "translated", | ||
| 32307 | "value": "Es werden keine Ergebnisse zurückgesendet" | ||
| 32308 | } | ||
| 32309 | }, | ||
| 32310 | "es": { | ||
| 32311 | "stringUnit": { | ||
| 32312 | "state": "translated", | ||
| 32313 | "value": "No se devuelven resultados" | ||
| 32314 | } | ||
| 32315 | }, | ||
| 32316 | "fr": { | ||
| 32317 | "stringUnit": { | ||
| 32318 | "state": "translated", | ||
| 32319 | "value": "Aucun résultat n’est renvoyé" | ||
| 32320 | } | ||
| 32321 | }, | ||
| 32322 | "ja": { | ||
| 32323 | "stringUnit": { | ||
| 32324 | "state": "translated", | ||
| 32325 | "value": "結果は返されません" | ||
| 32326 | } | ||
| 32327 | }, | ||
| 32328 | "pt-BR": { | ||
| 32329 | "stringUnit": { | ||
| 32330 | "state": "translated", | ||
| 32331 | "value": "Nenhum resultado é enviado de volta" | ||
| 32332 | } | ||
| 32333 | } | ||
| 32334 | } | ||
| 32335 | }, | ||
| 32030 | "No sync conflict copies": { | 32336 | "No sync conflict copies": { |
| 32031 | "comment": "Why Resolve Sync Conflicts… is greyed in the Commands list", | 32337 | "comment": "Why Resolve Sync Conflicts… is greyed in the Commands list", |
| 32032 | "localizations": { | 32338 | "localizations": { |
| @@ -40936,6 +41242,40 @@ | |||
| 40936 | } | 41242 | } |
| 40937 | } | 41243 | } |
| 40938 | }, | 41244 | }, |
| 41245 | "Results go to %@": { | ||
| 41246 | "localizations": { | ||
| 41247 | "de": { | ||
| 41248 | "stringUnit": { | ||
| 41249 | "state": "translated", | ||
| 41250 | "value": "Ergebnisse gehen an %@" | ||
| 41251 | } | ||
| 41252 | }, | ||
| 41253 | "es": { | ||
| 41254 | "stringUnit": { | ||
| 41255 | "state": "translated", | ||
| 41256 | "value": "Los resultados van a %@" | ||
| 41257 | } | ||
| 41258 | }, | ||
| 41259 | "fr": { | ||
| 41260 | "stringUnit": { | ||
| 41261 | "state": "translated", | ||
| 41262 | "value": "Les résultats vont à %@" | ||
| 41263 | } | ||
| 41264 | }, | ||
| 41265 | "ja": { | ||
| 41266 | "stringUnit": { | ||
| 41267 | "state": "translated", | ||
| 41268 | "value": "結果の送信先: %@" | ||
| 41269 | } | ||
| 41270 | }, | ||
| 41271 | "pt-BR": { | ||
| 41272 | "stringUnit": { | ||
| 41273 | "state": "translated", | ||
| 41274 | "value": "Os resultados vão para %@" | ||
| 41275 | } | ||
| 41276 | } | ||
| 41277 | } | ||
| 41278 | }, | ||
| 40939 | "Revert to File on Disk": { | 41279 | "Revert to File on Disk": { |
| 40940 | "comment": "Command title", | 41280 | "comment": "Command title", |
| 40941 | "localizations": { | 41281 | "localizations": { |