static_stylesheet.go 800 B

12345678910111213141516171819202122232425262728
  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. "time"
  8. "github.com/miniflux/miniflux/http/request"
  9. "github.com/miniflux/miniflux/http/response"
  10. "github.com/miniflux/miniflux/ui/static"
  11. )
  12. // Stylesheet renders the CSS.
  13. func (c *Controller) Stylesheet(w http.ResponseWriter, r *http.Request) {
  14. stylesheet := request.Param(r, "name", "white")
  15. body := static.Stylesheets["common"]
  16. etag := static.StylesheetsChecksums["common"]
  17. if theme, found := static.Stylesheets[stylesheet]; found {
  18. body += theme
  19. etag += static.StylesheetsChecksums[stylesheet]
  20. }
  21. response.Cache(w, r, "text/css; charset=utf-8", etag, []byte(body), 48*time.Hour)
  22. }