Skip to content

Commit 6351167

Browse files
tboergerThomas Boerger
authored andcommitted
Integrated build flag for bindata in public and templates
1 parent da33510 commit 6351167

File tree

6 files changed

+123
-0
lines changed

6 files changed

+123
-0
lines changed

public/dynamic.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// +build !bindata
2+
3+
// Copyright 2016 The Gitea Authors. All rights reserved.
4+
// Use of this source code is governed by a MIT-style
5+
// license that can be found in the LICENSE file.
6+
7+
package public
8+
9+
import (
10+
"gopkg.in/macaron.v1"
11+
)
12+
13+
func Static(opts *Options) macaron.Handler {
14+
return macaron.Static(
15+
opts.Directory,
16+
macaron.StaticOptions{
17+
SkipLogging: opts.SkipLogging,
18+
},
19+
)
20+
}

public/public.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
5+
package public
6+
7+
//go:generate go-bindata -tags bindata -ignore "\\.go|\\.less" -pkg public -o bindata.go ./...
8+
//go:generate go fmt bindata.go
9+
10+
type Options struct {
11+
Directory string
12+
SkipLogging bool
13+
}

public/static.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// +build bindata
2+
3+
// Copyright 2016 The Gitea Authors. All rights reserved.
4+
// Use of this source code is governed by a MIT-style
5+
// license that can be found in the LICENSE file.
6+
7+
package public
8+
9+
import (
10+
"github.com/go-macaron/bindata"
11+
"gopkg.in/macaron.v1"
12+
)
13+
14+
func Static(opts *Options) macaron.Handler {
15+
return macaron.Static(
16+
opts.Directory,
17+
macaron.StaticOptions{
18+
SkipLogging: opts.SkipLogging,
19+
FileSystem: bindata.Static(bindata.Options{
20+
Asset: Asset,
21+
AssetDir: AssetDir,
22+
AssetInfo: AssetInfo,
23+
AssetNames: AssetNames,
24+
Prefix: "",
25+
}),
26+
},
27+
)
28+
}

templates/dynamic.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// +build !bindata
2+
3+
// Copyright 2016 The Gitea Authors. All rights reserved.
4+
// Use of this source code is governed by a MIT-style
5+
// license that can be found in the LICENSE file.
6+
7+
package templates
8+
9+
import (
10+
"github.com/go-gitea/gitea/modules/template"
11+
"gopkg.in/macaron.v1"
12+
)
13+
14+
func Renderer(opts *Options) macaron.Handler {
15+
return macaron.Renderer(macaron.RenderOptions{
16+
Directory: opts.Directory,
17+
AppendDirectories: opts.AppendDirectories,
18+
Funcs: template.NewFuncMap(),
19+
})
20+
}

templates/static.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// +build bindata
2+
3+
// Copyright 2016 The Gitea Authors. All rights reserved.
4+
// Use of this source code is governed by a MIT-style
5+
// license that can be found in the LICENSE file.
6+
7+
package templates
8+
9+
import (
10+
"github.com/go-gitea/gitea/modules/template"
11+
"github.com/go-macaron/bindata"
12+
"gopkg.in/macaron.v1"
13+
)
14+
15+
func Renderer(opts *Options) macaron.Handler {
16+
return macaron.Renderer(macaron.RenderOptions{
17+
AppendDirectories: opts.AppendDirectories,
18+
Funcs: template.NewFuncMap(),
19+
TemplateFileSystem: bindata.Templates(
20+
bindata.Options{
21+
Asset: Asset,
22+
AssetDir: AssetDir,
23+
AssetInfo: AssetInfo,
24+
AssetNames: AssetNames,
25+
Prefix: "",
26+
},
27+
),
28+
})
29+
}

templates/templates.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
5+
package templates
6+
7+
//go:generate go-bindata -tags bindata -ignore "\\.go" -pkg templates -o bindata.go ./...
8+
//go:generate go fmt bindata.go
9+
10+
type Options struct {
11+
Directory string
12+
AppendDirectories []string
13+
}

0 commit comments

Comments
 (0)