miniflux/ui/feed_edit.go

80 lines
2.4 KiB
Go
Raw Normal View History

// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package ui // import "miniflux.app/v2/ui"
import (
"net/http"
"miniflux.app/v2/config"
"miniflux.app/v2/http/request"
"miniflux.app/v2/http/response/html"
"miniflux.app/v2/ui/form"
"miniflux.app/v2/ui/session"
"miniflux.app/v2/ui/view"
)
func (h *handler) showEditFeedPage(w http.ResponseWriter, r *http.Request) {
user, err := h.store.UserByID(request.UserID(r))
if err != nil {
2018-10-08 03:42:43 +02:00
html.ServerError(w, r, err)
return
}
feedID := request.RouteInt64Param(r, "feedID")
feed, err := h.store.FeedByID(user.ID, feedID)
if err != nil {
2018-10-08 03:42:43 +02:00
html.ServerError(w, r, err)
return
}
if feed == nil {
2018-10-08 03:42:43 +02:00
html.NotFound(w, r)
return
}
categories, err := h.store.Categories(user.ID)
if err != nil {
2018-10-08 03:42:43 +02:00
html.ServerError(w, r, err)
return
}
feedForm := form.FeedForm{
SiteURL: feed.SiteURL,
FeedURL: feed.FeedURL,
Title: feed.Title,
ScraperRules: feed.ScraperRules,
RewriteRules: feed.RewriteRules,
BlocklistRules: feed.BlocklistRules,
KeeplistRules: feed.KeeplistRules,
UrlRewriteRules: feed.UrlRewriteRules,
Crawler: feed.Crawler,
UserAgent: feed.UserAgent,
2021-03-23 04:27:58 +01:00
Cookie: feed.Cookie,
CategoryID: feed.Category.ID,
Username: feed.Username,
Password: feed.Password,
IgnoreHTTPCache: feed.IgnoreHTTPCache,
AllowSelfSignedCertificates: feed.AllowSelfSignedCertificates,
FetchViaProxy: feed.FetchViaProxy,
Disabled: feed.Disabled,
Add Media Player and resume to last playback position In order to ease podcast listening, the player can be put on top of the feed entry as main content. Use the `Use podcast player` option to enable that. It works on audio and video. Also, when playing audio or video, progression will be saved in order to be able to resume listening later. This position saving is done using the original attachement/enclosures player AND podcast player and do not rely on the podcast player option ti be enabled. Additionally, I made the player fill the width with the entry container to ease seeking and have a bigger video. updateEnclosures now keep existing enclosures based on URL When feeds get updated, enclosures entries are always wiped and re-created. This cause two issue - enclosure progression get lost in the process - enclosure ID changes I used the URL as identifier of an enclosure. Not perfect but hopefully should work. When an enclosure already exist, I simply do nothing and leave the entry as is in the database. If anyone is listening/watching to this enclosure during the refresh, the id stay coherent and progression saving still works. The updateEnclosures function got a bit more complex. I tried to make it the more clear I could. Some optimisation are possible but would make the function harder to read in my opinion. I'm not sure if this is often the case, but some feeds may include tracking or simply change the url each time we update the feed. In those situation, enclosures ids and progression will be lost. I have no idea how to handle this last situation. Use the size instead/alongside url to define the identity of an enclosure ? Translation: english as placeholder for every language except French Aside, I tested a video feed and fixed a few things for it. In fact, the MimeType was not working at all on my side, and found a pretty old stackoverflow discussion that suggest to use an Apple non-standard MimeType for m4v video format. I only did one substitution because I only have one feed to test. Any new video feed can make this go away or evolve depending on the situation. Real video feeds does not tend to be easy to find and test extensively this. Co-authored-by: toastal
2023-04-13 11:46:43 +02:00
NoMediaPlayer: feed.NoMediaPlayer,
HideGlobally: feed.HideGlobally,
CategoryHidden: feed.Category.HideGlobally,
}
sess := session.New(h.store, request.SessionID(r))
view := view.New(h.tpl, r, sess)
view.Set("form", feedForm)
view.Set("categories", categories)
view.Set("feed", feed)
view.Set("menu", "feeds")
view.Set("user", user)
view.Set("countUnread", h.store.CountUnreadEntries(user.ID))
2020-09-28 01:01:06 +02:00
view.Set("countErrorFeeds", h.store.CountUserFeedsWithErrors(user.ID))
view.Set("defaultUserAgent", config.Opts.HTTPClientUserAgent())
view.Set("hasProxyConfigured", config.Opts.HasHTTPClientProxyConfigured())
html.OK(w, r, view.Render("edit_feed"))
}