From 11da633ef2bb5eb74ea661d2a95504ef1d7d23bb Mon Sep 17 00:00:00 2001 From: Fernando Date: Thu, 4 Feb 2021 04:54:15 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=91=20Fixed=20parse=20issue=20(#2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/AppDelegate.swift | 27 +++++++++++++++---- Sources/Consts/Localized.swift | 1 + Sources/Info.plist | 2 +- Supporting FIles/en.lproj/Localizable.strings | 1 + Supporting FIles/ko.lproj/Localizable.strings | 1 + jandi.xcodeproj/project.pbxproj | 6 +++-- 6 files changed, 30 insertions(+), 8 deletions(-) diff --git a/Sources/AppDelegate.swift b/Sources/AppDelegate.swift index e2ef161..c488d6e 100644 --- a/Sources/AppDelegate.swift +++ b/Sources/AppDelegate.swift @@ -38,11 +38,18 @@ class AppDelegate: NSObject, NSApplicationDelegate { $0.keyEquivalent = "u" $0.tag = 3 } + + private let helpMenuItem = NSMenuItem().then { + $0.title = Localized.help + $0.action = #selector(onHelpClick) + $0.keyEquivalent = "" + $0.tag = 4 + } private let quitMenuItem = NSMenuItem().then { $0.title = Localized.quit $0.action = #selector(onQuitClick) - $0.tag = 4 + $0.tag = 5 $0.keyEquivalent = "q" } @@ -71,6 +78,8 @@ class AppDelegate: NSObject, NSApplicationDelegate { menu.addItem(.separator()) menu.addItem(userMenuItem) menu.addItem(.separator()) + menu.addItem(helpMenuItem) + menu.addItem(.separator()) menu.addItem(refreshMenuItem) menu.addItem(changeUserMenuItem) menu.addItem(quitMenuItem) @@ -140,6 +149,12 @@ class AppDelegate: NSObject, NSApplicationDelegate { @objc func onChangeUsernameClick() { showChangeUsernameAlert() } + + @objc func onHelpClick() { + let url = URL(string: "https://github.com/techinpark/Jandi")! + NSWorkspace.shared.open(url) + } + private func changeUsername(withUsername username: String) { UserDefaults.standard.setValue(username, forKey: Consts.usernameDefaultKey) @@ -221,11 +236,13 @@ class AppDelegate: NSObject, NSApplicationDelegate { private func parseHTML(html: String) { do { - let doc = try SwiftSoup.parse(html) - let days = try doc.getElementsByTag(ParseKeys.rect) - let weekend = days.suffix(Consts.fetchCount) - guard let today = days.last() else { return } + let doc: Document = try SwiftSoup.parse(html) + let rects: Elements = try doc.getElementsByTag(ParseKeys.rect) + let days: [Element] = rects.array().filter { $0.hasAttr(ParseKeys.date) } + let weekend = days.suffix(Consts.fetchCount) + guard let today = days.last else { return } + _ = weekend.map { guard let attr = $0.getAttributes() else { return } let date: String = attr.get(key: ParseKeys.date) diff --git a/Sources/Consts/Localized.swift b/Sources/Consts/Localized.swift index 0c93582..3f7e087 100644 --- a/Sources/Consts/Localized.swift +++ b/Sources/Consts/Localized.swift @@ -12,6 +12,7 @@ enum Localized { static let hello = NSLocalizedString("wellcome_user_message", comment: "πŸ‘‹ Hi, @${username}") static let refresh = NSLocalizedString("refresh", comment: "refresh") static let changeUsername = NSLocalizedString("change_username", comment: "Change username") + static let help = NSLocalizedString("help", comment: "help") static let textFieldPlaceholder = NSLocalizedString("textfield_placeholder", comment: "Github username") static let setUsernameDescription = NSLocalizedString("username_description", comment: "Set username") static let changeUsernameDescription = NSLocalizedString("change_username_description", comment: "Change username") diff --git a/Sources/Info.plist b/Sources/Info.plist index 3ac7a49..03f496f 100644 --- a/Sources/Info.plist +++ b/Sources/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType $(PRODUCT_BUNDLE_PACKAGE_TYPE) CFBundleShortVersionString - 1.0 + $(MARKETING_VERSION) CFBundleVersion $(CURRENT_PROJECT_VERSION) LSApplicationCategoryType diff --git a/Supporting FIles/en.lproj/Localizable.strings b/Supporting FIles/en.lproj/Localizable.strings index a8d915b..edeb53e 100644 --- a/Supporting FIles/en.lproj/Localizable.strings +++ b/Supporting FIles/en.lproj/Localizable.strings @@ -9,6 +9,7 @@ "wellcome_user_message" = "πŸ‘‹ Hello, @${username}"; "refresh" = "⏳ Refresh"; "change_username" = "βš™οΈ Change username"; +"help" = "πŸ› Bug Report"; "textfield_placeholder" = "GitHub username"; "username_description" = "Set username"; "change_username_description" = "Change username"; diff --git a/Supporting FIles/ko.lproj/Localizable.strings b/Supporting FIles/ko.lproj/Localizable.strings index 0f4f03f..376d1e9 100644 --- a/Supporting FIles/ko.lproj/Localizable.strings +++ b/Supporting FIles/ko.lproj/Localizable.strings @@ -9,6 +9,7 @@ "wellcome_user_message" = "πŸ‘‹ μ•ˆλ…•, @${username}"; "refresh" = "⏳ μƒˆλ‘œκ³ μΉ¨"; "change_username" = "βš™οΈ 아이디 λ³€κ²½"; +"help" = "πŸ› 버그 μ œλ³΄ν•˜κΈ°"; "textfield_placeholder" = "Github 아이디"; "username_description" = "아이디λ₯Ό μž…λ ₯ν•΄μ£Όμ„Έμš”"; "change_username_description" = "아이디λ₯Ό λ³€κ²½ν•©λ‹ˆλ‹€"; diff --git a/jandi.xcodeproj/project.pbxproj b/jandi.xcodeproj/project.pbxproj index 5a46025..2035a47 100644 --- a/jandi.xcodeproj/project.pbxproj +++ b/jandi.xcodeproj/project.pbxproj @@ -353,7 +353,7 @@ CODE_SIGN_ENTITLEMENTS = "$(SRCROOT)/Sources/jandi.entitlements"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 4; + CURRENT_PROJECT_VERSION = 6; DEVELOPMENT_TEAM = U6GQL8JQMT; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = "$(SRCROOT)/Sources/Info.plist"; @@ -362,6 +362,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.12; + MARKETING_VERSION = 1.2; PRODUCT_BUNDLE_IDENTIFIER = com.tmsae.jandi; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; @@ -377,7 +378,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 4; + CURRENT_PROJECT_VERSION = 6; DEVELOPMENT_TEAM = U6GQL8JQMT; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = "$(SRCROOT)/Sources/Info.plist"; @@ -386,6 +387,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.12; + MARKETING_VERSION = 1.2; PRODUCT_BUNDLE_IDENTIFIER = com.tmsae.jandi; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0;