1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-01 17:38:37 +00:00

Add new fields for feed username/password

This commit is contained in:
Frédéric Guillot 2018-06-19 22:58:29 -07:00
parent 261695c14c
commit bddca15b69
27 changed files with 203 additions and 68 deletions

View file

@ -56,6 +56,8 @@ func (c *Controller) EditFeed(w http.ResponseWriter, r *http.Request) {
RewriteRules: feed.RewriteRules,
Crawler: feed.Crawler,
CategoryID: feed.Category.ID,
Username: feed.Username,
Password: feed.Password,
}
sess := session.New(c.store, ctx)

View file

@ -21,6 +21,8 @@ type FeedForm struct {
RewriteRules string
Crawler bool
CategoryID int64
Username string
Password string
}
// ValidateModification validates FeedForm fields
@ -42,6 +44,8 @@ func (f FeedForm) Merge(feed *model.Feed) *model.Feed {
feed.Crawler = f.Crawler
feed.ParsingErrorCount = 0
feed.ParsingErrorMsg = ""
feed.Username = f.Username
feed.Password = f.Password
return feed
}
@ -60,5 +64,7 @@ func NewFeedForm(r *http.Request) *FeedForm {
RewriteRules: r.FormValue("rewrite_rules"),
Crawler: r.FormValue("crawler") == "1",
CategoryID: int64(categoryID),
Username: r.FormValue("username"),
Password: r.FormValue("password"),
}
}

View file

@ -16,6 +16,8 @@ type SubscriptionForm struct {
URL string
CategoryID int64
Crawler bool
Username string
Password string
}
// Validate makes sure the form values are valid.
@ -38,5 +40,7 @@ func NewSubscriptionForm(r *http.Request) *SubscriptionForm {
URL: r.FormValue("url"),
Crawler: r.FormValue("crawler") == "1",
CategoryID: int64(categoryID),
Username: r.FormValue("username"),
Password: r.FormValue("password"),
}
}

View file

@ -1,5 +1,5 @@
// Code generated by go generate; DO NOT EDIT.
// 2018-05-20 15:22:33.779971968 -0700 PDT m=+0.011442481
// 2018-06-19 22:56:40.300982018 -0700 PDT m=+0.022794138
package static

File diff suppressed because one or more lines are too long

View file

@ -184,6 +184,17 @@ tr:hover {
}
/* Forms */
fieldset {
border: 1px solid #ddd;
padding: 8px;
}
legend {
font-weight: 500;
padding-left: 3px;
padding-right: 3px;
}
label {
cursor: pointer;
display: block;

View file

@ -1,5 +1,5 @@
// Code generated by go generate; DO NOT EDIT.
// 2018-06-06 18:30:00.64689124 +0000 UTC m=+0.004975400
// 2018-06-19 22:56:40.308801738 -0700 PDT m=+0.030613858
package static

View file

@ -47,7 +47,14 @@ func (c *Controller) ChooseSubscription(w http.ResponseWriter, r *http.Request)
return
}
feed, err := c.feedHandler.CreateFeed(user.ID, subscriptionForm.CategoryID, subscriptionForm.URL, subscriptionForm.Crawler)
feed, err := c.feedHandler.CreateFeed(
user.ID,
subscriptionForm.CategoryID,
subscriptionForm.URL,
subscriptionForm.Crawler,
subscriptionForm.Username,
subscriptionForm.Password,
)
if err != nil {
view.Set("form", subscriptionForm)
view.Set("errorMessage", err)

View file

@ -49,7 +49,11 @@ func (c *Controller) SubmitSubscription(w http.ResponseWriter, r *http.Request)
return
}
subscriptions, err := subscription.FindSubscriptions(subscriptionForm.URL)
subscriptions, err := subscription.FindSubscriptions(
subscriptionForm.URL,
subscriptionForm.Username,
subscriptionForm.Password,
)
if err != nil {
logger.Error("[Controller:SubmitSubscription] %v", err)
v.Set("form", subscriptionForm)
@ -67,7 +71,14 @@ func (c *Controller) SubmitSubscription(w http.ResponseWriter, r *http.Request)
v.Set("errorMessage", "Unable to find any subscription.")
html.OK(w, v.Render("add_subscription"))
case n == 1:
feed, err := c.feedHandler.CreateFeed(user.ID, subscriptionForm.CategoryID, subscriptions[0].URL, subscriptionForm.Crawler)
feed, err := c.feedHandler.CreateFeed(
user.ID,
subscriptionForm.CategoryID,
subscriptions[0].URL,
subscriptionForm.Crawler,
subscriptionForm.Username,
subscriptionForm.Password,
)
if err != nil {
v.Set("form", subscriptionForm)
v.Set("errorMessage", err)
@ -79,7 +90,7 @@ func (c *Controller) SubmitSubscription(w http.ResponseWriter, r *http.Request)
case n > 1:
v := view.New(c.tpl, ctx, sess)
v.Set("subscriptions", subscriptions)
v.Set("categoryID", subscriptionForm.CategoryID)
v.Set("form", subscriptionForm)
v.Set("menu", "feeds")
v.Set("user", user)
v.Set("countUnread", c.store.CountUnreadEntries(user.ID))