aboutsummaryrefslogtreecommitdiff
path: root/capybara.go
diff options
context:
space:
mode:
Diffstat (limited to 'capybara.go')
-rw-r--r--capybara.go33
1 files changed, 29 insertions, 4 deletions
diff --git a/capybara.go b/capybara.go
index 497ffe5..b60d728 100644
--- a/capybara.go
+++ b/capybara.go
@@ -17,8 +17,24 @@ import (
"git.sr.ht/~adnano/go-gemini"
"git.sr.ht/~sircmpwn/getopt"
+ "github.com/spf13/viper"
)
+var keepGeminiLinks []string
+
+func init() {
+ viper.SetConfigName("Capybara.yaml")
+ viper.SetConfigType("yaml")
+ viper.AddConfigPath("./")
+ viper.AddConfigPath(".capybara/")
+ viper.AddConfigPath(".capybara-data/")
+ viper.AddConfigPath("/app/.capybara/")
+
+ if err := viper.ReadInConfig(); err == nil {
+ keepGeminiLinks = viper.GetStringSlice("capybara.keep_gemini")
+ }
+}
+
var gemtextPage = template.Must(template.
New("gemtext").
Funcs(template.FuncMap{
@@ -108,11 +124,20 @@ var gemtextPage = template.Must(template.
u = ctx.URL.ResolveReference(u)
if u.Scheme == "" || u.Scheme == "gemini" {
- if u.Host != ctx.Root.Host {
- u.Path = fmt.Sprintf("/proxy/%s%s", u.Host, u.Path)
+ keepGemini := false
+ for _, v := range keepGeminiLinks {
+ if v == u.Host {
+ keepGemini = true
+ }
+ }
+
+ if !keepGemini {
+ if u.Host != ctx.Root.Host {
+ u.Path = fmt.Sprintf("/proxy/%s%s", u.Host, u.Path)
+ }
+ u.Scheme = ""
+ u.Host = ""
}
- u.Scheme = ""
- u.Host = ""
}
return template.URL(u.String())
},