mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-08 04:20:07 +02:00
🐛 Ensure app can handle interactions with path w/ spaces (#74)
This commit is contained in:
@ -34,7 +34,7 @@ class Application {
|
|||||||
(This will open the app if it isn't open yet.)
|
(This will open the app if it isn't open yet.)
|
||||||
*/
|
*/
|
||||||
@objc public func openDirectory(file: String) {
|
@objc public func openDirectory(file: String) {
|
||||||
return Shell.run("/usr/bin/open -a \"\(name)\" \(file)")
|
return Shell.run("/usr/bin/open -a \"\(name)\" \"\(file)\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Checks if the app is installed. */
|
/** Checks if the app is installed. */
|
||||||
|
@ -167,11 +167,12 @@ class Valet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func determineSecured(_ tld: String) {
|
public func determineSecured(_ tld: String) {
|
||||||
secured = Shell.fileExists("~/.config/valet/Certificates/\(self.name!).\(tld).key")
|
let name = self.name!.replacingOccurrences(of: " ", with: "\\ ")
|
||||||
|
secured = Shell.fileExists("~/.config/valet/Certificates/\(name).\(tld).key")
|
||||||
}
|
}
|
||||||
|
|
||||||
public func determineDriver() {
|
public func determineDriver() {
|
||||||
let driver = Shell.pipe("cd \(absolutePath!) && valet which", requiresPath: true)
|
let driver = Shell.pipe("cd \"\(absolutePath!)\" && valet which", requiresPath: true)
|
||||||
if driver.contains("This site is served by") {
|
if driver.contains("This site is served by") {
|
||||||
self.driver = driver
|
self.driver = driver
|
||||||
// TODO: Use a regular expression to retrieve the driver instead?
|
// TODO: Use a regular expression to retrieve the driver instead?
|
||||||
|
@ -171,7 +171,7 @@ class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
|
|||||||
let originalSecureStatus = selectedSite!.secured
|
let originalSecureStatus = selectedSite!.secured
|
||||||
let action = selectedSite!.secured ? "unsecure" : "secure"
|
let action = selectedSite!.secured ? "unsecure" : "secure"
|
||||||
let selectedSite = selectedSite!
|
let selectedSite = selectedSite!
|
||||||
let command = "cd \(selectedSite.absolutePath!) && sudo \(Paths.valet) \(action) && exit;"
|
let command = "cd '\(selectedSite.absolutePath!)' && sudo \(Paths.valet) \(action) && exit;"
|
||||||
|
|
||||||
waitAndExecute {
|
waitAndExecute {
|
||||||
Shell.run(command, requiresPath: true)
|
Shell.run(command, requiresPath: true)
|
||||||
@ -204,16 +204,20 @@ class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
|
|||||||
|
|
||||||
@objc public func openInBrowser() {
|
@objc public func openInBrowser() {
|
||||||
let prefix = selectedSite!.secured ? "https://" : "http://"
|
let prefix = selectedSite!.secured ? "https://" : "http://"
|
||||||
let url = "\(prefix)\(selectedSite!.name!).\(Valet.shared.config.tld)"
|
let url = URL(string: "\(prefix)\(selectedSite!.name!).\(Valet.shared.config.tld)")
|
||||||
NSWorkspace.shared.open(URL(string: url)!)
|
if url != nil {
|
||||||
|
NSWorkspace.shared.open(url!)
|
||||||
|
} else {
|
||||||
|
warnAboutInvalidFolderAction()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public func openInFinder() {
|
@objc public func openInFinder() {
|
||||||
Shell.run("open \(selectedSite!.absolutePath!)")
|
Shell.run("open '\(selectedSite!.absolutePath!)'")
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public func openInTerminal() {
|
@objc public func openInTerminal() {
|
||||||
Shell.run("open -b com.apple.terminal \(selectedSite!.absolutePath!)")
|
Shell.run("open -b com.apple.terminal '\(selectedSite!.absolutePath!)'")
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc public func unlinkSite() {
|
@objc public func unlinkSite() {
|
||||||
@ -239,6 +243,13 @@ class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func warnAboutInvalidFolderAction() {
|
||||||
|
_ = Alert.present(
|
||||||
|
messageText: "site_list.alert.invalid_folder_name".localized,
|
||||||
|
informativeText: "site_list.alert.invalid_folder_name_desc".localized
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - (Search) Text Field Delegate
|
// MARK: - (Search) Text Field Delegate
|
||||||
|
|
||||||
func searchedFor(text: String) {
|
func searchedFor(text: String) {
|
||||||
|
@ -74,6 +74,9 @@
|
|||||||
"site_list.detected_apps" = "Detected Applications";
|
"site_list.detected_apps" = "Detected Applications";
|
||||||
"site_list.system_apps" = "System Applications";
|
"site_list.system_apps" = "System Applications";
|
||||||
|
|
||||||
|
"site_list.alert.invalid_folder_name" = "Invalid folder name";
|
||||||
|
"site_list.alert.invalid_folder_name_desc" = "This folder could not be resolved to a valid URL. This is usually because there’s a space in the folder name. Please rename the folder, reload the list of sites, and try again.";
|
||||||
|
|
||||||
// EDITORS
|
// EDITORS
|
||||||
|
|
||||||
"editors.alert.try_again" = "Try Again";
|
"editors.alert.try_again" = "Try Again";
|
||||||
|
Reference in New Issue
Block a user