Skip to content

Commit

Permalink
Golint fixed for modules/setting (#262)
Browse files Browse the repository at this point in the history
* golint fixed for modules/setting

* typo fixed and renamed UNIXSOCKET to UnixSocket
  • Loading branch information
lunny authored Nov 27, 2016
1 parent 0a76d26 commit 94da472
Show file tree
Hide file tree
Showing 38 changed files with 178 additions and 167 deletions.
18 changes: 9 additions & 9 deletions cmd/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func newMacaron() *macaron.Macaron {
m.Use(gzip.Gziper())
}
if setting.Protocol == setting.FCGI {
m.SetURLPrefix(setting.AppSubUrl)
m.SetURLPrefix(setting.AppSubURL)
}
m.Use(macaron.Static(
path.Join(setting.StaticRootPath, "public"),
Expand Down Expand Up @@ -158,7 +158,7 @@ func newMacaron() *macaron.Macaron {
localFiles[name] = bindata.MustAsset("conf/locale/" + name)
}
m.Use(i18n.I18n(i18n.Options{
SubURL: setting.AppSubUrl,
SubURL: setting.AppSubURL,
Files: localFiles,
CustomDirectory: path.Join(setting.CustomPath, "conf/locale"),
Langs: setting.Langs,
Expand All @@ -172,15 +172,15 @@ func newMacaron() *macaron.Macaron {
Interval: setting.CacheInterval,
}))
m.Use(captcha.Captchaer(captcha.Options{
SubURL: setting.AppSubUrl,
SubURL: setting.AppSubURL,
}))
m.Use(session.Sessioner(setting.SessionConfig))
m.Use(csrf.Csrfer(csrf.Options{
Secret: setting.SecretKey,
Cookie: setting.CSRFCookieName,
SetCookie: true,
Header: "X-Csrf-Token",
CookiePath: setting.AppSubUrl,
CookiePath: setting.AppSubURL,
}))
m.Use(toolbox.Toolboxer(m, toolbox.Options{
HealthCheckFuncs: []*toolbox.HealthCheckFuncDesc{
Expand Down Expand Up @@ -216,7 +216,7 @@ func runWeb(ctx *cli.Context) error {
m.Get("/", ignSignIn, routers.Home)
m.Group("/explore", func() {
m.Get("", func(ctx *context.Context) {
ctx.Redirect(setting.AppSubUrl + "/explore/repos")
ctx.Redirect(setting.AppSubURL + "/explore/repos")
})
m.Get("/repos", routers.ExploreRepos)
m.Get("/users", routers.ExploreUsers)
Expand Down Expand Up @@ -635,17 +635,17 @@ func runWeb(ctx *cli.Context) error {

// Flag for port number in case first time run conflict.
if ctx.IsSet("port") {
setting.AppUrl = strings.Replace(setting.AppUrl, setting.HTTPPort, ctx.String("port"), 1)
setting.AppURL = strings.Replace(setting.AppURL, setting.HTTPPort, ctx.String("port"), 1)
setting.HTTPPort = ctx.String("port")
}

var listenAddr string
if setting.Protocol == setting.UNIX_SOCKET {
if setting.Protocol == setting.UnixSocket {
listenAddr = fmt.Sprintf("%s", setting.HTTPAddr)
} else {
listenAddr = fmt.Sprintf("%s:%s", setting.HTTPAddr, setting.HTTPPort)
}
log.Info("Listen: %v://%s%s", setting.Protocol, listenAddr, setting.AppSubUrl)
log.Info("Listen: %v://%s%s", setting.Protocol, listenAddr, setting.AppSubURL)

var err error
switch setting.Protocol {
Expand All @@ -656,7 +656,7 @@ func runWeb(ctx *cli.Context) error {
err = server.ListenAndServeTLS(setting.CertFile, setting.KeyFile)
case setting.FCGI:
err = fcgi.Serve(nil, m)
case setting.UNIX_SOCKET:
case setting.UnixSocket:
os.Remove(listenAddr)

var listener *net.UnixListener
Expand Down
6 changes: 3 additions & 3 deletions models/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ func (a *Action) ShortRepoPath() string {

// GetRepoLink returns relative link to action repository.
func (a *Action) GetRepoLink() string {
if len(setting.AppSubUrl) > 0 {
return path.Join(setting.AppSubUrl, a.GetRepoPath())
if len(setting.AppSubURL) > 0 {
return path.Join(setting.AppSubURL, a.GetRepoPath())
}
return "/" + a.GetRepoPath()
}
Expand Down Expand Up @@ -546,7 +546,7 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
Ref: opts.RefFullName,
Before: opts.OldCommitID,
After: opts.NewCommitID,
CompareURL: setting.AppUrl + opts.Commits.CompareURL,
CompareURL: setting.AppURL + opts.Commits.CompareURL,
Commits: opts.Commits.ToAPIPayloadCommits(repo.HTMLURL()),
Repo: apiRepo,
Pusher: apiPusher,
Expand Down
2 changes: 1 addition & 1 deletion models/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository) (err error
Ref: git.BRANCH_PREFIX + pr.BaseBranch,
Before: pr.MergeBase,
After: pr.MergedCommitID,
CompareURL: setting.AppUrl + pr.BaseRepo.ComposeCompareURL(pr.MergeBase, pr.MergedCommitID),
CompareURL: setting.AppURL + pr.BaseRepo.ComposeCompareURL(pr.MergeBase, pr.MergedCommitID),
Commits: ListToPushCommits(l).ToAPIPayloadCommits(pr.BaseRepo.HTMLURL()),
Repo: pr.BaseRepo.APIFormat(nil),
Pusher: pr.HeadRepo.MustOwner().APIFormat(),
Expand Down
6 changes: 3 additions & 3 deletions models/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func (repo *Repository) FullName() string {
}

func (repo *Repository) HTMLURL() string {
return setting.AppUrl + repo.FullName()
return setting.AppURL + repo.FullName()
}

// Arguments that are allowed to be nil: permission
Expand Down Expand Up @@ -412,7 +412,7 @@ func (repo *Repository) RelLink() string {
}

func (repo *Repository) Link() string {
return setting.AppSubUrl + "/" + repo.FullName()
return setting.AppSubURL + "/" + repo.FullName()
}

func (repo *Repository) ComposeCompareURL(oldCommitID, newCommitID string) string {
Expand Down Expand Up @@ -550,7 +550,7 @@ type CloneLink struct {

// ComposeHTTPSCloneURL returns HTTPS clone URL based on given owner and repository name.
func ComposeHTTPSCloneURL(owner, repo string) string {
return fmt.Sprintf("%s%s/%s.git", setting.AppUrl, owner, repo)
return fmt.Sprintf("%s%s/%s.git", setting.AppURL, owner, repo)
}

func (repo *Repository) cloneLink(isWiki bool) *CloneLink {
Expand Down
14 changes: 7 additions & 7 deletions models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,14 @@ func (u *User) CanImportLocal() bool {
// DashboardLink returns the user dashboard page link.
func (u *User) DashboardLink() string {
if u.IsOrganization() {
return setting.AppSubUrl + "/org/" + u.Name + "/dashboard/"
return setting.AppSubURL + "/org/" + u.Name + "/dashboard/"
}
return setting.AppSubUrl + "/"
return setting.AppSubURL + "/"
}

// HomeLink returns the user or organization home page link.
func (u *User) HomeLink() string {
return setting.AppSubUrl + "/" + u.Name
return setting.AppSubURL + "/" + u.Name
}

// GenerateEmailActivateCode generates an activate code based on user information and given e-mail.
Expand Down Expand Up @@ -261,7 +261,7 @@ func (u *User) GenerateRandomAvatar() error {
// which includes app sub-url as prefix. However, it is possible
// to return full URL if user enables Gravatar-like service.
func (u *User) RelAvatarLink() string {
defaultImgUrl := setting.AppSubUrl + "/img/avatar_default.png"
defaultImgUrl := setting.AppSubURL + "/img/avatar_default.png"
if u.ID == -1 {
return defaultImgUrl
}
Expand All @@ -271,15 +271,15 @@ func (u *User) RelAvatarLink() string {
if !com.IsExist(u.CustomAvatarPath()) {
return defaultImgUrl
}
return setting.AppSubUrl + "/avatars/" + com.ToStr(u.ID)
return setting.AppSubURL + "/avatars/" + com.ToStr(u.ID)
case setting.DisableGravatar, setting.OfflineMode:
if !com.IsExist(u.CustomAvatarPath()) {
if err := u.GenerateRandomAvatar(); err != nil {
log.Error(3, "GenerateRandomAvatar: %v", err)
}
}

return setting.AppSubUrl + "/avatars/" + com.ToStr(u.ID)
return setting.AppSubURL + "/avatars/" + com.ToStr(u.ID)
}
return base.AvatarLink(u.AvatarEmail)
}
Expand All @@ -288,7 +288,7 @@ func (u *User) RelAvatarLink() string {
func (u *User) AvatarLink() string {
link := u.RelAvatarLink()
if link[0] == '/' && link[1] != '/' {
return setting.AppUrl + strings.TrimPrefix(link, setting.AppSubUrl)[1:]
return setting.AppURL + strings.TrimPrefix(link, setting.AppSubURL)[1:]
}
return link
}
Expand Down
4 changes: 2 additions & 2 deletions models/webhook_slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func getSlackPushPayload(p *api.PushPayload, slack *SlackMeta) (*SlackPayload, e
}

func getSlackPullRequestPayload(p *api.PullRequestPayload, slack *SlackMeta) (*SlackPayload, error) {
senderLink := SlackLinkFormatter(setting.AppUrl+p.Sender.UserName, p.Sender.UserName)
senderLink := SlackLinkFormatter(setting.AppURL+p.Sender.UserName, p.Sender.UserName)
titleLink := SlackLinkFormatter(fmt.Sprintf("%s/pulls/%d", p.Repository.HTMLURL, p.Index),
fmt.Sprintf("#%d %s", p.Index, p.PullRequest.Title))
var text, title, attachmentText string
Expand All @@ -164,7 +164,7 @@ func getSlackPullRequestPayload(p *api.PullRequestPayload, slack *SlackMeta) (*S
attachmentText = SlackTextFormatter(p.PullRequest.Body)
case api.HookIssueAssigned:
text = fmt.Sprintf("[%s] Pull request assigned to %s: %s by %s", p.Repository.FullName,
SlackLinkFormatter(setting.AppUrl+p.PullRequest.Assignee.UserName, p.PullRequest.Assignee.UserName),
SlackLinkFormatter(setting.AppURL+p.PullRequest.Assignee.UserName, p.PullRequest.Assignee.UserName),
titleLink, senderLink)
case api.HookIssueUnassigned:
text = fmt.Sprintf("[%s] Pull request unassigned: %s by %s", p.Repository.FullName, titleLink, senderLink)
Expand Down
2 changes: 1 addition & 1 deletion modules/base/tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func AvatarLink(email string) string {
return setting.GravatarSource + HashEmail(email)
}

return setting.AppSubUrl + "/img/avatar_default.png"
return setting.AppSubURL + "/img/avatar_default.png"
}

// Seconds-based time units
Expand Down
8 changes: 4 additions & 4 deletions modules/context/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ func (ctx *APIContext) SetLinkHeader(total, pageSize int) {
page := paginater.New(total, pageSize, ctx.QueryInt("page"), 0)
links := make([]string, 0, 4)
if page.HasNext() {
links = append(links, fmt.Sprintf("<%s%s?page=%d>; rel=\"next\"", setting.AppUrl, ctx.Req.URL.Path[1:], page.Next()))
links = append(links, fmt.Sprintf("<%s%s?page=%d>; rel=\"next\"", setting.AppURL, ctx.Req.URL.Path[1:], page.Next()))
}
if !page.IsLast() {
links = append(links, fmt.Sprintf("<%s%s?page=%d>; rel=\"last\"", setting.AppUrl, ctx.Req.URL.Path[1:], page.TotalPages()))
links = append(links, fmt.Sprintf("<%s%s?page=%d>; rel=\"last\"", setting.AppURL, ctx.Req.URL.Path[1:], page.TotalPages()))
}
if !page.IsFirst() {
links = append(links, fmt.Sprintf("<%s%s?page=1>; rel=\"first\"", setting.AppUrl, ctx.Req.URL.Path[1:]))
links = append(links, fmt.Sprintf("<%s%s?page=1>; rel=\"first\"", setting.AppURL, ctx.Req.URL.Path[1:]))
}
if page.HasPrevious() {
links = append(links, fmt.Sprintf("<%s%s?page=%d>; rel=\"prev\"", setting.AppUrl, ctx.Req.URL.Path[1:], page.Previous()))
links = append(links, fmt.Sprintf("<%s%s?page=%d>; rel=\"prev\"", setting.AppURL, ctx.Req.URL.Path[1:], page.Previous()))
}

if len(links) > 0 {
Expand Down
16 changes: 8 additions & 8 deletions modules/context/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func Toggle(options *ToggleOptions) macaron.Handler {
return func(ctx *Context) {
// Cannot view any page before installation.
if !setting.InstallLock {
ctx.Redirect(setting.AppSubUrl + "/install")
ctx.Redirect(setting.AppSubURL + "/install")
return
}

Expand All @@ -38,14 +38,14 @@ func Toggle(options *ToggleOptions) macaron.Handler {
}

// Check non-logged users landing page.
if !ctx.IsSigned && ctx.Req.RequestURI == "/" && setting.LandingPageURL != setting.LANDING_PAGE_HOME {
ctx.Redirect(setting.AppSubUrl + string(setting.LandingPageURL))
if !ctx.IsSigned && ctx.Req.RequestURI == "/" && setting.LandingPageURL != setting.LandingPageHome {
ctx.Redirect(setting.AppSubURL + string(setting.LandingPageURL))
return
}

// Redirect to dashboard if user tries to visit any non-login page.
if options.SignOutRequired && ctx.IsSigned && ctx.Req.RequestURI != "/" {
ctx.Redirect(setting.AppSubUrl + "/")
ctx.Redirect(setting.AppSubURL + "/")
return
}

Expand All @@ -66,8 +66,8 @@ func Toggle(options *ToggleOptions) macaron.Handler {
return
}

ctx.SetCookie("redirect_to", url.QueryEscape(setting.AppSubUrl+ctx.Req.RequestURI), 0, setting.AppSubUrl)
ctx.Redirect(setting.AppSubUrl + "/user/login")
ctx.SetCookie("redirect_to", url.QueryEscape(setting.AppSubURL+ctx.Req.RequestURI), 0, setting.AppSubURL)
ctx.Redirect(setting.AppSubURL + "/user/login")
return
} else if !ctx.User.IsActive && setting.Service.RegisterEmailConfirm {
ctx.Data["Title"] = ctx.Tr("auth.active_your_account")
Expand All @@ -79,8 +79,8 @@ func Toggle(options *ToggleOptions) macaron.Handler {
// Redirect to log in page if auto-signin info is provided and has not signed in.
if !options.SignOutRequired && !ctx.IsSigned && !auth.IsAPIPath(ctx.Req.URL.Path) &&
len(ctx.GetCookie(setting.CookieUserName)) > 0 {
ctx.SetCookie("redirect_to", url.QueryEscape(setting.AppSubUrl+ctx.Req.RequestURI), 0, setting.AppSubUrl)
ctx.Redirect(setting.AppSubUrl + "/user/login")
ctx.SetCookie("redirect_to", url.QueryEscape(setting.AppSubURL+ctx.Req.RequestURI), 0, setting.AppSubURL)
ctx.Redirect(setting.AppSubURL + "/user/login")
return
}

Expand Down
2 changes: 1 addition & 1 deletion modules/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func Contexter() macaron.Handler {
Org: &Organization{},
}
// Compute current URL for real-time change language.
ctx.Data["Link"] = setting.AppSubUrl + strings.TrimSuffix(ctx.Req.URL.Path, "/")
ctx.Data["Link"] = setting.AppSubURL + strings.TrimSuffix(ctx.Req.URL.Path, "/")

ctx.Data["PageStartTime"] = time.Now()

Expand Down
2 changes: 1 addition & 1 deletion modules/context/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func HandleOrgAssignment(ctx *Context, args ...bool) {
ctx.Data["IsOrganizationOwner"] = ctx.Org.IsOwner
ctx.Data["IsOrganizationMember"] = ctx.Org.IsMember

ctx.Org.OrgLink = setting.AppSubUrl + "/org/" + org.Name
ctx.Org.OrgLink = setting.AppSubURL + "/org/" + org.Name
ctx.Data["OrgLink"] = ctx.Org.OrgLink

// Team.
Expand Down
4 changes: 2 additions & 2 deletions modules/context/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func RetrieveBaseRepo(ctx *Context, repo *models.Repository) {

// composeGoGetImport returns go-get-import meta content.
func composeGoGetImport(owner, repo string) string {
return path.Join(setting.Domain, setting.AppSubUrl, owner, repo)
return path.Join(setting.Domain, setting.AppSubURL, owner, repo)
}

// earlyResponseForGoGetMeta responses appropriate go-get meta with status 200
Expand Down Expand Up @@ -331,7 +331,7 @@ func RepoAssignment(args ...bool) macaron.Handler {

if ctx.Query("go-get") == "1" {
ctx.Data["GoGetImport"] = composeGoGetImport(owner.Name, repo.Name)
prefix := setting.AppUrl + path.Join(owner.Name, repo.Name, "src", ctx.Repo.BranchName)
prefix := setting.AppURL + path.Join(owner.Name, repo.Name, "src", ctx.Repo.BranchName)
ctx.Data["GoDocDirectory"] = prefix + "{/dir}"
ctx.Data["GoDocFile"] = prefix + "{/dir}/{file}#L{line}"
}
Expand Down
6 changes: 3 additions & 3 deletions modules/markdown/markdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (r *Renderer) AutoLink(out *bytes.Buffer, link []byte, kind int) {

// Since this method could only possibly serve one link at a time,
// we do not need to find all.
if bytes.HasPrefix(link, []byte(setting.AppUrl)) {
if bytes.HasPrefix(link, []byte(setting.AppURL)) {
m := CommitPattern.Find(link)
if m != nil {
m = bytes.TrimSpace(m)
Expand Down Expand Up @@ -225,7 +225,7 @@ func cutoutVerbosePrefix(prefix string) string {
if prefix[i] == '/' {
count++
}
if count >= 3+setting.AppSubUrlDepth {
if count >= 3+setting.AppSubURLDepth {
return prefix[:i]
}
}
Expand Down Expand Up @@ -279,7 +279,7 @@ func RenderSpecialLink(rawBytes []byte, urlPrefix string, metas map[string]strin
for _, m := range ms {
m = m[bytes.Index(m, []byte("@")):]
rawBytes = bytes.Replace(rawBytes, m,
[]byte(fmt.Sprintf(`<a href="%s/%s">%s</a>`, setting.AppSubUrl, m[1:], m)), -1)
[]byte(fmt.Sprintf(`<a href="%s/%s">%s</a>`, setting.AppSubURL, m[1:], m)), -1)
}

rawBytes = RenderIssueIndexPattern(rawBytes, urlPrefix, metas)
Expand Down
6 changes: 3 additions & 3 deletions modules/markdown/markdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestMarkdown(t *testing.T) {
urlPrefix = "/prefix"
metas map[string]string = nil
)
setting.AppSubUrlDepth = 0
setting.AppSubURLDepth = 0

Convey("To the internal issue tracker", func() {
Convey("It should not render anything when there are no mentions", func() {
Expand Down Expand Up @@ -237,7 +237,7 @@ func TestMarkdown(t *testing.T) {
})

Convey("Rendering an issue URL", t, func() {
setting.AppUrl = "http://localhost:3000/"
setting.AppURL = "http://localhost:3000/"
htmlFlags := 0
htmlFlags |= blackfriday.HTML_SKIP_STYLE
htmlFlags |= blackfriday.HTML_OMIT_CONTENTS
Expand Down Expand Up @@ -279,7 +279,7 @@ func TestMarkdown(t *testing.T) {
})

Convey("Rendering a commit URL", t, func() {
setting.AppUrl = "http://localhost:3000/"
setting.AppURL = "http://localhost:3000/"
htmlFlags := 0
htmlFlags |= blackfriday.HTML_SKIP_STYLE
htmlFlags |= blackfriday.HTML_OMIT_CONTENTS
Expand Down
Loading

0 comments on commit 94da472

Please sign in to comment.