summaryrefslogtreecommitdiff
path: root/actions.go
diff options
context:
space:
mode:
Diffstat (limited to 'actions.go')
-rw-r--r--actions.go20
1 files changed, 19 insertions, 1 deletions
diff --git a/actions.go b/actions.go
index 28713ee..448ac06 100644
--- a/actions.go
+++ b/actions.go
@@ -8,6 +8,7 @@ import (
"net/url"
"os"
"os/exec"
+ "path"
"path/filepath"
"strconv"
"strings"
@@ -176,7 +177,7 @@ func Reload(state *BrowserState, conf *Config) error {
return err
}
- return print(state)
+ return HandleResource(state, conf)
}
func externalMessage() ([]byte, error) {
@@ -470,6 +471,23 @@ func Print(state *BrowserState) error {
return print(state)
}
+func HandleResource(state *BrowserState, conf *Config) error {
+ if state.Modal != nil {
+ return Print(state)
+ }
+
+ if handler, ok := conf.Handlers[state.DocType]; ok {
+ return Pipe(state, handler)
+ }
+
+ switch state.DocType {
+ case "text/gemini", "text/x-gophermap", "text/plain":
+ return print(state)
+ }
+
+ return Save(state, path.Base(state.Url.Path), conf)
+}
+
func Outline(state *BrowserState, conf *Config) error {
if state.Body == nil {
return ErrMustBeOnAPage