From e184c626f2ba524df9c4becdca30c85390f10882 Mon Sep 17 00:00:00 2001 From: Mathijs Bernson Date: Wed, 15 Apr 2026 20:52:33 +0200 Subject: [PATCH 1/2] Move search suggestions to a JSON file --- .../Features/Search/SearchSuggestion.swift | 33 ++++----------- .../Features/Search/SearchSuggestions.json5 | 41 +++++++++++++++++++ 2 files changed, 50 insertions(+), 24 deletions(-) create mode 100644 HackerTube/Features/Search/SearchSuggestions.json5 diff --git a/HackerTube/Features/Search/SearchSuggestion.swift b/HackerTube/Features/Search/SearchSuggestion.swift index 659b7c7..63ee50b 100644 --- a/HackerTube/Features/Search/SearchSuggestion.swift +++ b/HackerTube/Features/Search/SearchSuggestion.swift @@ -13,28 +13,13 @@ struct SearchSuggestion: Identifiable { } extension SearchSuggestion { - static let defaultSuggestions: [SearchSuggestion] = [ - "Freedom", "Linux", "Ethics", "Internet of Things", - "Security", "Lightning talks", "Climate", "Cryptography", "Encryption", - "Internet", "Software", "Hardware", "Cloud", "Networking", - "Privacy", "Mental health", "Accessibility", - "Artificial intelligence", "AI", "Machine learning", "Neural networks", "Language models", - "Electronics", "Robotics", "Quantum computing", "Microcontroller", - "Python", "Rust", - "Science", "Chemistry", "Math", "Physics", "Biology", "Biohacking", "DNA", "Biometrics", - "Information theory", "Communication", "GPS", - "The ultimate talk", "Radio communications", "Badge", - "Blockchain", "Cryptocurrency", - "Digital forensics", - "Drones", "Autonomous vehicles", "Smart cities", - "Cybersecurity", "Digital rights", "Ethical hacking", "Data Science", - "Internet governance", "Hacktivism", - "Open source", "Free software", - "Malware analysis", "Data protection", "Forensics", "Social engineering", - "Network security", - "Virtual reality (VR)", "Augmented reality (AR)", "Wearable tech", - "Penetration testing", "Bug bounties", "Reverse engineering", - "Dark web", "Anonymity", - "4G", "5G", "Cellular", - ].map(SearchSuggestion.init) + static let defaultSuggestions: [SearchSuggestion] = { + guard let url = Bundle.main.url(forResource: "SearchSuggestions", withExtension: "json5"), + let data = try? Data(contentsOf: url) + else { return [] } + let decoder = JSONDecoder() + decoder.allowsJSON5 = true + guard let titles = try? decoder.decode([String].self, from: data) else { return [] } + return titles.map(SearchSuggestion.init) + }() } diff --git a/HackerTube/Features/Search/SearchSuggestions.json5 b/HackerTube/Features/Search/SearchSuggestions.json5 new file mode 100644 index 0000000..95e8d15 --- /dev/null +++ b/HackerTube/Features/Search/SearchSuggestions.json5 @@ -0,0 +1,41 @@ +[ + // General tech & society + "Freedom", "Linux", "Ethics", "Internet of Things", + "Internet", "Software", "Hardware", "Cloud", "Networking", + "Open source", "Free software", + + // Security & privacy + "Security", "Cryptography", "Encryption", + "Privacy", "Anonymity", "Dark web", + "Cybersecurity", "Digital rights", "Ethical hacking", + "Malware analysis", "Data protection", "Forensics", "Digital forensics", "Social engineering", + "Network security", "Penetration testing", "Bug bounties", "Reverse engineering", + + // AI & data + "Artificial intelligence", "AI", "Machine learning", "Neural networks", "Language models", + "Data Science", + + // Hardware & electronics + "Electronics", "Robotics", "Quantum computing", "Microcontroller", + "Drones", "Autonomous vehicles", "Wearable tech", + "Virtual reality (VR)", "Augmented reality (AR)", + + // Programming languages + "Python", "Rust", + + // Science + "Science", "Chemistry", "Math", "Physics", "Biology", "Biohacking", "DNA", "Biometrics", + "Information theory", "Communication", "GPS", + + // Culture & community + "Lightning talks", "Climate", + "Mental health", "Accessibility", + "Internet governance", "Hacktivism", + "The ultimate talk", "Radio communications", "Badge", + + // Cryptocurrency + "Blockchain", "Cryptocurrency", + + // Wireless & cellular + "4G", "5G", "Cellular", +] From 22d3e2184c72e23308f8b85c6d83dbc6af44a081 Mon Sep 17 00:00:00 2001 From: Mathijs Bernson Date: Wed, 15 Apr 2026 21:16:30 +0200 Subject: [PATCH 2/2] Update search suggestions list --- .../Features/Search/SearchSuggestions.json5 | 80 +++++++++++-------- HackerTube/Features/Search/SearchView.swift | 2 +- 2 files changed, 46 insertions(+), 36 deletions(-) diff --git a/HackerTube/Features/Search/SearchSuggestions.json5 b/HackerTube/Features/Search/SearchSuggestions.json5 index 95e8d15..d1b0abb 100644 --- a/HackerTube/Features/Search/SearchSuggestions.json5 +++ b/HackerTube/Features/Search/SearchSuggestions.json5 @@ -1,41 +1,51 @@ [ - // General tech & society - "Freedom", "Linux", "Ethics", "Internet of Things", - "Internet", "Software", "Hardware", "Cloud", "Networking", - "Open source", "Free software", - - // Security & privacy - "Security", "Cryptography", "Encryption", - "Privacy", "Anonymity", "Dark web", - "Cybersecurity", "Digital rights", "Ethical hacking", - "Malware analysis", "Data protection", "Forensics", "Digital forensics", "Social engineering", - "Network security", "Penetration testing", "Bug bounties", "Reverse engineering", + // Hacking & security + "Security", "Cybersecurity", "Ethical hacking", "Penetration testing", + "Cryptography", "Encryption", "Post-quantum cryptography", + "Privacy", "Anonymity", "Data protection", "Surveillance", "Spyware", + "Malware analysis", "Digital forensics", "Social engineering", + "Reverse engineering", "Fuzzing", "Side-channel attacks", + "Certificate transparency", "Passkeys", "WebAuthn", + "Secure boot", "Bootloader", "CTF", + + // Systems & infrastructure + "Linux", "NixOS", "Containers", "Kubernetes", + "Cloud", "Self-hosting", "Internet", "Networking", + "IPv6", "BGP", "DNS", "DNSSEC", "eBPF", "VPN", + "4G", "5G", "Cellular", "LoRa", // AI & data - "Artificial intelligence", "AI", "Machine learning", "Neural networks", "Language models", + "Artificial intelligence", "AI", "Machine learning", "Neural networks", + "Language models", "Large language models", "RAG", "AI agents", "Data Science", - // Hardware & electronics - "Electronics", "Robotics", "Quantum computing", "Microcontroller", - "Drones", "Autonomous vehicles", "Wearable tech", - "Virtual reality (VR)", "Augmented reality (AR)", - - // Programming languages - "Python", "Rust", - - // Science - "Science", "Chemistry", "Math", "Physics", "Biology", "Biohacking", "DNA", "Biometrics", - "Information theory", "Communication", "GPS", - - // Culture & community - "Lightning talks", "Climate", - "Mental health", "Accessibility", - "Internet governance", "Hacktivism", - "The ultimate talk", "Radio communications", "Badge", - - // Cryptocurrency - "Blockchain", "Cryptocurrency", - - // Wireless & cellular - "4G", "5G", "Cellular", + // Hardware & making + "Electronics", "Hardware", "Microcontroller", "FPGA", "Embedded systems", + "ESP32", "Raspberry Pi", "3D printing", "Laser", + "Robotics", "Drones", "Autonomous vehicles", + "Wearable tech", "Virtual reality (VR)", "Augmented reality (AR)", + "Quantum computing", "Amateur radio", "Internet of Things", + + // Programming + "Software", "Open source", "Free software", + "Python", "Rust", "Go", "Haskell", + + // Communications & protocols + "Matrix", "Fediverse", "Signal", "Meshtastic", "Meshcore", + "End-to-end encryption", "Federated", "Decentralized", + + // Society, politics & law + "Freedom", "Ethics", "Digital sovereignty", "Digital rights", + "Internet governance", "Hacktivism", "Elections", + "Chat control", "E-voting", "Surveillance capitalism", + "Climate", "Mental health", "Accessibility", + + // Science & space + "Science", "Chemistry", "Math", "Physics", "Biology", + "Biohacking", "DNA", "Biometrics", + "Information theory", "GPS", "Satellites", + + // Community & culture + "Lightning talks", "The ultimate talk", "Badge", "Radio communications", + "OpenStreetMap", "Game development", "Godot", "Infrastructure review" ] diff --git a/HackerTube/Features/Search/SearchView.swift b/HackerTube/Features/Search/SearchView.swift index 146cae8..eee8094 100644 --- a/HackerTube/Features/Search/SearchView.swift +++ b/HackerTube/Features/Search/SearchView.swift @@ -14,7 +14,7 @@ struct SearchView: View { @State var query = "" @State var isLoading = false @State var error: Error? - @State var suggestions: [SearchSuggestion] = SearchSuggestion.defaultSuggestions.shuffled() + @State var suggestions = SearchSuggestion.defaultSuggestions.shuffled().prefix(15) @Environment(ApiService.self) var api var body: some View {