entry_scraper.go 1023 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright 2018 Frédéric Guillot. All rights reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. package ui // import "miniflux.app/ui"
  5. import (
  6. "net/http"
  7. "miniflux.app/http/request"
  8. "miniflux.app/http/response/json"
  9. "miniflux.app/model"
  10. "miniflux.app/proxy"
  11. "miniflux.app/reader/processor"
  12. )
  13. func (h *handler) fetchContent(w http.ResponseWriter, r *http.Request) {
  14. entryID := request.RouteInt64Param(r, "entryID")
  15. builder := h.store.NewEntryQueryBuilder(request.UserID(r))
  16. builder.WithEntryID(entryID)
  17. builder.WithoutStatus(model.EntryStatusRemoved)
  18. entry, err := builder.GetEntry()
  19. if err != nil {
  20. json.ServerError(w, r, err)
  21. return
  22. }
  23. if entry == nil {
  24. json.NotFound(w, r)
  25. return
  26. }
  27. if err := processor.ProcessEntryWebPage(entry); err != nil {
  28. json.ServerError(w, r, err)
  29. return
  30. }
  31. h.store.UpdateEntryContent(entry)
  32. json.OK(w, r, map[string]string{"content": proxy.ImageProxyRewriter(h.router, entry.Content)})
  33. }