diff --git a/.gitignore b/.gitignore index 1bc0c924..89f06c5f 100644 --- a/.gitignore +++ b/.gitignore @@ -74,6 +74,9 @@ Libraries # ignore xcode project files, they are now generated by XcodeGen *.xcodeproj +# ignore the lock file, it is not working the same way as lock files in other tools +Brewfile.lock.json + # this is CI specific Brewfile_CI Brewfile_CI.lock.json \ No newline at end of file diff --git a/App/App_macOS.swift b/App/App_macOS.swift index 56559c34..a6041241 100644 --- a/App/App_macOS.swift +++ b/App/App_macOS.swift @@ -166,6 +166,12 @@ struct RootView: View { navigation.currentItem = .reading browser.load(url: url) } + .onReceive(NotificationCenter.default.publisher(for: NSWindow.willCloseNotification), perform: { output in + guard let window = output.object as? NSWindow else { return } + if window.isKeyWindow && window.isMainWindow { // if this is the very last window, close the app + NSApp.terminate(nil) + } + }) .onReceive(appTerminates) { _ in browser.persistAllTabIdsFromWindows() }.task { diff --git a/Brewfile.lock.json b/Brewfile.lock.json deleted file mode 100644 index c29e672d..00000000 --- a/Brewfile.lock.json +++ /dev/null @@ -1,145 +0,0 @@ -{ - "entries": { - "brew": { - "pre-commit": { - "version": "3.6.1", - "bottle": { - "rebuild": 0, - "root_url": "https://ghcr.io/v2/homebrew/core", - "files": { - "arm64_sonoma": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/pre-commit/blobs/sha256:4e484a05a5bd384af65102fe822ce5376b77f638a5d48e774e5bf890a5ce1426", - "sha256": "4e484a05a5bd384af65102fe822ce5376b77f638a5d48e774e5bf890a5ce1426" - }, - "arm64_ventura": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/pre-commit/blobs/sha256:d291393de358a7d20a58f050a74cc7d53bfda3e1f5627fbdee8738df8cfd599c", - "sha256": "d291393de358a7d20a58f050a74cc7d53bfda3e1f5627fbdee8738df8cfd599c" - }, - "arm64_monterey": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/pre-commit/blobs/sha256:8a424636b2204c8956ba089dcecc0ebc8bccaa8cdb3e61e34a7c6c1bd32f236a", - "sha256": "8a424636b2204c8956ba089dcecc0ebc8bccaa8cdb3e61e34a7c6c1bd32f236a" - }, - "sonoma": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/pre-commit/blobs/sha256:a2525c44b30d94e9f5e517aca09835c2a3c94930cc46ea09a761b8909c38ae55", - "sha256": "a2525c44b30d94e9f5e517aca09835c2a3c94930cc46ea09a761b8909c38ae55" - }, - "ventura": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/pre-commit/blobs/sha256:9a2a9c8f2708d500cc8b1f08fdb1d19f09722028f4fc0d0d516b055697073e0c", - "sha256": "9a2a9c8f2708d500cc8b1f08fdb1d19f09722028f4fc0d0d516b055697073e0c" - }, - "monterey": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/pre-commit/blobs/sha256:d87f9614307145e6a5572c37d7c86ad6062f7da75e13b3b98229ce2787524509", - "sha256": "d87f9614307145e6a5572c37d7c86ad6062f7da75e13b3b98229ce2787524509" - }, - "x86_64_linux": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/pre-commit/blobs/sha256:2febc58717f13ffbd9295870b4567ce97c453466871674d16181d7431b235e5d", - "sha256": "2febc58717f13ffbd9295870b4567ce97c453466871674d16181d7431b235e5d" - } - } - } - }, - "xcodegen": { - "version": "2.38.0", - "bottle": { - "rebuild": 0, - "root_url": "https://ghcr.io/v2/homebrew/core", - "files": { - "arm64_sonoma": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/xcodegen/blobs/sha256:422fb8dfbc7e2ed59125d22b4687bb54a1ab3f0ddef044a3875b624121f9be47", - "sha256": "422fb8dfbc7e2ed59125d22b4687bb54a1ab3f0ddef044a3875b624121f9be47" - }, - "arm64_ventura": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/xcodegen/blobs/sha256:5b2d9dfdf8bc9912ecef48ecc4a03cfb4ba68f35f03c4ab4fc9e893b077f8796", - "sha256": "5b2d9dfdf8bc9912ecef48ecc4a03cfb4ba68f35f03c4ab4fc9e893b077f8796" - }, - "arm64_monterey": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/xcodegen/blobs/sha256:7a239feca86c46f78ae91d631858d957cb2e7e63ea7230b30f3d618097774bff", - "sha256": "7a239feca86c46f78ae91d631858d957cb2e7e63ea7230b30f3d618097774bff" - }, - "sonoma": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/xcodegen/blobs/sha256:346164300a7e835f8516c70b25793702bab2437d7e9fb606b5394ab757dab4f5", - "sha256": "346164300a7e835f8516c70b25793702bab2437d7e9fb606b5394ab757dab4f5" - }, - "ventura": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/xcodegen/blobs/sha256:2bca799f6fee1e679a3f826a9a977449a23f81f02896b22a525056f6cd4a07dd", - "sha256": "2bca799f6fee1e679a3f826a9a977449a23f81f02896b22a525056f6cd4a07dd" - }, - "monterey": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/xcodegen/blobs/sha256:3e306a4b9ad078c77b61d93090c224304c7dac35ca119808db87792edb983be8", - "sha256": "3e306a4b9ad078c77b61d93090c224304c7dac35ca119808db87792edb983be8" - } - } - } - }, - "curl": { - "version": "8.6.0", - "bottle": { - "rebuild": 0, - "root_url": "https://ghcr.io/v2/homebrew/core", - "files": { - "arm64_sonoma": { - "cellar": ":any", - "url": "https://ghcr.io/v2/homebrew/core/curl/blobs/sha256:3231814e0bdbb794f57db7193edc33d930f29cd784fd41af25d41bf03b04d770", - "sha256": "3231814e0bdbb794f57db7193edc33d930f29cd784fd41af25d41bf03b04d770" - }, - "arm64_ventura": { - "cellar": ":any", - "url": "https://ghcr.io/v2/homebrew/core/curl/blobs/sha256:188e7ef7c17bfd3a15378acf1794873e4a8e6a35cc30d7cc4839cd7be8dbf022", - "sha256": "188e7ef7c17bfd3a15378acf1794873e4a8e6a35cc30d7cc4839cd7be8dbf022" - }, - "arm64_monterey": { - "cellar": ":any", - "url": "https://ghcr.io/v2/homebrew/core/curl/blobs/sha256:b8689b34b4ffc9ef5eeb68754063c68f393a91e8a0d374538ba648e516bb8676", - "sha256": "b8689b34b4ffc9ef5eeb68754063c68f393a91e8a0d374538ba648e516bb8676" - }, - "sonoma": { - "cellar": ":any", - "url": "https://ghcr.io/v2/homebrew/core/curl/blobs/sha256:e0882b7691661774c03a78fcbb7e0b61f0f2d0a53f9458339566d057d4087c77", - "sha256": "e0882b7691661774c03a78fcbb7e0b61f0f2d0a53f9458339566d057d4087c77" - }, - "ventura": { - "cellar": ":any", - "url": "https://ghcr.io/v2/homebrew/core/curl/blobs/sha256:833eccc950937eed12e9530dcbc7d5a9f0f7d2c0ad83417de34713622cec5709", - "sha256": "833eccc950937eed12e9530dcbc7d5a9f0f7d2c0ad83417de34713622cec5709" - }, - "monterey": { - "cellar": ":any", - "url": "https://ghcr.io/v2/homebrew/core/curl/blobs/sha256:8bbe6cb934786eb681f19df52584a4e74b5ace691deb620d3ca08a93b223a750", - "sha256": "8bbe6cb934786eb681f19df52584a4e74b5ace691deb620d3ca08a93b223a750" - }, - "x86_64_linux": { - "cellar": ":any_skip_relocation", - "url": "https://ghcr.io/v2/homebrew/core/curl/blobs/sha256:960084d21f9d235b36a926469dfe48a9e198b44a5e787da8479ccb0467078ccc", - "sha256": "960084d21f9d235b36a926469dfe48a9e198b44a5e787da8479ccb0467078ccc" - } - } - } - } - } - }, - "system": { - "macos": { - "ventura": { - "HOMEBREW_VERSION": "4.2.7", - "HOMEBREW_PREFIX": "/opt/homebrew", - "Homebrew/homebrew-core": "api", - "CLT": "15.1.0.0.1.1700200546", - "Xcode": "15.1", - "macOS": "13.6.4" - } - } - } -} diff --git a/Model/Entities/Entities.swift b/Model/Entities/Entities.swift index 1dc04695..f996504b 100644 --- a/Model/Entities/Entities.swift +++ b/Model/Entities/Entities.swift @@ -146,6 +146,14 @@ struct URLContent { let start: UInt let end: UInt let size: UInt + + var httpContentType: String { + if mime == "text/plain" { + return "text/plain;charset=UTf-8" + } else { + return mime + } + } } final class ZimFile: NSManagedObject, Identifiable { diff --git a/Model/Utilities/WebKitHandler.swift b/Model/Utilities/WebKitHandler.swift index b28c57e2..a431c8b6 100644 --- a/Model/Utilities/WebKitHandler.swift +++ b/Model/Utilities/WebKitHandler.swift @@ -76,7 +76,7 @@ final class KiwixURLSchemeHandler: NSObject, WKURLSchemeHandler { } private func sendHTTP200Response(_ urlSchemeTask: WKURLSchemeTask, url: URL, content: URLContent) { - let headers = ["Content-Type": content.mime, "Content-Length": "\(content.size)"] + let headers = ["Content-Type": content.httpContentType, "Content-Length": "\(content.size)"] if let response = HTTPURLResponse(url: url, statusCode: 200, httpVersion: "HTTP/1.1", headerFields: headers) { guard isStartedFor(urlSchemeTask.hash) else { return } urlSchemeTask.didReceive(response) diff --git a/Support/zh-hant.lproj/Localizable.strings b/Support/zh-hant.lproj/Localizable.strings index 2df70183..525ffec2 100644 --- a/Support/zh-hant.lproj/Localizable.strings +++ b/Support/zh-hant.lproj/Localizable.strings @@ -1,6 +1,7 @@ // Messages for Traditional Chinese (中文(繁體)) // Exported from translatewiki.net // Author: Kly +// Author: 列维劳德 "library_refresh_error.retrieve.description" = "檢索圖書館資料時發生錯誤。"; "library_refresh_error.parse.description" = "解析圖書館資料時發生錯誤。"; @@ -58,25 +59,20 @@ "library_refresh_time.never" = "永不"; "zim_file_cell_article_count_suffix" = "條目"; "zim_file_missing_indicator.help" = "遺失 Zim 檔案。"; -// Fuzzy -"library.zim_file_details.side_panel.message" = "選擇一個 zim 檔案以查看詳細資訊"; +"library.zim_file_details.side_panel.message" = "選擇一個 ZIM 檔案以查看詳細資訊"; "library.zim_file_context.main_page.label" = "主頁"; "library.zim_file_context.random.label" = "隨機頁面"; "library.zim_file_context.copy_url" = "複製 URL"; "library.zim_file_context.copy_id" = "複製 ID"; -// Fuzzy -"zim_file_opened.overlay.no-opened.message" = "沒有開啟的 zim 檔案"; +"zim_file_opened.overlay.no-opened.message" = "沒有開啟的 ZIM 檔案"; "zim_file_opened.toolbar.show_sidebar.label" = "顯示側邊欄"; "zim_file_opened.toolbar.open.title" = "開啟…"; -// Fuzzy -"zim_file_opened.toolbar.open.help" = "開啟一個 zim 檔案"; +"zim_file_opened.toolbar.open.help" = "開啟一個 ZIM 檔案"; "zim_file_category.title" = "分類"; -// Fuzzy -"zim_file_category.section.empty.message" = "此分類下沒有 zim 檔案。"; +"zim_file_category.section.empty.message" = "此分類下沒有 ZIM 檔案。"; "zim_file_downloads.overlay.empty.message" = "沒有下載任務"; "zim_file_downloads.toolbar.show_sidebar.label" = "顯示側邊欄"; -// Fuzzy -"zim_file_new_overlay.empty" = "沒有新的 zim 檔案"; +"zim_file_new_overlay.empty" = "沒有新的 ZIM 檔案"; "zim_file_new_button_refresh" = "重整"; "zim_file.list.name.text" = "名稱"; "zim_file.list.description.text" = "描述"; @@ -87,19 +83,15 @@ "zim_file.action.reveal_in_finder.title" = "在 Finder 中顯示"; "zim_file.action.toggle_cellular" = "使用蜂巢式網路下載"; "zim_file.action.unlink.title" = "取消連結"; -// Fuzzy -"zim_file.action.unlink.message" = "連結到該 zim 檔案的所有加入到書籤的條目都將被刪除,不過原始檔案會保留於原處。"; +"zim_file.action.unlink.message" = "連結到該 ZIM 檔案的所有加入到書籤的條目都將被刪除,不過原始檔案會保留於原處。"; "zim_file.action.unlink.button.title" = "取消連結"; "zim_file.action.delete.title" = "刪除"; -// Fuzzy -"zim_file.action.delete.message" = "Zim 檔案與連結到該檔案的所有加入到書籤的條目都將被刪除。"; +"zim_file.action.delete.message" = "ZIM 檔案與連結到該檔案的所有加入到書籤的條目都將被刪除。"; "zim_file.action.delete.button.title" = "刪除"; "zim_file.action.download.title" = "下載"; "zim_file.action.download.warning.title" = "空間警告"; -// Fuzzy -"zim_file.action.download.warning.message" = "您的設備上可能沒有足夠的空間來容納此 zim 檔案。"; -// Fuzzy -"zim_file.action.download.warning.message1" = "下載 zim 檔案後,剩餘空間會少於 1GB。"; +"zim_file.action.download.warning.message" = "您的裝置可能沒有足夠的空間儲存此 ZIM 檔。"; +"zim_file.action.download.warning.message1" = "下載 ZIM 檔案後,剩餘空間會少於 1GB。"; "zim_file.action.download.button.anyway" = "無論如何都要下載"; "zim_file.base_info.attribute.language" = "語言"; "zim_file.base_info.attribute.category" = "分類"; @@ -141,8 +133,7 @@ "catalog_settings.auto_refresh.toggle" = "自動重整"; "catalog_settings.header.text" = "目錄"; "catalog_settings.footer.text" = "啟用後,在圖書館目錄過期時會自動重整。"; -// Fuzzy -"backup_settings.toggle.title" = "在備份中包含 zim 檔案"; +"backup_settings.toggle.title" = "在備份中包含 ZIM 檔案"; "backup_settings.header.text" = "備份"; "backup_settings.footer.text" = "不適用於在此開啟的檔案。"; "settings.miscellaneous.title" = "雜項"; @@ -174,8 +165,7 @@ "bookmark.overlay.empty.title" = "沒有書籤"; "bookmark.toolbar.show_sidebar.label" = "顯示側邊欄"; "browser_tab.toolbar.show_sidebar.label" = "顯示側邊欄"; -// Fuzzy -"search_result.zimfile.empty.message" = "沒有開啟的 zim 檔案"; +"search_result.zimfile.empty.message" = "沒有開啟的 ZIM 檔案"; "search_result.zimfile.no_result.message" = "沒有結果"; "search_result.sidebar.button.remove" = "移除"; "search_result.header.text" = "最近搜尋"; diff --git a/Views/ViewModifiers/ExternalLinkHandler.swift b/Views/ViewModifiers/ExternalLinkHandler.swift index 0d48b5cf..99c3208f 100644 --- a/Views/ViewModifiers/ExternalLinkHandler.swift +++ b/Views/ViewModifiers/ExternalLinkHandler.swift @@ -46,8 +46,11 @@ struct ExternalLinkHandler: ViewModifier { if case .ask(let url) = alert { Button("external_link_handler.alert.button.load.link".localized) { load(url: url) + externalURL = nil // important to nil out, so the same link tapped will trigger onChange again + } + Button("common.button.cancel".localized, role: .cancel) { + externalURL = nil // important to nil out, so the same link tapped will trigger onChange again } - Button("common.button.cancel".localized, role: .cancel) { } } } message: { alert in switch alert { diff --git a/project.yml b/project.yml index 89281f3e..ee578fb9 100644 --- a/project.yml +++ b/project.yml @@ -65,7 +65,6 @@ targetTemplates: path: Support/Kiwix.entitlements properties: com.apple.security.app-sandbox: true - com.apple.security.files.downloads.read-write: true com.apple.security.files.user-selected.read-only: true com.apple.security.network.client: true dependencies: @@ -92,6 +91,9 @@ targets: Kiwix: templates: - ApplicationTemplate + entitlements: + properties: + com.apple.security.files.downloads.read-write: true settings: base: MARKETING_VERSION: "3.3.0"