diff options
-rw-r--r-- | config.example | 3 | ||||
-rw-r--r-- | config/config.go | 1 | ||||
-rw-r--r-- | models/item/item.go | 6 |
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 { |