diff options
author | Navan Chauhan <navanchauhan@gmail.com> | 2024-02-07 15:02:24 -0700 |
---|---|---|
committer | Navan Chauhan <navanchauhan@gmail.com> | 2024-02-07 15:02:24 -0700 |
commit | 30e80066d426b15e2e3dc4c5ca5370a86bc8126f (patch) | |
tree | a2925d47b56600f7f52a7f5fb4cd7d2e05e3e4e8 | |
parent | a22ff62c83717fb09285dbc66441b8b1c1583c68 (diff) |
handle gopher:// urls
-rw-r--r-- | iGopherBrowser/BrowserView.swift | 15 | ||||
-rw-r--r-- | iGopherBrowser/Info.plist | 15 | ||||
-rw-r--r-- | 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 @@ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> - <key>LSApplicationCategoryType</key> - <string>public.app-category.productivity</string> + <key>CFBundleURLTypes</key> + <array> + <dict> + <key>CFBundleTypeRole</key> + <string>Viewer</string> + <key>CFBundleURLName</key> + <string>gopher</string> + <key>CFBundleURLSchemes</key> + <array> + <string>gopher</string> + </array> + </dict> + </array> </dict> </plist> 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) |