Make paths absolute and append file:// before publishing

This commit is contained in:
Emery Hemingway 2022-05-11 13:06:10 -05:00
parent 5834d8ecf4
commit 692c455f18
4 changed files with 11 additions and 4 deletions

View File

@ -7,5 +7,4 @@ There are two utilites, `xdg-open` and `uri_runner`. The former connects to a sh
The [protocol.nim](./src/protocol.nim) file is generated from the [protocol.prs](./protocol.prs) schema, a [Tupfile](https://gittup.org/tup/) file is provided to do this.
## TODO
- Pattern back-references in commands
- Fallback commands?

View File

@ -2,7 +2,7 @@
# SPDX-License-Identifier: Unlicense
import std/[asyncdispatch, os]
import preserves
from std/sequtils import map
import syndicate, syndicate/capabilities
import ./protocol
@ -17,7 +17,12 @@ proc mintCap: SturdyRef =
bootDataspace("main") do (root: Ref; turn: var Turn):
connectUnix(turn, unixSocketPath(), mintCap()) do (turn: var Turn; ds: Ref):
message(turn, ds, XdgOpen(uris: commandLineParams()))
var uris = commandLineParams().map do (param: string) -> string:
if fileExists param:
"file://" & absolutePath(param)
else:
param
message(turn, ds, XdgOpen(uris: uris))
for i in 0..7: poll(20)
# A hack to exit

View File

@ -25,5 +25,8 @@ let ?root_ds = dataspace
<action-handler "gemini://.*|file:///.*.gmi" ["/run/current-system/sw/bin/kristall" 0]>
<action-handler ".*\\.avi|.*\\.mkv|.*\\.mp4|.*\\.ogg|.*\\.opus", ["/run/current-system/sw/bin/mpv" 0]>
; filesystem paths are always prefixed with file://
<action-handler "file://(.*.pdf)" ["/run/current-system/sw/bin/mupdf" 1]>
]
]

View File

@ -1,6 +1,6 @@
# Package
version = "0.3.1"
version = "0.3.2"
author = "Emery"
description = "A better xdg-open"
license = "Unlicense"