2016-11-29 21:56:36 +05:30
|
|
|
// Copyright 2016 The Gitea Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a MIT-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package public
|
|
|
|
|
2017-01-29 03:44:56 +05:30
|
|
|
import (
|
|
|
|
"path"
|
|
|
|
|
|
|
|
"code.gitea.io/gitea/modules/setting"
|
|
|
|
"gopkg.in/macaron.v1"
|
|
|
|
)
|
|
|
|
|
2016-11-29 21:56:36 +05:30
|
|
|
//go:generate go-bindata -tags "bindata" -ignore "\\.go|\\.less" -pkg "public" -o "bindata.go" ../../public/...
|
|
|
|
//go:generate go fmt bindata.go
|
2016-12-06 23:28:31 +05:30
|
|
|
//go:generate sed -i.bak s/..\/..\/public\/// bindata.go
|
|
|
|
//go:generate rm -f bindata.go.bak
|
2016-11-29 21:56:36 +05:30
|
|
|
|
|
|
|
// Options represents the available options to configure the macaron handler.
|
|
|
|
type Options struct {
|
|
|
|
Directory string
|
|
|
|
SkipLogging bool
|
|
|
|
}
|
2017-01-29 03:44:56 +05:30
|
|
|
|
|
|
|
// Custom implements the macaron static handler for serving custom assets.
|
|
|
|
func Custom(opts *Options) macaron.Handler {
|
|
|
|
return macaron.Static(
|
|
|
|
path.Join(setting.CustomPath, "public"),
|
|
|
|
macaron.StaticOptions{
|
|
|
|
SkipLogging: opts.SkipLogging,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
}
|