Add configuration option ShowImages

When enabled, clients accessing gemini pages via HTTPS will see links to
images as inline images.

Resolves #13.
This commit is contained in:
Trevor Slocum 2021-07-22 20:00:50 -07:00
parent 0c4c7e8ecb
commit 24f3196a61
2 changed files with 9 additions and 0 deletions

View file

@ -23,6 +23,11 @@ Address to listen for connections on in the format of `interface:port`.
Content types may be defined by file extension. When a type is not defined for Content types may be defined by file extension. When a type is not defined for
the requested file extension, content type is detected automatically. the requested file extension, content type is detected automatically.
## ShowImages
When enabled, clients accessing gemini pages via HTTPS will see links to images
as inline images.
## Hosts ## Hosts
Hosts are defined by their hostname followed by one or more paths to serve. Hosts are defined by their hostname followed by one or more paths to serve.

View file

@ -11,6 +11,7 @@ import (
"strconv" "strconv"
"strings" "strings"
"code.rocketnine.space/tslocum/gmitohtml/pkg/gmitohtml"
"github.com/kballard/go-shellquote" "github.com/kballard/go-shellquote"
"github.com/yookoala/gofast" "github.com/yookoala/gofast"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
@ -76,6 +77,7 @@ type hostConfig struct {
type serverConfig struct { type serverConfig struct {
Listen string Listen string
Types map[string]string Types map[string]string
ShowImages bool
Hosts map[string]*hostConfig Hosts map[string]*hostConfig
DisableHTTPS bool DisableHTTPS bool
DisableSize bool DisableSize bool
@ -151,6 +153,8 @@ func readconfig(configPath string) error {
config.Types[".gemini"] = geminiType config.Types[".gemini"] = geminiType
} }
gmitohtml.Config.ConvertImages = config.ShowImages
defaultHost := config.Hosts["default"] defaultHost := config.Hosts["default"]
delete(config.Hosts, "default") delete(config.Hosts, "default")