@@ -7,7 +7,6 @@ package cmd
7
7
import (
8
8
"crypto/tls"
9
9
"fmt"
10
- "io/ioutil"
11
10
"net"
12
11
"net/http"
13
12
"net/http/fcgi"
@@ -30,6 +29,7 @@ import (
30
29
"code.gitea.io/gitea/routers/org"
31
30
"code.gitea.io/gitea/routers/repo"
32
31
"code.gitea.io/gitea/routers/user"
32
+ "github.com/go-macaron/bindata"
33
33
"github.com/go-macaron/binding"
34
34
"github.com/go-macaron/cache"
35
35
"github.com/go-macaron/captcha"
@@ -73,45 +73,6 @@ type VerChecker struct {
73
73
Expected string
74
74
}
75
75
76
- // checkVersion checks if binary matches the version of templates files.
77
- func checkVersion () {
78
- // Templates.
79
- data , err := ioutil .ReadFile (setting .StaticRootPath + "/templates/.VERSION" )
80
- if err != nil {
81
- log .Fatal (4 , "Fail to read 'templates/.VERSION': %v" , err )
82
- }
83
- tplVer := string (data )
84
- if tplVer != setting .AppVer {
85
- if version .Compare (tplVer , setting .AppVer , ">" ) {
86
- log .Fatal (4 , "Binary version is lower than template file version, did you forget to recompile Gogs?" )
87
- } else {
88
- log .Fatal (4 , "Binary version is higher than template file version, did you forget to update template files?" )
89
- }
90
- }
91
-
92
- // Check dependency version.
93
- checkers := []VerChecker {
94
- {"github.com/go-xorm/xorm" , func () string { return xorm .Version }, "0.5.5" },
95
- {"github.com/go-macaron/binding" , binding .Version , "0.3.2" },
96
- {"github.com/go-macaron/cache" , cache .Version , "0.1.2" },
97
- {"github.com/go-macaron/csrf" , csrf .Version , "0.1.0" },
98
- {"github.com/go-macaron/i18n" , i18n .Version , "0.3.0" },
99
- {"github.com/go-macaron/session" , session .Version , "0.1.6" },
100
- {"github.com/go-macaron/toolbox" , toolbox .Version , "0.1.0" },
101
- {"gopkg.in/ini.v1" , ini .Version , "1.8.4" },
102
- {"gopkg.in/macaron.v1" , macaron .Version , "1.1.7" },
103
- {"code.gitea.io/git" , git .Version , "0.4.1" },
104
- }
105
- for _ , c := range checkers {
106
- if ! version .Compare (c .Version (), c .Expected , ">=" ) {
107
- log .Fatal (4 , `Dependency outdated!
108
- Package '%s' current version (%s) is below requirement (%s),
109
- please use following command to update this package and recompile Gogs:
110
- go get -u %[1]s` , c .ImportPath , c .Version (), c .Expected )
111
- }
112
- }
113
- }
114
-
115
76
// newMacaron initializes Macaron instance.
116
77
func newMacaron () * macaron.Macaron {
117
78
m := macaron .New ()
@@ -126,9 +87,16 @@ func newMacaron() *macaron.Macaron {
126
87
m .SetURLPrefix (setting .AppSubURL )
127
88
}
128
89
m .Use (macaron .Static (
129
- path . Join ( setting . StaticRootPath , "public" ) ,
90
+ "public" ,
130
91
macaron.StaticOptions {
131
92
SkipLogging : setting .DisableRouterLog ,
93
+ FileSystem : bindata .Static (bindata.Options {
94
+ Asset : public .Asset ,
95
+ AssetDir : public .AssetDir ,
96
+ AssetInfo : public .AssetInfo ,
97
+ AssetNames : public .AssetNames ,
98
+ Prefix : "" ,
99
+ }),
132
100
},
133
101
))
134
102
m .Use (macaron .Static (
@@ -139,23 +107,31 @@ func newMacaron() *macaron.Macaron {
139
107
},
140
108
))
141
109
110
+ templateOptions := bindata.Options {
111
+ Asset : templates .Asset ,
112
+ AssetDir : templates .AssetDir ,
113
+ AssetInfo : templates .AssetInfo ,
114
+ AssetNames : templates .AssetNames ,
115
+ Prefix : "" ,
116
+ }
117
+
142
118
funcMap := template .NewFuncMap ()
143
119
m .Use (macaron .Renderer (macaron.RenderOptions {
144
- Directory : path .Join (setting .StaticRootPath , "templates" ),
145
- AppendDirectories : [] string { path . Join ( setting . CustomPath , "templates" )} ,
146
- Funcs : funcMap ,
147
- IndentJSON : macaron . Env != macaron . PROD ,
120
+ AppendDirectories : [] string { path .Join (setting .CustomPath , "templates" )} ,
121
+ Funcs : funcMap ,
122
+ IndentJSON : macaron . Env != macaron . PROD ,
123
+ TemplateFileSystem : bindata . Templates ( templateOptions ) ,
148
124
}))
149
- models .InitMailRender (path . Join ( setting . StaticRootPath , "templates/mail" ) ,
125
+ models .InitMailRender (templateOptions ,
150
126
path .Join (setting .CustomPath , "templates/mail" ), funcMap )
151
127
152
- localeNames , err := bindata .AssetDir ("conf/ locale" )
128
+ localeNames , err := conf .AssetDir ("locale" )
153
129
if err != nil {
154
130
log .Fatal (4 , "Fail to list locale files: %v" , err )
155
131
}
156
132
localFiles := make (map [string ][]byte )
157
133
for _ , name := range localeNames {
158
- localFiles [name ] = bindata .MustAsset ("conf/ locale/" + name )
134
+ localFiles [name ] = conf .MustAsset ("locale/" + name )
159
135
}
160
136
m .Use (i18n .I18n (i18n.Options {
161
137
SubURL : setting .AppSubURL ,
@@ -199,7 +175,6 @@ func runWeb(ctx *cli.Context) error {
199
175
setting .CustomConf = ctx .String ("config" )
200
176
}
201
177
routers .GlobalInit ()
202
- checkVersion ()
203
178
204
179
m := newMacaron ()
205
180
0 commit comments