opml_export.go 680 B

1234567891011121314151617181920212223242526
  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
  5. import (
  6. "net/http"
  7. "github.com/miniflux/miniflux/http/context"
  8. "github.com/miniflux/miniflux/http/response/html"
  9. "github.com/miniflux/miniflux/http/response/xml"
  10. "github.com/miniflux/miniflux/reader/opml"
  11. )
  12. // Export generates the OPML file.
  13. func (c *Controller) Export(w http.ResponseWriter, r *http.Request) {
  14. ctx := context.New(r)
  15. opml, err := opml.NewHandler(c.store).Export(ctx.UserID())
  16. if err != nil {
  17. html.ServerError(w, err)
  18. return
  19. }
  20. xml.Attachment(w, "feeds.opml", opml)
  21. }