@@ -7,14 +7,14 @@ 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"
14
13
"os"
15
14
"path"
16
15
"strings"
17
16
17
+ "github.com/go-macaron/bindata"
18
18
"github.com/go-macaron/binding"
19
19
"github.com/go-macaron/cache"
20
20
"github.com/go-macaron/captcha"
@@ -23,29 +23,25 @@ import (
23
23
"github.com/go-macaron/i18n"
24
24
"github.com/go-macaron/session"
25
25
"github.com/go-macaron/toolbox"
26
- "github.com/go-xorm/xorm"
27
- "github.com/mcuadros/go-version"
28
26
"github.com/urfave/cli"
29
- "gopkg.in/ini.v1"
30
27
"gopkg.in/macaron.v1"
31
28
32
- "github.com/gogits/git-module"
33
- "github.com/gogits/go-gogs-client"
34
-
29
+ "github.com/go-gitea/gitea/conf"
35
30
"github.com/go-gitea/gitea/models"
36
31
"github.com/go-gitea/gitea/modules/auth"
37
- "github.com/go-gitea/gitea/modules/bindata"
38
32
"github.com/go-gitea/gitea/modules/context"
39
33
"github.com/go-gitea/gitea/modules/log"
40
34
"github.com/go-gitea/gitea/modules/setting"
41
35
"github.com/go-gitea/gitea/modules/template"
36
+ "github.com/go-gitea/gitea/public"
42
37
"github.com/go-gitea/gitea/routers"
43
38
"github.com/go-gitea/gitea/routers/admin"
44
39
apiv1 "github.com/go-gitea/gitea/routers/api/v1"
45
40
"github.com/go-gitea/gitea/routers/dev"
46
41
"github.com/go-gitea/gitea/routers/org"
47
42
"github.com/go-gitea/gitea/routers/repo"
48
43
"github.com/go-gitea/gitea/routers/user"
44
+ "github.com/go-gitea/gitea/templates"
49
45
)
50
46
51
47
// CmdWeb represents the available web sub-command.
@@ -68,46 +64,6 @@ type VerChecker struct {
68
64
Expected string
69
65
}
70
66
71
- // checkVersion checks if binary matches the version of templates files.
72
- func checkVersion () {
73
- // Templates.
74
- data , err := ioutil .ReadFile (setting .StaticRootPath + "/templates/.VERSION" )
75
- if err != nil {
76
- log .Fatal (4 , "Fail to read 'templates/.VERSION': %v" , err )
77
- }
78
- tplVer := string (data )
79
- if tplVer != setting .AppVer {
80
- if version .Compare (tplVer , setting .AppVer , ">" ) {
81
- log .Fatal (4 , "Binary version is lower than template file version, did you forget to recompile Gogs?" )
82
- } else {
83
- log .Fatal (4 , "Binary version is higher than template file version, did you forget to update template files?" )
84
- }
85
- }
86
-
87
- // Check dependency version.
88
- checkers := []VerChecker {
89
- {"github.com/go-xorm/xorm" , func () string { return xorm .Version }, "0.5.5" },
90
- {"github.com/go-macaron/binding" , binding .Version , "0.3.2" },
91
- {"github.com/go-macaron/cache" , cache .Version , "0.1.2" },
92
- {"github.com/go-macaron/csrf" , csrf .Version , "0.1.0" },
93
- {"github.com/go-macaron/i18n" , i18n .Version , "0.3.0" },
94
- {"github.com/go-macaron/session" , session .Version , "0.1.6" },
95
- {"github.com/go-macaron/toolbox" , toolbox .Version , "0.1.0" },
96
- {"gopkg.in/ini.v1" , ini .Version , "1.8.4" },
97
- {"gopkg.in/macaron.v1" , macaron .Version , "1.1.7" },
98
- {"github.com/gogits/git-module" , git .Version , "0.4.1" },
99
- {"github.com/gogits/go-gogs-client" , gogs .Version , "0.12.1" },
100
- }
101
- for _ , c := range checkers {
102
- if ! version .Compare (c .Version (), c .Expected , ">=" ) {
103
- log .Fatal (4 , `Dependency outdated!
104
- Package '%s' current version (%s) is below requirement (%s),
105
- please use following command to update this package and recompile Gogs:
106
- go get -u %[1]s` , c .ImportPath , c .Version (), c .Expected )
107
- }
108
- }
109
- }
110
-
111
67
// newMacaron initializes Macaron instance.
112
68
func newMacaron () * macaron.Macaron {
113
69
m := macaron .New ()
@@ -122,9 +78,16 @@ func newMacaron() *macaron.Macaron {
122
78
m .SetURLPrefix (setting .AppSubUrl )
123
79
}
124
80
m .Use (macaron .Static (
125
- path . Join ( setting . StaticRootPath , "public" ) ,
81
+ "public" ,
126
82
macaron.StaticOptions {
127
83
SkipLogging : setting .DisableRouterLog ,
84
+ FileSystem : bindata .Static (bindata.Options {
85
+ Asset : public .Asset ,
86
+ AssetDir : public .AssetDir ,
87
+ AssetInfo : public .AssetInfo ,
88
+ AssetNames : public .AssetNames ,
89
+ Prefix : "" ,
90
+ }),
128
91
},
129
92
))
130
93
m .Use (macaron .Static (
@@ -135,23 +98,31 @@ func newMacaron() *macaron.Macaron {
135
98
},
136
99
))
137
100
101
+ templateOptions := bindata.Options {
102
+ Asset : templates .Asset ,
103
+ AssetDir : templates .AssetDir ,
104
+ AssetInfo : templates .AssetInfo ,
105
+ AssetNames : templates .AssetNames ,
106
+ Prefix : "" ,
107
+ }
108
+
138
109
funcMap := template .NewFuncMap ()
139
110
m .Use (macaron .Renderer (macaron.RenderOptions {
140
- Directory : path .Join (setting .StaticRootPath , "templates" ),
141
- AppendDirectories : [] string { path . Join ( setting . CustomPath , "templates" )} ,
142
- Funcs : funcMap ,
143
- IndentJSON : macaron . Env != macaron . PROD ,
111
+ AppendDirectories : [] string { path .Join (setting .CustomPath , "templates" )} ,
112
+ Funcs : funcMap ,
113
+ IndentJSON : macaron . Env != macaron . PROD ,
114
+ TemplateFileSystem : bindata . Templates ( templateOptions ) ,
144
115
}))
145
- models .InitMailRender (path . Join ( setting . StaticRootPath , "templates/mail" ) ,
116
+ models .InitMailRender (templateOptions ,
146
117
path .Join (setting .CustomPath , "templates/mail" ), funcMap )
147
118
148
- localeNames , err := bindata .AssetDir ("conf/ locale" )
119
+ localeNames , err := conf .AssetDir ("locale" )
149
120
if err != nil {
150
121
log .Fatal (4 , "Fail to list locale files: %v" , err )
151
122
}
152
123
localFiles := make (map [string ][]byte )
153
124
for _ , name := range localeNames {
154
- localFiles [name ] = bindata .MustAsset ("conf/ locale/" + name )
125
+ localFiles [name ] = conf .MustAsset ("locale/" + name )
155
126
}
156
127
m .Use (i18n .I18n (i18n.Options {
157
128
SubURL : setting .AppSubUrl ,
@@ -195,7 +166,6 @@ func runWeb(ctx *cli.Context) error {
195
166
setting .CustomConf = ctx .String ("config" )
196
167
}
197
168
routers .GlobalInit ()
198
- checkVersion ()
199
169
200
170
m := newMacaron ()
201
171
0 commit comments