feed_edit.go 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
  2. // SPDX-License-Identifier: Apache-2.0
  3. package ui // import "miniflux.app/v2/internal/ui"
  4. import (
  5. "net/http"
  6. "miniflux.app/v2/internal/config"
  7. "miniflux.app/v2/internal/http/request"
  8. "miniflux.app/v2/internal/http/response/html"
  9. "miniflux.app/v2/internal/ui/form"
  10. "miniflux.app/v2/internal/ui/session"
  11. "miniflux.app/v2/internal/ui/view"
  12. )
  13. func (h *handler) showEditFeedPage(w http.ResponseWriter, r *http.Request) {
  14. user, err := h.store.UserByID(request.UserID(r))
  15. if err != nil {
  16. html.ServerError(w, r, err)
  17. return
  18. }
  19. feedID := request.RouteInt64Param(r, "feedID")
  20. feed, err := h.store.FeedByID(user.ID, feedID)
  21. if err != nil {
  22. html.ServerError(w, r, err)
  23. return
  24. }
  25. if feed == nil {
  26. html.NotFound(w, r)
  27. return
  28. }
  29. categories, err := h.store.Categories(user.ID)
  30. if err != nil {
  31. html.ServerError(w, r, err)
  32. return
  33. }
  34. feedForm := form.FeedForm{
  35. SiteURL: feed.SiteURL,
  36. FeedURL: feed.FeedURL,
  37. Title: feed.Title,
  38. Description: feed.Description,
  39. ScraperRules: feed.ScraperRules,
  40. RewriteRules: feed.RewriteRules,
  41. UrlRewriteRules: feed.UrlRewriteRules,
  42. BlocklistRules: feed.BlocklistRules,
  43. KeeplistRules: feed.KeeplistRules,
  44. BlockFilterEntryRules: feed.BlockFilterEntryRules,
  45. KeepFilterEntryRules: feed.KeepFilterEntryRules,
  46. Crawler: feed.Crawler,
  47. UserAgent: feed.UserAgent,
  48. Cookie: feed.Cookie,
  49. CategoryID: feed.Category.ID,
  50. Username: feed.Username,
  51. Password: feed.Password,
  52. IgnoreHTTPCache: feed.IgnoreHTTPCache,
  53. AllowSelfSignedCertificates: feed.AllowSelfSignedCertificates,
  54. FetchViaProxy: feed.FetchViaProxy,
  55. Disabled: feed.Disabled,
  56. NoMediaPlayer: feed.NoMediaPlayer,
  57. HideGlobally: feed.HideGlobally,
  58. CategoryHidden: feed.Category.HideGlobally,
  59. AppriseServiceURLs: feed.AppriseServiceURLs,
  60. WebhookURL: feed.WebhookURL,
  61. DisableHTTP2: feed.DisableHTTP2,
  62. NtfyEnabled: feed.NtfyEnabled,
  63. NtfyPriority: feed.NtfyPriority,
  64. NtfyTopic: feed.NtfyTopic,
  65. PushoverEnabled: feed.PushoverEnabled,
  66. PushoverPriority: feed.PushoverPriority,
  67. ProxyURL: feed.ProxyURL,
  68. }
  69. sess := session.New(h.store, request.SessionID(r))
  70. view := view.New(h.tpl, r, sess)
  71. view.Set("form", feedForm)
  72. view.Set("categories", categories)
  73. view.Set("feed", feed)
  74. view.Set("menu", "feeds")
  75. view.Set("user", user)
  76. view.Set("countUnread", h.store.CountUnreadEntries(user.ID))
  77. view.Set("countErrorFeeds", h.store.CountUserFeedsWithErrors(user.ID))
  78. view.Set("defaultUserAgent", config.Opts.HTTPClientUserAgent())
  79. view.Set("hasProxyConfigured", config.Opts.HasHTTPClientProxyURLConfigured())
  80. html.OK(w, r, view.Render("edit_feed"))
  81. }