aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Mathes <adam@trenchant.org>2018-04-27 08:44:59 -0700
committerAdam Mathes <adam@trenchant.org>2018-04-27 08:44:59 -0700
commiteb3112116ae926921fbefd3677ed16a6da65f645 (patch)
tree76ee877488c64c7a05737067d838627f63c5a8a5
parent071a352c7553224aa8d3dd3a95fc945488c3d943 (diff)
downloadneko-eb3112116ae926921fbefd3677ed16a6da65f645.tar.gz
neko-eb3112116ae926921fbefd3677ed16a6da65f645.tar.bz2
neko-eb3112116ae926921fbefd3677ed16a6da65f645.zip
img proxy as config option
-rw-r--r--config.example3
-rw-r--r--config/config.go1
-rw-r--r--models/item/item.go6
3 files changed, 8 insertions, 2 deletions
diff --git a/config.example b/config.example
index d66df69..10734fc 100644
--- a/config.example
+++ b/config.example
@@ -3,5 +3,6 @@
"web": "127.0.0.0.1:4994",
"username": "username",
"password": "plaintextexamplepasswordpleasereplacethis",
- "static_dir": "absolute/directory/to/neko/static"
+ "static_dir": "absolute/directory/to/neko/static",
+ "proxy_images": false
}
diff --git a/config/config.go b/config/config.go
index bcd1d27..fef1add 100644
--- a/config/config.go
+++ b/config/config.go
@@ -12,6 +12,7 @@ type Settings struct {
Username string `json:"username"`
DigestPassword string `json:"password"`
StaticDir string `json:"static_dir"`
+ ProxyImages bool `json:"proxy_images"`
}
var Config Settings
diff --git a/models/item/item.go b/models/item/item.go
index 1e7e86a..8d1d473 100644
--- a/models/item/item.go
+++ b/models/item/item.go
@@ -1,6 +1,7 @@
package item
import (
+ "adammathes.com/neko/config"
"adammathes.com/neko/models"
"adammathes.com/neko/vlog"
"encoding/base64"
@@ -179,7 +180,9 @@ func Filter(max_id int64, feed_id int64, category string, unread_only bool, star
// but still may need to adjust rules
i.Title = p.Sanitize(i.Title)
i.Description = p.Sanitize(i.Description)
- i.Description = rewriteImages(i.Description)
+ if config.Config.ProxyImages {
+ i.Description = rewriteImages(i.Description)
+ }
i.Url = p.Sanitize(i.Url)
i.FeedTitle = p.Sanitize(i.FeedTitle)
i.FeedUrl = p.Sanitize(i.FeedUrl)
@@ -201,6 +204,7 @@ func (i *Item) CleanHeaderImage() {
}
}
+// rewrite images to use local proxy
func rewriteImages(s string) string {
doc, err := goquery.NewDocumentFromReader(strings.NewReader(s))
if err != nil {