Browse Source

Variable rename: capitalisation and stuttering

Renamed DOI configuration variables and structs to avoid stuttering:
Doi.DoiUrl -> DOI.URL
Doi.DoiKey -> DOI.Key
etc
Achilleas Koutsou 6 năm trước cách đây
mục cha
commit
516131f06f
6 tập tin đã thay đổi với 12 bổ sung16 xóa
  1. 2 3
      cmd/web.go
  2. 0 1
      conf/app.ini
  3. 0 0
      pkg/bindata/bindata.go
  4. 5 6
      pkg/setting/setting.go
  5. 4 5
      routes/doi.go
  6. 1 1
      routes/repo/view.go

+ 2 - 3
cmd/web.go

@@ -32,6 +32,7 @@ import (
 	"github.com/G-Node/gogs/models"
 	"github.com/G-Node/gogs/pkg/bindata"
 	"github.com/G-Node/gogs/pkg/context"
+	"github.com/G-Node/gogs/pkg/dav"
 	"github.com/G-Node/gogs/pkg/form"
 	"github.com/G-Node/gogs/pkg/mailer"
 	"github.com/G-Node/gogs/pkg/setting"
@@ -43,7 +44,6 @@ import (
 	"github.com/G-Node/gogs/routes/org"
 	"github.com/G-Node/gogs/routes/repo"
 	"github.com/G-Node/gogs/routes/user"
-	"github.com/G-Node/gogs/pkg/dav"
 	"golang.org/x/net/webdav"
 )
 
@@ -173,7 +173,6 @@ func runWeb(c *cli.Context) error {
 
 	m := newMacaron()
 
-
 	reqSignIn := context.Toggle(&context.ToggleOptions{SignInRequired: true})
 	ignSignIn := context.Toggle(&context.ToggleOptions{SignInRequired: setting.Service.RequireSignInView})
 	ignSignInAndCsrf := context.Toggle(&context.ToggleOptions{DisableCSRF: true})
@@ -486,7 +485,7 @@ func runWeb(c *cli.Context) error {
 		m.Get("/issues/:index", repo.ViewIssue)
 		m.Get("/labels/", repo.RetrieveLabels, repo.Labels)
 		m.Get("/milestones", repo.Milestones)
-		m.Get("/doi", routes.RequestDoi)
+		m.Get("/doi", routes.RequestDOI)
 	}, ignSignIn, context.RepoAssignment(true))
 	m.Group("/:username/:reponame", func() {
 		// FIXME: should use different URLs but mostly same logic for comments of issue and pull reuqest.

+ 0 - 1
conf/app.ini

@@ -505,7 +505,6 @@ INDEX_URL = localhost/index
 SEACH_URL = localhost/search
 
 [doi]
-DO = false
 DOI_URL = https://doi.gin.g-node.org/
 ; AES key (eg. openssl enc -aes-128-cbc -k secret -P -md sha1)
 DOI_KEY = WONTWORK

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
pkg/bindata/bindata.go


+ 5 - 6
pkg/setting/setting.go

@@ -325,11 +325,10 @@ var (
 		SearchUrl string
 	}
 
-	Doi struct {
-		Do      bool
-		DoiUrl  string
-		DoiKey  string
-		DoiBase string
+	DOI struct {
+		URL  string `ini:"DOI_URL"`
+		Key  string `ini:"DOI_KEY"`
+		Base string `ini:"DOI_BASE"`
 	}
 
 	CliConfig struct {
@@ -689,7 +688,7 @@ func NewContext() {
 		log.Fatal(2, "Fail to map UI settings: %v", err)
 	} else if err = Cfg.Section("search").MapTo(&Search); err != nil {
 		log.Fatal(2, "Fail to map Search settings: %v", err)
-	} else if err = Cfg.Section("doi").MapTo(&Doi); err != nil {
+	} else if err = Cfg.Section("doi").MapTo(&DOI); err != nil {
 		log.Fatal(2, "Fail to map Doi settings: %v", err)
 	} else if err = Cfg.Section("cliconfig").MapTo(&CliConfig); err != nil {
 		log.Fatal(2, "Fail to map Client config settings: %v", err)

+ 4 - 5
routes/doi.go

@@ -14,20 +14,19 @@ import (
 	log "gopkg.in/clog.v1"
 )
 
-func RequestDoi(c *context.Context) {
+func RequestDOI(c *context.Context) {
 	if !c.Repo.IsAdmin() {
 		c.Status(http.StatusUnauthorized)
 		return
 	}
 	token := c.GetCookie(setting.SessionConfig.CookieName)
-	token, err := encrypt([]byte(setting.Doi.DoiKey), token)
+	token, err := encrypt([]byte(setting.DOI.Key), token)
 	if err != nil {
-		log.Error(0, "Could not encrypt Secret key:%s", err)
+		log.Error(2, "Could not encrypt Secret key: %s", err)
 		c.Status(http.StatusInternalServerError)
 		return
 	}
-	url := fmt.Sprintf("%s/register?repo=%s&user=%s&token=%s", setting.Doi.DoiUrl, c.Repo.Repository.FullName(),
-		c.User.Name, token)
+	url := fmt.Sprintf("%s/register?repo=%s&user=%s&token=%s", setting.DOI.URL, c.Repo.Repository.FullName(), c.User.Name, token)
 	c.Redirect(url)
 }
 

+ 1 - 1
routes/repo/view.go

@@ -86,7 +86,7 @@ func renderDirectory(c *context.Context, treeLink string) {
 			}
 			c.Data["DOIInfo"] = &doiInfo
 
-			doi := GDoiRepo(c, setting.Doi.DoiBase)
+			doi := GDoiRepo(c, setting.DOI.Base)
 			//ddata, err := ginDoi.GDoiMData(doi, "https://api.datacite.org/works/") //todo configure URL?
 
 			c.Data["DOIReg"] = libgin.IsRegisteredDOI(doi)

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác