You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
896 B

  1. // Copyright 2016 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package public
  5. import (
  6. "path"
  7. "code.gitea.io/gitea/modules/setting"
  8. "gopkg.in/macaron.v1"
  9. )
  10. //go:generate go-bindata -tags "bindata" -ignore "\\.go|\\.less" -pkg "public" -o "bindata.go" ../../public/...
  11. //go:generate go fmt bindata.go
  12. //go:generate sed -i.bak s/..\/..\/public\/// bindata.go
  13. //go:generate rm -f bindata.go.bak
  14. // Options represents the available options to configure the macaron handler.
  15. type Options struct {
  16. Directory string
  17. SkipLogging bool
  18. }
  19. // Custom implements the macaron static handler for serving custom assets.
  20. func Custom(opts *Options) macaron.Handler {
  21. return macaron.Static(
  22. path.Join(setting.CustomPath, "public"),
  23. macaron.StaticOptions{
  24. SkipLogging: opts.SkipLogging,
  25. },
  26. )
  27. }