mirror of
https://github.com/miniflux/v2.git
synced 2025-08-01 17:38:37 +00:00
Add HTTP proxy option for subscriptions
This commit is contained in:
parent
0f258fd55b
commit
cf7712acea
40 changed files with 201 additions and 65 deletions
|
@ -7,6 +7,7 @@ package ui // import "miniflux.app/ui"
|
|||
import (
|
||||
"net/http"
|
||||
|
||||
"miniflux.app/config"
|
||||
"miniflux.app/http/client"
|
||||
"miniflux.app/http/request"
|
||||
"miniflux.app/http/response/html"
|
||||
|
@ -52,6 +53,7 @@ func (h *handler) showEditFeedPage(w http.ResponseWriter, r *http.Request) {
|
|||
Username: feed.Username,
|
||||
Password: feed.Password,
|
||||
IgnoreHTTPCache: feed.IgnoreHTTPCache,
|
||||
FetchViaProxy: feed.FetchViaProxy,
|
||||
Disabled: feed.Disabled,
|
||||
}
|
||||
|
||||
|
@ -65,6 +67,7 @@ func (h *handler) showEditFeedPage(w http.ResponseWriter, r *http.Request) {
|
|||
view.Set("countUnread", h.store.CountUnreadEntries(user.ID))
|
||||
view.Set("countErrorFeeds", h.store.CountErrorFeeds(user.ID))
|
||||
view.Set("defaultUserAgent", client.DefaultUserAgent)
|
||||
view.Set("hasProxyConfigured", config.Opts.HasHTTPClientProxyConfigured())
|
||||
|
||||
html.OK(w, r, view.Render("edit_feed"))
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ type FeedForm struct {
|
|||
Username string
|
||||
Password string
|
||||
IgnoreHTTPCache bool
|
||||
FetchViaProxy bool
|
||||
Disabled bool
|
||||
}
|
||||
|
||||
|
@ -51,6 +52,7 @@ func (f FeedForm) Merge(feed *model.Feed) *model.Feed {
|
|||
feed.Username = f.Username
|
||||
feed.Password = f.Password
|
||||
feed.IgnoreHTTPCache = f.IgnoreHTTPCache
|
||||
feed.FetchViaProxy = f.FetchViaProxy
|
||||
feed.Disabled = f.Disabled
|
||||
return feed
|
||||
}
|
||||
|
@ -74,6 +76,7 @@ func NewFeedForm(r *http.Request) *FeedForm {
|
|||
Username: r.FormValue("feed_username"),
|
||||
Password: r.FormValue("feed_password"),
|
||||
IgnoreHTTPCache: r.FormValue("ignore_http_cache") == "1",
|
||||
FetchViaProxy: r.FormValue("fetch_via_proxy") == "1",
|
||||
Disabled: r.FormValue("disabled") == "1",
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,14 +13,15 @@ import (
|
|||
|
||||
// SubscriptionForm represents the subscription form.
|
||||
type SubscriptionForm struct {
|
||||
URL string
|
||||
CategoryID int64
|
||||
Crawler bool
|
||||
UserAgent string
|
||||
Username string
|
||||
Password string
|
||||
ScraperRules string
|
||||
RewriteRules string
|
||||
URL string
|
||||
CategoryID int64
|
||||
Crawler bool
|
||||
FetchViaProxy bool
|
||||
UserAgent string
|
||||
Username string
|
||||
Password string
|
||||
ScraperRules string
|
||||
RewriteRules string
|
||||
}
|
||||
|
||||
// Validate makes sure the form values are valid.
|
||||
|
@ -40,13 +41,14 @@ func NewSubscriptionForm(r *http.Request) *SubscriptionForm {
|
|||
}
|
||||
|
||||
return &SubscriptionForm{
|
||||
URL: r.FormValue("url"),
|
||||
Crawler: r.FormValue("crawler") == "1",
|
||||
CategoryID: int64(categoryID),
|
||||
UserAgent: r.FormValue("user_agent"),
|
||||
Username: r.FormValue("feed_username"),
|
||||
Password: r.FormValue("feed_password"),
|
||||
ScraperRules: r.FormValue("scraper_rules"),
|
||||
RewriteRules: r.FormValue("rewrite_rules"),
|
||||
URL: r.FormValue("url"),
|
||||
Crawler: r.FormValue("crawler") == "1",
|
||||
FetchViaProxy: r.FormValue("fetch_via_proxy") == "1",
|
||||
CategoryID: int64(categoryID),
|
||||
UserAgent: r.FormValue("user_agent"),
|
||||
Username: r.FormValue("feed_username"),
|
||||
Password: r.FormValue("feed_password"),
|
||||
ScraperRules: r.FormValue("scraper_rules"),
|
||||
RewriteRules: r.FormValue("rewrite_rules"),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,14 +2,15 @@
|
|||
// Use of this source code is governed by the Apache 2.0
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package ui // import "miniflux.app/ui"
|
||||
package ui // import "miniflux.app/ui"
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"miniflux.app/config"
|
||||
"miniflux.app/http/client"
|
||||
"miniflux.app/http/response/html"
|
||||
"miniflux.app/http/request"
|
||||
"miniflux.app/http/response/html"
|
||||
"miniflux.app/ui/form"
|
||||
"miniflux.app/ui/session"
|
||||
"miniflux.app/ui/view"
|
||||
|
@ -38,6 +39,7 @@ func (h *handler) showAddSubscriptionPage(w http.ResponseWriter, r *http.Request
|
|||
view.Set("countErrorFeeds", h.store.CountErrorFeeds(user.ID))
|
||||
view.Set("defaultUserAgent", client.DefaultUserAgent)
|
||||
view.Set("form", &form.SubscriptionForm{CategoryID: 0})
|
||||
view.Set("hasProxyConfigured", config.Opts.HasHTTPClientProxyConfigured())
|
||||
|
||||
html.OK(w, r, view.Render("add_subscription"))
|
||||
}
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
// Use of this source code is governed by the Apache 2.0
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package ui // import "miniflux.app/ui"
|
||||
package ui // import "miniflux.app/ui"
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"miniflux.app/config"
|
||||
"miniflux.app/http/client"
|
||||
"miniflux.app/http/request"
|
||||
"miniflux.app/http/response/html"
|
||||
|
@ -40,6 +41,7 @@ func (h *handler) bookmarklet(w http.ResponseWriter, r *http.Request) {
|
|||
view.Set("countUnread", h.store.CountUnreadEntries(user.ID))
|
||||
view.Set("countErrorFeeds", h.store.CountErrorFeeds(user.ID))
|
||||
view.Set("defaultUserAgent", client.DefaultUserAgent)
|
||||
view.Set("hasProxyConfigured", config.Opts.HasHTTPClientProxyConfigured())
|
||||
|
||||
html.OK(w, r, view.Render("add_subscription"))
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ func (h *handler) showChooseSubscriptionPage(w http.ResponseWriter, r *http.Requ
|
|||
subscriptionForm.Password,
|
||||
subscriptionForm.ScraperRules,
|
||||
subscriptionForm.RewriteRules,
|
||||
subscriptionForm.FetchViaProxy,
|
||||
)
|
||||
if err != nil {
|
||||
view.Set("form", subscriptionForm)
|
||||
|
|
|
@ -7,6 +7,7 @@ package ui // import "miniflux.app/ui"
|
|||
import (
|
||||
"net/http"
|
||||
|
||||
"miniflux.app/config"
|
||||
"miniflux.app/http/client"
|
||||
"miniflux.app/http/request"
|
||||
"miniflux.app/http/response/html"
|
||||
|
@ -40,6 +41,7 @@ func (h *handler) submitSubscription(w http.ResponseWriter, r *http.Request) {
|
|||
v.Set("countUnread", h.store.CountUnreadEntries(user.ID))
|
||||
v.Set("countErrorFeeds", h.store.CountErrorFeeds(user.ID))
|
||||
v.Set("defaultUserAgent", client.DefaultUserAgent)
|
||||
v.Set("hasProxyConfigured", config.Opts.HasHTTPClientProxyConfigured())
|
||||
|
||||
subscriptionForm := form.NewSubscriptionForm(r)
|
||||
if err := subscriptionForm.Validate(); err != nil {
|
||||
|
@ -54,6 +56,7 @@ func (h *handler) submitSubscription(w http.ResponseWriter, r *http.Request) {
|
|||
subscriptionForm.UserAgent,
|
||||
subscriptionForm.Username,
|
||||
subscriptionForm.Password,
|
||||
subscriptionForm.FetchViaProxy,
|
||||
)
|
||||
if findErr != nil {
|
||||
logger.Error("[UI:SubmitSubscription] %s", findErr)
|
||||
|
@ -82,6 +85,7 @@ func (h *handler) submitSubscription(w http.ResponseWriter, r *http.Request) {
|
|||
subscriptionForm.Password,
|
||||
subscriptionForm.ScraperRules,
|
||||
subscriptionForm.RewriteRules,
|
||||
subscriptionForm.FetchViaProxy,
|
||||
)
|
||||
if err != nil {
|
||||
v.Set("form", subscriptionForm)
|
||||
|
@ -99,6 +103,7 @@ func (h *handler) submitSubscription(w http.ResponseWriter, r *http.Request) {
|
|||
v.Set("user", user)
|
||||
v.Set("countUnread", h.store.CountUnreadEntries(user.ID))
|
||||
v.Set("countErrorFeeds", h.store.CountErrorFeeds(user.ID))
|
||||
v.Set("hasProxyConfigured", config.Opts.HasHTTPClientProxyConfigured())
|
||||
|
||||
html.OK(w, r, v.Render("choose_subscription"))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue