Skip to content

Commit

Permalink
πŸš‘ Fixed parse issue (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
techinpark authored Feb 4, 2021
1 parent 19ec642 commit 11da633
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 8 deletions.
27 changes: 22 additions & 5 deletions Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions Sources/Consts/Localized.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion Sources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSApplicationCategoryType</key>
Expand Down
1 change: 1 addition & 0 deletions Supporting FIles/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions Supporting FIles/ko.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"wellcome_user_message" = "πŸ‘‹ μ•ˆλ…•, @${username}";
"refresh" = "⏳ μƒˆλ‘œκ³ μΉ¨";
"change_username" = "βš™οΈ 아이디 λ³€κ²½";
"help" = "πŸ› 버그 μ œλ³΄ν•˜κΈ°";
"textfield_placeholder" = "Github 아이디";
"username_description" = "아이디λ₯Ό μž…λ ₯ν•΄μ£Όμ„Έμš”";
"change_username_description" = "아이디λ₯Ό λ³€κ²½ν•©λ‹ˆλ‹€";
Expand Down
6 changes: 4 additions & 2 deletions jandi.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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;
Expand All @@ -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";
Expand All @@ -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;
Expand Down

0 comments on commit 11da633

Please sign in to comment.