commit e4c33ddc98a8865f21ed858a7bf7281d28e58755
parent ef2cbf41bcd7a3d6ac427f9f1b19084d528a00a4
Author: FIGBERT <figbert@figbert.com>
Date: Tue, 6 Sep 2022 14:03:04 -0700
Add support for handling gemini:// urls
This enables the fundamental ability to click on links and open them
in the browser.
It further allows for gemini:// urls encountered in other apps - like
Safari, for example - to be opened in a Gemenon window.
Diffstat:
3 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/Gemenon.xcodeproj/project.pbxproj b/Gemenon.xcodeproj/project.pbxproj
@@ -18,6 +18,7 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
+ 3A1FABC828C6F91D00950AF8 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
3AB5B66B28BF23FF00F0C1A5 /* GemenonApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GemenonApp.swift; sourceTree = "<group>"; };
3AB5B66C28BF23FF00F0C1A5 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
3AB5B66D28BF23FF00F0C1A5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
@@ -77,6 +78,7 @@
3AB5B67928BF23FF00F0C1A5 /* macOS */ = {
isa = PBXGroup;
children = (
+ 3A1FABC828C6F91D00950AF8 /* Info.plist */,
3AB5B67A28BF23FF00F0C1A5 /* macOS.entitlements */,
);
path = macOS;
@@ -388,6 +390,7 @@
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
+ INFOPLIST_FILE = "macOS/Info.plist";
INFOPLIST_KEY_NSHumanReadableCopyright = "";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
@@ -416,6 +419,7 @@
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
+ INFOPLIST_FILE = "macOS/Info.plist";
INFOPLIST_KEY_NSHumanReadableCopyright = "";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
diff --git a/Shared/ContentView.swift b/Shared/ContentView.swift
@@ -69,6 +69,12 @@ struct ContentView: View {
}
}
}
+ .handlesExternalEvents(preferring: ["gemini://*"], allowing: ["*"])
+ .onOpenURL(perform: { url in
+ Task {
+ response = try! await engine.request(url)
+ }
+ })
}
func renderGemtext() -> some View {
diff --git a/macOS/Info.plist b/macOS/Info.plist
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleURLTypes</key>
+ <array>
+ <dict>
+ <key>CFBundleTypeRole</key>
+ <string>Viewer</string>
+ <key>CFBundleURLName</key>
+ <string>com.figbertind.Gemenon</string>
+ <key>CFBundleURLSchemes</key>
+ <array>
+ <string>gemini</string>
+ </array>
+ </dict>
+ </array>
+</dict>
+</plist>