aboutsummaryrefslogtreecommitdiff
path: root/HoloBar
diff options
context:
space:
mode:
authorFuwn <[email protected]>2025-02-07 00:46:37 -0800
committerFuwn <[email protected]>2025-02-07 00:48:26 -0800
commitf3b0018992dec16349ac6132d1ae7f35be62c1ca (patch)
treec68e062b07e88352d18ef641f8138839f84467f1 /HoloBar
downloadholobar-f3b0018992dec16349ac6132d1ae7f35be62c1ca.tar.xz
holobar-f3b0018992dec16349ac6132d1ae7f35be62c1ca.zip
feat: initial release
Diffstat (limited to 'HoloBar')
-rw-r--r--HoloBar/Assets.xcassets/AccentColor.colorset/Contents.json11
-rw-r--r--HoloBar/Assets.xcassets/AppIcon.appiconset/Contents.json58
-rw-r--r--HoloBar/Assets.xcassets/Contents.json6
-rw-r--r--HoloBar/Character.swift7
-rw-r--r--HoloBar/CharacterFetcher.swift55
-rw-r--r--HoloBar/HoloBar.entitlements12
-rw-r--r--HoloBar/HoloBarApp.swift34
-rw-r--r--HoloBar/Info.plist8
-rw-r--r--HoloBar/Preview Content/Preview Assets.xcassets/Contents.json6
9 files changed, 197 insertions, 0 deletions
diff --git a/HoloBar/Assets.xcassets/AccentColor.colorset/Contents.json b/HoloBar/Assets.xcassets/AccentColor.colorset/Contents.json
new file mode 100644
index 0000000..eb87897
--- /dev/null
+++ b/HoloBar/Assets.xcassets/AccentColor.colorset/Contents.json
@@ -0,0 +1,11 @@
+{
+ "colors" : [
+ {
+ "idiom" : "universal"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ }
+}
diff --git a/HoloBar/Assets.xcassets/AppIcon.appiconset/Contents.json b/HoloBar/Assets.xcassets/AppIcon.appiconset/Contents.json
new file mode 100644
index 0000000..3f00db4
--- /dev/null
+++ b/HoloBar/Assets.xcassets/AppIcon.appiconset/Contents.json
@@ -0,0 +1,58 @@
+{
+ "images" : [
+ {
+ "idiom" : "mac",
+ "scale" : "1x",
+ "size" : "16x16"
+ },
+ {
+ "idiom" : "mac",
+ "scale" : "2x",
+ "size" : "16x16"
+ },
+ {
+ "idiom" : "mac",
+ "scale" : "1x",
+ "size" : "32x32"
+ },
+ {
+ "idiom" : "mac",
+ "scale" : "2x",
+ "size" : "32x32"
+ },
+ {
+ "idiom" : "mac",
+ "scale" : "1x",
+ "size" : "128x128"
+ },
+ {
+ "idiom" : "mac",
+ "scale" : "2x",
+ "size" : "128x128"
+ },
+ {
+ "idiom" : "mac",
+ "scale" : "1x",
+ "size" : "256x256"
+ },
+ {
+ "idiom" : "mac",
+ "scale" : "2x",
+ "size" : "256x256"
+ },
+ {
+ "idiom" : "mac",
+ "scale" : "1x",
+ "size" : "512x512"
+ },
+ {
+ "idiom" : "mac",
+ "scale" : "2x",
+ "size" : "512x512"
+ }
+ ],
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ }
+}
diff --git a/HoloBar/Assets.xcassets/Contents.json b/HoloBar/Assets.xcassets/Contents.json
new file mode 100644
index 0000000..73c0059
--- /dev/null
+++ b/HoloBar/Assets.xcassets/Contents.json
@@ -0,0 +1,6 @@
+{
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ }
+}
diff --git a/HoloBar/Character.swift b/HoloBar/Character.swift
new file mode 100644
index 0000000..23132a2
--- /dev/null
+++ b/HoloBar/Character.swift
@@ -0,0 +1,7 @@
+import Foundation
+
+struct Character: Identifiable {
+ let id = UUID()
+ let name: String
+ let profileURL: URL
+}
diff --git a/HoloBar/CharacterFetcher.swift b/HoloBar/CharacterFetcher.swift
new file mode 100644
index 0000000..56c4a2f
--- /dev/null
+++ b/HoloBar/CharacterFetcher.swift
@@ -0,0 +1,55 @@
+import Foundation
+import SwiftSoup
+
+class CharacterFetcher: ObservableObject {
+ @Published var characters: [Character] = []
+
+ init() {
+ let today = Calendar.current.dateComponents([.month, .day], from: Date())
+
+ if let month = today.month, let day = today.day {
+ fetchCharacters(for: month, day: day)
+ }
+ }
+
+ func fetchCharacters(for month: Int, day: Int) {
+ let urlString = "https://hololist.net/birthday/?birthday_month=\(String(format: "%02d", month))&birthday_day=\(String(format: "%02d", day))"
+ guard let url = URL(string: urlString) else { return }
+
+ let task = URLSession.shared.dataTask(with: url) { data, _, error in
+ guard let data = data, error == nil,
+ let html = String(data: data, encoding: .utf8) else { return }
+
+ DispatchQueue.main.async {
+ self.characters = self.parseHTML(html: html)
+ }
+ }
+
+ task.resume()
+ }
+
+ private func parseHTML(html: String) -> [Character] {
+ var fetchedCharacters: [Character] = []
+
+ do {
+ let document = try SwiftSoup.parse(html)
+ let characterElements = try document.select("div.d-flex.mb-4.rounded")
+
+ for element in characterElements {
+ if let nameElement = try? element.select("a.line-truncate span").first(),
+ let linkElement = try? element.select("a.line-truncate").first(),
+ let profileHref = try? linkElement.attr("href"),
+ let profileURL = URL(string: profileHref)
+ {
+ let name = try nameElement.text()
+
+ fetchedCharacters.append(Character(name: name, profileURL: profileURL))
+ }
+ }
+ } catch {
+ fetchedCharacters.append(Character(name: "Error parsing HTML", profileURL: URL(string: "#")!))
+ }
+
+ return fetchedCharacters
+ }
+}
diff --git a/HoloBar/HoloBar.entitlements b/HoloBar/HoloBar.entitlements
new file mode 100644
index 0000000..625af03
--- /dev/null
+++ b/HoloBar/HoloBar.entitlements
@@ -0,0 +1,12 @@
+<?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>com.apple.security.app-sandbox</key>
+ <true/>
+ <key>com.apple.security.files.user-selected.read-only</key>
+ <true/>
+ <key>com.apple.security.network.client</key>
+ <true/>
+</dict>
+</plist>
diff --git a/HoloBar/HoloBarApp.swift b/HoloBar/HoloBarApp.swift
new file mode 100644
index 0000000..39250fd
--- /dev/null
+++ b/HoloBar/HoloBarApp.swift
@@ -0,0 +1,34 @@
+import SwiftUI
+
+@main
+struct HoloBarApp: App {
+ @StateObject private var fetcher = CharacterFetcher()
+
+ var body: some Scene {
+ MenuBarExtra {
+ if fetcher.characters.isEmpty {
+ Text("Loading …")
+ } else {
+ ForEach(fetcher.characters) { character in
+ Button(character.name) {
+ NSWorkspace.shared.open(character.profileURL)
+ }
+ }
+ }
+
+ Divider()
+ Button("Refresh") {
+ let today = Calendar.current.dateComponents([.month, .day], from: Date())
+
+ if let month = today.month, let day = today.day {
+ fetcher.fetchCharacters(for: month, day: day)
+ }
+ }
+ Button("Quit") {
+ NSApplication.shared.terminate(nil)
+ }
+ } label: {
+ Text("HL")
+ }
+ }
+}
diff --git a/HoloBar/Info.plist b/HoloBar/Info.plist
new file mode 100644
index 0000000..6f7ae58
--- /dev/null
+++ b/HoloBar/Info.plist
@@ -0,0 +1,8 @@
+<?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>LSUIElement</key>
+ <true/>
+</dict>
+</plist>
diff --git a/HoloBar/Preview Content/Preview Assets.xcassets/Contents.json b/HoloBar/Preview Content/Preview Assets.xcassets/Contents.json
new file mode 100644
index 0000000..73c0059
--- /dev/null
+++ b/HoloBar/Preview Content/Preview Assets.xcassets/Contents.json
@@ -0,0 +1,6 @@
+{
+ "info" : {
+ "author" : "xcode",
+ "version" : 1
+ }
+}