Skip to content

Commit ef5a2ea

Browse files
committed
Simplify how URLs are opened with a browser
1 parent fdfaade commit ef5a2ea

File tree

7 files changed

+7
-34
lines changed

7 files changed

+7
-34
lines changed

engine/config.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ func New(versionString, description string) (*Config, error) {
199199
// Mutex for rendering Pongo2 pages
200200
pongomutex: &sync.RWMutex{},
201201

202-
// Program for opening URLs
203-
defaultOpenExecutable: platformdep.DefaultOpenExecutable,
202+
// Program for opening URLs, keep empty for using the default in url.go
203+
defaultOpenExecutable: "",
204204

205205
// General information about Algernon
206206
versionString: versionString,

engine/flags.go

-5
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,6 @@ func (ac *Config) handleFlags(serverTempDir string) {
352352
}
353353
}
354354

355-
// Use the default openExecutable if none is set
356-
if ac.openURLAfterServing && ac.openExecutable == "" {
357-
ac.openExecutable = ac.defaultOpenExecutable
358-
}
359-
360355
// Add the serverConfScript to the list of configuration scripts to be read and executed
361356
if ac.serverConfScript != "" && ac.serverConfScript != os.DevNull {
362357
ac.serverConfigurationFilenames = append(ac.serverConfigurationFilenames, ac.serverConfScript, filepath.Join(ac.serverDirOrFilename, ac.serverConfScript))

engine/help.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,8 @@ Available flags:
573573
Quits after the file has been served once.
574574
("-m" is equivalent to "-q -o -z").
575575
-n, --nobanner Don't display a colorful banner at start.
576-
-o, --open=EXECUTABLE Open the served URL in a browser or with the given
577-
executable (uses "` + ac.defaultOpenExecutable + `" by default).
576+
-o, --open=EXECUTABLE Open the served URL in a browser with a standard
577+
methodor or with the given (optional) executable.
578578
-p, --prod Serve HTTP/2+HTTPS on port 443. Serve regular
579579
HTTP on port 80. Uses /srv/algernon for files.
580580
Disables debug mode. Disables auto-refresh.

engine/url.go

+3-6
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,12 @@ func (ac *Config) OpenURL(host, cPort string, httpsPrefix bool) {
2929
cmd := exec.Command(ac.openExecutable, url)
3030
if ac.openExecutable == "" {
3131
switch runtime.GOOS {
32-
case "darwin":
33-
ac.openExecutable = "open"
34-
cmd = exec.Command("open", url)
35-
case "linux":
36-
ac.openExecutable = "xdg-open"
32+
case "linux", "solaris":
3733
cmd = exec.Command("xdg-open", url)
3834
case "windows":
39-
ac.openExecutable = ""
4035
cmd = exec.Command("rundll32", "url.dll,FileProtocolHandler", url)
36+
default: // darwin, bsd etc
37+
cmd = exec.Command("open", url)
4138
}
4239
}
4340

platformdep/open_bsd.go

-6
This file was deleted.

platformdep/open_linux.go

-6
This file was deleted.

platformdep/open_win.go

-7
This file was deleted.

0 commit comments

Comments
 (0)