From 30e80066d426b15e2e3dc4c5ca5370a86bc8126f Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Wed, 7 Feb 2024 15:02:24 -0700 Subject: handle gopher:// urls --- iGopherBrowser/BrowserView.swift | 15 +++++++++++++-- iGopherBrowser/Info.plist | 15 +++++++++++++-- iGopherBrowser/iGopherBrowserApp.swift | 2 +- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/iGopherBrowser/BrowserView.swift b/iGopherBrowser/BrowserView.swift index f745fc8..29c28d0 100644 --- a/iGopherBrowser/BrowserView.swift +++ b/iGopherBrowser/BrowserView.swift @@ -369,11 +369,18 @@ struct BrowserView: View { .autocapitalization(.none) #endif .padding(10) - Spacer() } //.background(Color.white) .cornerRadius(30) - + if (shareThroughProxy) { + ShareLink(item: URL(string: "https://gopher.navan.dev/\(url)")!) { + Label("Share", systemImage: "square.and.arrow.up").labelStyle(.iconOnly) + } + } else { + ShareLink(item: URL(string: "gopher://\(url)")!) { + Label("Share", systemImage: "square.and.arrow.up").labelStyle(.iconOnly) + } + } Button( "Go", action: { @@ -395,6 +402,10 @@ struct BrowserView: View { performGopherRequest(host: node.host, port: node.port, selector: node.selector) } } + .onOpenURL { gopherURL in + self.url = gopherURL.absoluteString + performGopherRequest() + } .sheet( isPresented: $showPreferences, onDismiss: { diff --git a/iGopherBrowser/Info.plist b/iGopherBrowser/Info.plist index 8608c07..3f9c0e7 100644 --- a/iGopherBrowser/Info.plist +++ b/iGopherBrowser/Info.plist @@ -2,7 +2,18 @@ - LSApplicationCategoryType - public.app-category.productivity + CFBundleURLTypes + + + CFBundleTypeRole + Viewer + CFBundleURLName + gopher + CFBundleURLSchemes + + gopher + + + diff --git a/iGopherBrowser/iGopherBrowserApp.swift b/iGopherBrowser/iGopherBrowserApp.swift index e18d6f5..5698e82 100644 --- a/iGopherBrowser/iGopherBrowserApp.swift +++ b/iGopherBrowser/iGopherBrowserApp.swift @@ -12,7 +12,7 @@ import TelemetryClient struct iGopherBrowserApp: App { var body: some Scene { WindowGroup { - ContentView() + ContentView() } .commands { #if os(macOS) -- cgit v1.2.3