mirror of
https://gitee.com/gitea/gitea
synced 2025-11-05 09:00:24 +08:00
Replaced bindata calls with options
This commit is contained in:
27
cmd/web.go
27
cmd/web.go
@@ -18,9 +18,9 @@ import (
|
|||||||
"code.gitea.io/git"
|
"code.gitea.io/git"
|
||||||
"code.gitea.io/gitea/models"
|
"code.gitea.io/gitea/models"
|
||||||
"code.gitea.io/gitea/modules/auth"
|
"code.gitea.io/gitea/modules/auth"
|
||||||
"code.gitea.io/gitea/modules/bindata"
|
|
||||||
"code.gitea.io/gitea/modules/context"
|
"code.gitea.io/gitea/modules/context"
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
|
"code.gitea.io/gitea/modules/options"
|
||||||
"code.gitea.io/gitea/modules/public"
|
"code.gitea.io/gitea/modules/public"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
"code.gitea.io/gitea/modules/template"
|
"code.gitea.io/gitea/modules/template"
|
||||||
@@ -150,22 +150,29 @@ func newMacaron() *macaron.Macaron {
|
|||||||
models.InitMailRender(path.Join(setting.StaticRootPath, "templates/mail"),
|
models.InitMailRender(path.Join(setting.StaticRootPath, "templates/mail"),
|
||||||
path.Join(setting.CustomPath, "templates/mail"), funcMap)
|
path.Join(setting.CustomPath, "templates/mail"), funcMap)
|
||||||
|
|
||||||
localeNames, err := bindata.AssetDir("conf/locale")
|
localeNames, err := options.Dir("locale")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(4, "Fail to list locale files: %v", err)
|
log.Fatal(4, "Fail to list locale files: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
localFiles := make(map[string][]byte)
|
localFiles := make(map[string][]byte)
|
||||||
|
|
||||||
for _, name := range localeNames {
|
for _, name := range localeNames {
|
||||||
localFiles[name] = bindata.MustAsset("conf/locale/" + name)
|
localFiles[name], err = options.Locale(name)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(4, "Failed to load %s locale file. %v", name, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m.Use(i18n.I18n(i18n.Options{
|
m.Use(i18n.I18n(i18n.Options{
|
||||||
SubURL: setting.AppSubURL,
|
SubURL: setting.AppSubURL,
|
||||||
Files: localFiles,
|
Files: localFiles,
|
||||||
CustomDirectory: path.Join(setting.CustomPath, "conf/locale"),
|
Langs: setting.Langs,
|
||||||
Langs: setting.Langs,
|
Names: setting.Names,
|
||||||
Names: setting.Names,
|
DefaultLang: "en-US",
|
||||||
DefaultLang: "en-US",
|
Redirect: true,
|
||||||
Redirect: true,
|
|
||||||
}))
|
}))
|
||||||
m.Use(cache.Cacher(cache.Options{
|
m.Use(cache.Cacher(cache.Options{
|
||||||
Adapter: setting.CacheAdapter,
|
Adapter: setting.CacheAdapter,
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"code.gitea.io/git"
|
"code.gitea.io/git"
|
||||||
"code.gitea.io/gitea/modules/bindata"
|
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
"code.gitea.io/gitea/modules/markdown"
|
"code.gitea.io/gitea/modules/markdown"
|
||||||
|
"code.gitea.io/gitea/modules/options"
|
||||||
"code.gitea.io/gitea/modules/process"
|
"code.gitea.io/gitea/modules/process"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
"code.gitea.io/gitea/modules/sync"
|
"code.gitea.io/gitea/modules/sync"
|
||||||
@@ -80,11 +80,11 @@ func LoadRepoConfig() {
|
|||||||
types := []string{"gitignore", "license", "readme", "label"}
|
types := []string{"gitignore", "license", "readme", "label"}
|
||||||
typeFiles := make([][]string, 4)
|
typeFiles := make([][]string, 4)
|
||||||
for i, t := range types {
|
for i, t := range types {
|
||||||
files, err := bindata.AssetDir("conf/" + t)
|
files, err := options.Dir(t)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(4, "Fail to get %s files: %v", t, err)
|
log.Fatal(4, "Fail to get %s files: %v", t, err)
|
||||||
}
|
}
|
||||||
customPath := path.Join(setting.CustomPath, "conf", t)
|
customPath := path.Join(setting.CustomPath, "options", t)
|
||||||
if com.IsDir(customPath) {
|
if com.IsDir(customPath) {
|
||||||
customFiles, err := com.StatDir(customPath)
|
customFiles, err := com.StatDir(customPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -823,14 +823,25 @@ type CreateRepoOptions struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getRepoInitFile(tp, name string) ([]byte, error) {
|
func getRepoInitFile(tp, name string) ([]byte, error) {
|
||||||
relPath := path.Join("conf", tp, strings.TrimLeft(name, "./"))
|
cleanedName := strings.TrimLeft(name, "./")
|
||||||
|
relPath := path.Join("options", tp, cleanedName)
|
||||||
|
|
||||||
// Use custom file when available.
|
// Use custom file when available.
|
||||||
customPath := path.Join(setting.CustomPath, relPath)
|
customPath := path.Join(setting.CustomPath, relPath)
|
||||||
if com.IsFile(customPath) {
|
if com.IsFile(customPath) {
|
||||||
return ioutil.ReadFile(customPath)
|
return ioutil.ReadFile(customPath)
|
||||||
}
|
}
|
||||||
return bindata.Asset(relPath)
|
|
||||||
|
switch tp {
|
||||||
|
case "readme":
|
||||||
|
return options.Readme(cleanedName)
|
||||||
|
case "gitignore":
|
||||||
|
return options.Gitignore(cleanedName)
|
||||||
|
case "license":
|
||||||
|
return options.License(cleanedName)
|
||||||
|
default:
|
||||||
|
return []byte{}, fmt.Errorf("Invalid init file type")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func prepareRepoCommit(repo *Repository, tmpDir, repoPath string, opts CreateRepoOptions) error {
|
func prepareRepoCommit(repo *Repository, tmpDir, repoPath string, opts CreateRepoOptions) error {
|
||||||
|
|||||||
Reference in New Issue
Block a user