From 0d61e05e98f6f020722ee4d43f024c1da348d2a9 Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Thu, 14 May 2026 12:41:55 -0500 Subject: feat: add Safari extension for sourcehut deep links --- Hutch/Views/Lookup/LookupView.swift | 2 + Hutch/Views/Settings/SafariExtensionHelpView.swift | 59 ++++++++++++++++++++++ Hutch/Views/Settings/SettingsView.swift | 17 +++++++ 3 files changed, 78 insertions(+) create mode 100644 Hutch/Views/Settings/SafariExtensionHelpView.swift (limited to 'Hutch/Views') diff --git a/Hutch/Views/Lookup/LookupView.swift b/Hutch/Views/Lookup/LookupView.swift index f464da5..55c421b 100644 --- a/Hutch/Views/Lookup/LookupView.swift +++ b/Hutch/Views/Lookup/LookupView.swift @@ -443,6 +443,8 @@ struct LookupView: View { SettingsView() case .about: AboutView() + case .userProfile(let owner): + UserProfileDeepLinkView(owner: owner) case .mailingList(let mailingList): MailingListDetailView(mailingList: mailingList) case .thread(let thread): diff --git a/Hutch/Views/Settings/SafariExtensionHelpView.swift b/Hutch/Views/Settings/SafariExtensionHelpView.swift new file mode 100644 index 0000000..5da1a3d --- /dev/null +++ b/Hutch/Views/Settings/SafariExtensionHelpView.swift @@ -0,0 +1,59 @@ +import SwiftUI + +struct SafariExtensionHelpView: View { + private let supportedServices = [ + "git.sr.ht", + "hg.sr.ht", + "todo.sr.ht", + "builds.sr.ht", + "lists.sr.ht", + "meta.sr.ht", + "sr.ht", + ] + + var body: some View { + Form { + Section { + Text("Enable Open in Hutch from Settings > Apps > Safari > Extensions, then turn on Hutch and allow it for SourceHut websites.") + .font(.subheadline) + .foregroundStyle(.secondary) + .themedRow() + } header: { + Text("Enable") + } + + Section("Supported Services") { + ForEach(supportedServices, id: \.self) { service in + Label(service, systemImage: "checkmark.circle") + .themedRow() + } + } + + Section { + Text("The extension adds a Safari action named Open in Hutch. It converts supported SourceHut web URLs into Hutch deep links, then opens the matching screen in the app.") + .font(.subheadline) + .foregroundStyle(.secondary) + .themedRow() + + Text("This is separate from Universal Links. Hutch cannot claim sr.ht links system-wide because those domains are owned by SourceHut and would need Apple App Site Association files hosted there.") + .font(.subheadline) + .foregroundStyle(.secondary) + .themedRow() + } header: { + Text("How It Works") + } + + Section { + Text("Pages are never redirected automatically by default. The optional in-page Open in Hutch banner is off unless the extension setting is explicitly enabled.") + .font(.subheadline) + .foregroundStyle(.secondary) + .themedRow() + } header: { + Text("Privacy") + } + } + .themedList() + .navigationTitle("Safari Extension") + .navigationBarTitleDisplayMode(.inline) + } +} diff --git a/Hutch/Views/Settings/SettingsView.swift b/Hutch/Views/Settings/SettingsView.swift index f307429..0dd4319 100644 --- a/Hutch/Views/Settings/SettingsView.swift +++ b/Hutch/Views/Settings/SettingsView.swift @@ -15,6 +15,7 @@ struct SettingsView: View { Form { appearanceSection() behaviorSection() + safariExtensionSection() authenticationSection() } .themedList() @@ -55,6 +56,22 @@ struct SettingsView: View { } } + @ViewBuilder + private func safariExtensionSection() -> some View { + Section { + NavigationLink { + SafariExtensionHelpView() + } label: { + Label("Safari Extension", systemImage: "safari") + } + .themedRow() + } header: { + Text("Browser") + } footer: { + Text("Open supported SourceHut pages in Hutch from Safari without claiming sr.ht links system-wide.") + } + } + @ViewBuilder private func appearanceSection() -> some View { Section { -- cgit v1.2.3