aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/ui
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <fred@miniflux.net>2017-12-10 20:51:04 -0800
committerGravatar Frédéric Guillot <fred@miniflux.net>2017-12-10 20:51:04 -0800
commit87ccad5c7f1edf8bce37af547ca1659326398fa8 (patch)
tree4998a78ac68b1c2c03e6152d26567928cdf042ec /server/ui
parent7a35c58f53d76356292e3e0ca9c91add3595a9e0 (diff)
Add scraper rules
Diffstat (limited to 'server/ui')
-rw-r--r--server/ui/controller/entry.go10
-rw-r--r--server/ui/controller/feed.go9
-rw-r--r--server/ui/form/feed.go19
3 files changed, 19 insertions, 19 deletions
diff --git a/server/ui/controller/entry.go b/server/ui/controller/entry.go
index eb47201..5c1d3f5 100644
--- a/server/ui/controller/entry.go
+++ b/server/ui/controller/entry.go
@@ -40,18 +40,14 @@ func (c *Controller) FetchContent(ctx *core.Context, request *core.Request, resp
return
}
- content, err := scraper.Fetch(entry.URL)
+ content, err := scraper.Fetch(entry.URL, entry.Feed.ScraperRules)
if err != nil {
response.JSON().ServerError(err)
return
}
- if len(content) > len(entry.Content) {
- entry.Content = content
- c.store.UpdateEntryContent(entry)
- } else {
- content = entry.Content
- }
+ entry.Content = content
+ c.store.UpdateEntryContent(entry)
response.JSON().Created(map[string]string{"content": content})
}
diff --git a/server/ui/controller/feed.go b/server/ui/controller/feed.go
index eeb66c4..d5bc858 100644
--- a/server/ui/controller/feed.go
+++ b/server/ui/controller/feed.go
@@ -217,10 +217,11 @@ func (c *Controller) getFeedFormTemplateArgs(ctx *core.Context, user *model.User
if feedForm == nil {
args["form"] = form.FeedForm{
- SiteURL: feed.SiteURL,
- FeedURL: feed.FeedURL,
- Title: feed.Title,
- CategoryID: feed.Category.ID,
+ SiteURL: feed.SiteURL,
+ FeedURL: feed.FeedURL,
+ Title: feed.Title,
+ ScraperRules: feed.ScraperRules,
+ CategoryID: feed.Category.ID,
}
} else {
args["form"] = feedForm
diff --git a/server/ui/form/feed.go b/server/ui/form/feed.go
index 8a8cf20..7d07375 100644
--- a/server/ui/form/feed.go
+++ b/server/ui/form/feed.go
@@ -14,10 +14,11 @@ import (
// FeedForm represents a feed form in the UI
type FeedForm struct {
- FeedURL string
- SiteURL string
- Title string
- CategoryID int64
+ FeedURL string
+ SiteURL string
+ Title string
+ ScraperRules string
+ CategoryID int64
}
// ValidateModification validates FeedForm fields
@@ -34,6 +35,7 @@ func (f FeedForm) Merge(feed *model.Feed) *model.Feed {
feed.Title = f.Title
feed.SiteURL = f.SiteURL
feed.FeedURL = f.FeedURL
+ feed.ScraperRules = f.ScraperRules
feed.ParsingErrorCount = 0
feed.ParsingErrorMsg = ""
return feed
@@ -47,9 +49,10 @@ func NewFeedForm(r *http.Request) *FeedForm {
}
return &FeedForm{
- FeedURL: r.FormValue("feed_url"),
- SiteURL: r.FormValue("site_url"),
- Title: r.FormValue("title"),
- CategoryID: int64(categoryID),
+ FeedURL: r.FormValue("feed_url"),
+ SiteURL: r.FormValue("site_url"),
+ Title: r.FormValue("title"),
+ ScraperRules: r.FormValue("scraper_rules"),
+ CategoryID: int64(categoryID),
}
}