Explorar o código

[codestyle] Capitalise initialisms in variable names

Doi -> DOI
Url -> URL
Achilleas Koutsou %!s(int64=6) %!d(string=hai) anos
pai
achega
ef307232fb

+ 1 - 1
cmd/web.go

@@ -500,7 +500,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.

+ 1 - 1
models/models_gin.go

@@ -22,7 +22,7 @@ func StartIndexing(user, owner *User, repo *Repository) {
 		log.Trace("could not marshal index request :%+v", err)
 		return
 	}
-	req, _ := http.NewRequest(http.MethodPost, setting.Search.IndexUrl, bytes.NewReader(data))
+	req, _ := http.NewRequest(http.MethodPost, setting.Search.IndexURL, bytes.NewReader(data))
 	client := http.Client{}
 	resp, err := client.Do(req)
 	if err != nil || resp.StatusCode != http.StatusOK {

+ 11 - 12
pkg/setting/setting.go

@@ -117,7 +117,6 @@ var (
 	UseMSSQL      bool
 
 	// Repository settings
-	// Repository settingsS
 	Repository struct {
 		AnsiCharset              string
 		ForcePrivate             bool
@@ -333,19 +332,19 @@ var (
 
 	Search struct {
 		Do        bool
-		IndexUrl  string
-		SearchUrl string
+		IndexURL  string
+		SearchURL string
 	}
 
-	Doi struct {
+	DOI struct {
 		Do      bool
-		DoiUrl  string
-		DoiKey  string
-		DoiBase string
+		DOIURL  string
+		DOIKey  string
+		DOIBase string
 	}
 
-	CliConfig struct {
-		RsaHostKey string
+	CLIConfig struct {
+		RSAHostKey string
 	}
 
 	WebDav struct {
@@ -716,9 +715,9 @@ func NewContext() {
 		log.Fatal(2, "Failed to map Prometheus 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 {
-		log.Fatal(2, "Fail to map Doi settings: %v", err)
-	} else if err = Cfg.Section("cliconfig").MapTo(&CliConfig); 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)
 	} else if err = Cfg.Section("dav").MapTo(&WebDav); err != nil {
 		log.Fatal(2, "Fail to map WebDav settings: %v", err)

+ 4 - 4
routes/api/v1/misc/client.go

@@ -10,10 +10,10 @@ import (
 	log "gopkg.in/clog.v1"
 )
 
-type CliCongig struct {
-	RsaHostKey string
+type CLICongig struct {
+	RSAHostKey string
 }
-type ApiCliConfig struct {
+type APICLIConfig struct {
 	RSAKet  string
 	Weburl  string
 	Webport string
@@ -23,7 +23,7 @@ type ApiCliConfig struct {
 }
 
 func ClientC(c *context.APIContext) {
-	cf := ApiCliConfig{RSAKet: setting.CliConfig.RsaHostKey,
+	cf := APICLIConfig{RSAKet: setting.CLIConfig.RSAHostKey,
 		Weburl:  fmt.Sprintf("%s://%s", setting.Protocol, setting.Domain),
 		Webport: setting.HTTPPort, SSHUrl: setting.SSH.Domain, SSHPort: setting.SSH.Port,
 		SSHUser: setting.RunUser}

+ 1 - 1
routes/api/v1/search/general.go

@@ -27,7 +27,7 @@ func Search(c *context.APIContext) {
 		c.Status(http.StatusInternalServerError)
 		return
 	}
-	req, _ := http.NewRequest("Post", setting.Search.SearchUrl, bytes.NewReader(data))
+	req, _ := http.NewRequest("Post", setting.Search.SearchURL, bytes.NewReader(data))
 	cl := http.Client{}
 	resp, err := cl.Do(req)
 	if err != nil {

+ 1 - 1
routes/api/v1/search/suggest.go

@@ -26,7 +26,7 @@ func Suggest(c *context.APIContext) {
 		c.Status(http.StatusInternalServerError)
 		return
 	}
-	req, _ := http.NewRequest("Post", setting.Search.SearchUrl, bytes.NewReader(data))
+	req, _ := http.NewRequest("Post", setting.Search.SearchURL, bytes.NewReader(data))
 	cl := http.Client{}
 	resp, err := cl.Do(req)
 	if err != nil {

+ 3 - 3
routes/doi.go

@@ -14,19 +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.DOIKey), token)
 	if err != nil {
 		log.Error(0, "Could not encrypt Secret key:%s", err)
 		c.Status(http.StatusInternalServerError)
 		return
 	}
-	url := fmt.Sprintf("%s/?repo=%s&user=%s&token=%s", setting.Doi.DoiUrl, c.Repo.Repository.FullName(),
+	url := fmt.Sprintf("%s/?repo=%s&user=%s&token=%s", setting.DOI.DOIURL, 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.DOIBase)
 			//ddata, err := ginDoi.GDoiMData(doi, "https://api.datacite.org/works/") //todo configure URL?
 
 			c.Data["DOIReg"] = libgin.IsRegisteredDOI(doi)

+ 1 - 1
routes/search.go

@@ -36,7 +36,7 @@ func Search(c *context.Context, keywords string, sType int64) ([]byte, error) {
 		c.Status(http.StatusInternalServerError)
 		return nil, err
 	}
-	req, _ := http.NewRequest("Post", setting.Search.SearchUrl, bytes.NewReader(data))
+	req, _ := http.NewRequest("Post", setting.Search.SearchURL, bytes.NewReader(data))
 	cl := http.Client{}
 	resp, err := cl.Do(req)
 	if err != nil {