Add hostname option

Resolves #1.
This commit is contained in:
Trevor Slocum 2021-01-05 19:00:14 -08:00
parent 2a1abe8efe
commit cfaca6678d
5 changed files with 19 additions and 9 deletions

View file

@ -1,3 +1,6 @@
1.0.4:
- Add hostname option
1.0.3:
- Set address bar width to screen width

2
go.mod
View file

@ -2,4 +2,4 @@ module gitlab.com/tslocum/gmitohtml
go 1.15
require gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776
require gopkg.in/yaml.v3 v3.0.0-20210105161348-2e78108cf5f8

4
go.sum
View file

@ -1,4 +1,4 @@
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ=
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210105161348-2e78108cf5f8 h1:tH9C0MON9YI3/KuD+u5+tQrQQ8px0MrcJ/avzeALw7o=
gopkg.in/yaml.v3 v3.0.0-20210105161348-2e78108cf5f8/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

14
main.go
View file

@ -31,13 +31,17 @@ func openBrowser(url string) {
}
func main() {
var view bool
var allowFile bool
var daemon string
var configFile string
var (
view bool
allowFile bool
daemon string
hostname string
configFile string
)
flag.BoolVar(&view, "view", false, "open web browser")
flag.BoolVar(&allowFile, "allow-file", false, "allow local file access via file://")
flag.StringVar(&daemon, "daemon", "", "start daemon on specified address")
flag.StringVar(&hostname, "hostname", "", "server hostname (e.g. rocketnine.space) (defaults to daemon address)")
flag.StringVar(&configFile, "config", "", "path to configuration file")
// TODO option to include response header in page
flag.Parse()
@ -92,7 +96,7 @@ func main() {
}
})
err := gmitohtml.StartDaemon(daemon, allowFile)
err := gmitohtml.StartDaemon(daemon, hostname, allowFile)
if err != nil {
log.Fatal(err)
}

View file

@ -345,8 +345,11 @@ func SetOnBookmarksChanged(f func()) {
}
// StartDaemon starts the page conversion daemon.
func StartDaemon(address string, allowFile bool) error {
func StartDaemon(address string, hostname string, allowFile bool) error {
daemonAddress = address
if hostname != "" {
daemonAddress = hostname
}
allowFileAccess = allowFile
loadAssets()