diff options
author | Unknown <joe2010xtmf@163.com> | 2014-04-27 01:05:13 -0600 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-04-27 01:05:13 -0600 |
commit | 62d23e91541550d0478c4884696e918a0e818b4f (patch) | |
tree | 335e18b41b15a419233e5117d1cbc43fa66f2b5c | |
parent | 59d0e73c3507296b31c8e741b44afc7bfe1eb695 (diff) | |
download | gitea-62d23e91541550d0478c4884696e918a0e818b4f.tar.gz gitea-62d23e91541550d0478c4884696e918a0e818b4f.zip |
HTTP no follow and offline mode
-rw-r--r-- | conf/app.ini | 2 | ||||
-rw-r--r-- | gogs.go | 2 | ||||
-rw-r--r-- | models/repo.go | 16 | ||||
-rw-r--r-- | models/update.go | 8 | ||||
-rw-r--r-- | modules/base/conf.go | 18 | ||||
-rw-r--r-- | modules/base/template.go | 10 | ||||
-rw-r--r-- | routers/admin/admin.go | 2 | ||||
-rw-r--r-- | routers/install.go | 2 | ||||
-rw-r--r-- | templates/admin/config.tmpl | 4 | ||||
-rw-r--r-- | templates/base/head.tmpl | 2 | ||||
-rw-r--r-- | templates/base/navbar.tmpl | 6 | ||||
-rw-r--r-- | templates/release/list.tmpl | 36 | ||||
-rw-r--r-- | templates/repo/commits.tmpl | 4 | ||||
-rw-r--r-- | templates/repo/nav.tmpl | 4 | ||||
-rw-r--r-- | templates/repo/single_file.tmpl | 4 | ||||
-rw-r--r-- | templates/repo/single_list.tmpl | 2 | ||||
-rw-r--r-- | templates/user/profile.tmpl | 6 |
17 files changed, 54 insertions, 74 deletions
diff --git a/conf/app.ini b/conf/app.ini index 25fd41091f..e7174e2251 100644 --- a/conf/app.ini +++ b/conf/app.ini @@ -16,6 +16,8 @@ LICENSES = Apache v2 License|GPL v2|MIT License|Affero GPL|Artistic License 2.0| PROTOCOL = http DOMAIN = localhost ROOT_URL = %(PROTOCOL)s://%(DOMAIN)s:%(HTTP_PORT)s/ +; Disable CDN even in "prod" mode +OFFLINE_MODE = false HTTP_ADDR = HTTP_PORT = 3000 ; Generate steps: @@ -19,7 +19,7 @@ import ( // Test that go1.2 tag above is included in builds. main.go refers to this definition. const go12tag = true -const APP_VER = "0.3.0.0426 Alpha" +const APP_VER = "0.3.0.0427 Alpha" func init() { base.AppVer = APP_VER diff --git a/models/repo.go b/models/repo.go index 2457174372..5f66bca86d 100644 --- a/models/repo.go +++ b/models/repo.go @@ -159,9 +159,7 @@ func MirrorUpdate() { repoPath := filepath.Join(base.RepoRootPath, m.RepoName+".git") _, stderr, err := com.ExecCmdDir(repoPath, "git", "remote", "update") if err != nil { - return err - } else if strings.Contains(stderr, "fatal:") { - return errors.New(stderr) + return errors.New("git remote update: " + stderr) } else if err = git.UnpackRefs(repoPath); err != nil { return err } @@ -177,9 +175,7 @@ func MirrorUpdate() { func MirrorRepository(repoId int64, userName, repoName, repoPath, url string) error { _, stderr, err := com.ExecCmd("git", "clone", "--mirror", url, repoPath) if err != nil { - return err - } else if strings.Contains(stderr, "fatal:") { - return errors.New(stderr) + return errors.New("git clone --mirror: " + stderr) } if _, err = orm.InsertOne(&Mirror{ @@ -219,23 +215,17 @@ func MigrateRepository(user *User, name, desc string, private, mirror bool, url // Clone from local repository. _, stderr, err := com.ExecCmd("git", "clone", repoPath, tmpDir) if err != nil { - return repo, err - } else if strings.Contains(stderr, "fatal:") { return repo, errors.New("git clone: " + stderr) } // Pull data from source. _, stderr, err = com.ExecCmdDir(tmpDir, "git", "pull", url) if err != nil { - return repo, err - } else if strings.Contains(stderr, "fatal:") { return repo, errors.New("git pull: " + stderr) } // Push data to local repository. if _, stderr, err = com.ExecCmdDir(tmpDir, "git", "push", "origin", "master"); err != nil { - return repo, err - } else if strings.Contains(stderr, "fatal:") { return repo, errors.New("git push: " + stderr) } @@ -429,8 +419,6 @@ func initRepository(f string, user *User, repo *Repository, initReadme bool, rep _, stderr, err := com.ExecCmd("git", "clone", repoPath, tmpDir) if err != nil { - return err - } else if strings.Contains(stderr, "fatal:") { return errors.New("git clone: " + stderr) } diff --git a/models/update.go b/models/update.go index 2f59547b72..648c45f160 100644 --- a/models/update.go +++ b/models/update.go @@ -1,3 +1,7 @@ +// Copyright 2014 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + package models import ( @@ -5,9 +9,11 @@ import ( "os/exec" "strings" + qlog "github.com/qiniu/log" + "github.com/gogits/git" + "github.com/gogits/gogs/modules/base" - qlog "github.com/qiniu/log" ) func Update(refName, oldCommitId, newCommitId, userName, repoName string, userId int64) { diff --git a/modules/base/conf.go b/modules/base/conf.go index 17b55316a8..cfc85ff51e 100644 --- a/modules/base/conf.go +++ b/modules/base/conf.go @@ -45,14 +45,15 @@ type Oauther struct { } var ( - AppVer string - AppName string - AppLogo string - AppUrl string - IsProdMode bool - Domain string - SecretKey string - RunUser string + AppVer string + AppName string + AppLogo string + AppUrl string + OfflineMode bool + ProdMode bool + Domain string + SecretKey string + RunUser string RepoRootPath string ScriptType string @@ -325,6 +326,7 @@ func NewConfigContext() { AppLogo = Cfg.MustValue("", "APP_LOGO", "img/favicon.png") AppUrl = Cfg.MustValue("server", "ROOT_URL") Domain = Cfg.MustValue("server", "DOMAIN") + OfflineMode = Cfg.MustBool("server", "OFFLINE_MODE", false) SecretKey = Cfg.MustValue("security", "SECRET_KEY") InstallLock = Cfg.MustBool("security", "INSTALL_LOCK", false) diff --git a/modules/base/template.go b/modules/base/template.go index 79aeeb9d77..dd98df75b1 100644 --- a/modules/base/template.go +++ b/modules/base/template.go @@ -56,8 +56,8 @@ var TemplateFuncs template.FuncMap = map[string]interface{}{ "AppDomain": func() string { return Domain }, - "IsProdMode": func() bool { - return IsProdMode + "CdnMode": func() bool { + return ProdMode && !OfflineMode }, "LoadTimes": func(startTime time.Time) string { return fmt.Sprint(time.Since(startTime).Nanoseconds()/1e6) + "ms" @@ -124,11 +124,11 @@ func ActionIcon(opType int) string { const ( TPL_CREATE_REPO = `<a href="/user/%s">%s</a> created repository <a href="/%s">%s</a>` TPL_COMMIT_REPO = `<a href="/user/%s">%s</a> pushed to <a href="/%s/src/%s">%s</a> at <a href="/%s">%s</a>%s` - TPL_COMMIT_REPO_LI = `<div><img src="%s?s=16" alt="user-avatar"/> <a href="/%s/commit/%s">%s</a> %s</div>` + TPL_COMMIT_REPO_LI = `<div><img src="%s?s=16" alt="user-avatar"/> <a href="/%s/commit/%s" rel="nofollow">%s</a> %s</div>` TPL_CREATE_ISSUE = `<a href="/user/%s">%s</a> opened issue <a href="/%s/issues/%s">%s#%s</a> <div><img src="%s?s=16" alt="user-avatar"/> %s</div>` TPL_TRANSFER_REPO = `<a href="/user/%s">%s</a> transfered repository <code>%s</code> to <a href="/%s">%s</a>` - TPL_PUSH_TAG = `<a href="/user/%s">%s</a> pushed tag <a href="/%s/src/%s">%s</a> at <a href="/%s">%s</a>` + TPL_PUSH_TAG = `<a href="/user/%s">%s</a> pushed tag <a href="/%s/src/%s" rel="nofollow">%s</a> at <a href="/%s">%s</a>` ) type PushCommit struct { @@ -165,7 +165,7 @@ func ActionDesc(act Actioner) string { buf.WriteString(fmt.Sprintf(TPL_COMMIT_REPO_LI, AvatarLink(commit.AuthorEmail), repoLink, commit.Sha1, commit.Sha1[:7], commit.Message) + "\n") } if push.Len > 3 { - buf.WriteString(fmt.Sprintf(`<div><a href="/%s/%s/commits/%s">%d other commits >></a></div>`, actUserName, repoName, branch, push.Len)) + buf.WriteString(fmt.Sprintf(`<div><a href="/%s/%s/commits/%s" rel="nofollow">%d other commits >></a></div>`, actUserName, repoName, branch, push.Len)) } return fmt.Sprintf(TPL_COMMIT_REPO, actUserName, actUserName, repoLink, branch, branch, repoLink, repoLink, buf.String()) diff --git a/routers/admin/admin.go b/routers/admin/admin.go index d0f737e645..fddd830185 100644 --- a/routers/admin/admin.go +++ b/routers/admin/admin.go @@ -139,9 +139,11 @@ func Config(ctx *middleware.Context) { ctx.Data["AppUrl"] = base.AppUrl ctx.Data["Domain"] = base.Domain + ctx.Data["OfflineMode"] = base.OfflineMode ctx.Data["RunUser"] = base.RunUser ctx.Data["RunMode"] = strings.Title(martini.Env) ctx.Data["RepoRootPath"] = base.RepoRootPath + ctx.Data["ScriptType"] = base.ScriptType ctx.Data["Service"] = base.Service diff --git a/routers/install.go b/routers/install.go index 8ffa9b5d1a..38bf896f4e 100644 --- a/routers/install.go +++ b/routers/install.go @@ -30,7 +30,7 @@ func checkRunMode() { switch base.Cfg.MustValue("", "RUN_MODE") { case "prod": martini.Env = martini.Prod - base.IsProdMode = true + base.ProdMode = true case "test": martini.Env = martini.Test } diff --git a/templates/admin/config.tmpl b/templates/admin/config.tmpl index d25d40275a..b2b25e90f6 100644 --- a/templates/admin/config.tmpl +++ b/templates/admin/config.tmpl @@ -18,6 +18,8 @@ <dd>{{.AppUrl}}</dd> <dt>Domain</dt> <dd>{{.Domain}}</dd> + <dt>Offline Mode</dt> + <dd><i class="fa fa{{if .OfflineMode}}-check{{end}}-square-o"></i></dd> <hr/> <dt>Run User</dt> <dd>{{.RunUser}}</dd> @@ -26,6 +28,8 @@ <hr/> <dt>Repository Root Path</dt> <dd>{{.RepoRootPath}}</dd> + <dt>Script Type</dt> + <dd>{{.ScriptType}}</dd> </dl> </div> </div> diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index 68231391c0..6794b0171e 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -12,7 +12,7 @@ {{if .Repository.IsGoget}}<meta name="go-import" content="{{.GoGetImport}} git {{.CloneLink.HTTPS}}">{{end}} <!-- Stylesheets --> - {{if IsProdMode}} + {{if CdnMode}} <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"> <link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet"> diff --git a/templates/base/navbar.tmpl b/templates/base/navbar.tmpl index 932cae36d4..b8cba5faa6 100644 --- a/templates/base/navbar.tmpl +++ b/templates/base/navbar.tmpl @@ -3,7 +3,7 @@ <nav class="nav"> <a id="nav-logo" class="nav-item pull-left{{if .PageIsHome}} active{{end}}" href="/"><img src="/img/favicon.png" alt="Gogs Logo" id="logo"></a> <a class="nav-item pull-left{{if .PageIsUserDashboard}} active{{end}}" href="/">Dashboard</a> - <a class="nav-item pull-left{{if .PageIsHelp}} active{{end}}" href="https://github.com/gogits/gogs/wiki">Help</a>{{if .IsSigned}} + <a class="nav-item pull-left{{if .PageIsHelp}} active{{end}}" target="_blank" href="https://github.com/gogits/gogs/wiki">Help</a>{{if .IsSigned}} {{if .HasAccess}}<!-- <form class="nav-item pull-left{{if .PageIsNewRepo}} active{{end}}" id="nav-search-form"> <div class="input-group"> <div class="input-group-btn"> @@ -33,8 +33,8 @@ </ul> </div> </div> - {{else}}<a id="nav-signin" class="nav-item navbar-right navbar-btn btn btn-danger" href="/user/login/">Sign In</a> - <a id="nav-signup" class="nav-item navbar-right" href="/user/sign_up/">Sign Up</a>{{end}} + {{else}}<a id="nav-signin" class="nav-item navbar-right navbar-btn btn btn-danger" href="/user/login/" rel="nofollow">Sign In</a> + <a id="nav-signup" class="nav-item navbar-right" href="/user/sign_up/" rel="nofollow">Sign Up</a>{{end}} </nav> </div> </div> diff --git a/templates/release/list.tmpl b/templates/release/list.tmpl index dd37e9c1a2..11f96aa548 100644 --- a/templates/release/list.tmpl +++ b/templates/release/list.tmpl @@ -15,8 +15,8 @@ {{if .PublisherId}} <div class="col-md-2 text-right"> {{if .IsPrerelease}}<span class="btn btn-warning status pre-release">Pre-Release</span>{{else}}<span class="btn btn-success status stable">Stable</span>{{end}} - <a class="tag" href="{{$.RepoLink}}/src/{{.TagName}}"><i class="fa fa-tag"></i>{{.TagName}}</a> - <a class="commit" href="{{$.RepoLink}}/src/{{.SHA1}}"><i class="fa fa-code"></i>{{ShortSha .SHA1}}</a> + <a class="tag" href="{{$.RepoLink}}/src/{{.TagName}}" rel="nofollow"><i class="fa fa-tag"></i>{{.TagName}}</a> + <a class="commit" href="{{$.RepoLink}}/src/{{.SHA1}}" rel="nofollow"><i class="fa fa-code"></i>{{ShortSha .SHA1}}</a> </div> <div class="col-md-10"> <h4 class="title"><a href="{{$.RepoLink}}/src/{{.TagName}}">{{.Title}}</a></h4> @@ -30,19 +30,19 @@ {{str2html .Note}} </div> <p class="download"> - <a class="btn btn-default" href="{{$.RepoLink}}/archive/{{.TagName}}/{{$.Repository.Name}}.zip"><i class="fa fa-download"></i>Source Code (ZIP)</a> + <a class="btn btn-default" href="{{$.RepoLink}}/archive/{{.TagName}}/{{$.Repository.Name}}.zip" rel="nofollow"><i class="fa fa-download"></i>Source Code (ZIP)</a> <!-- <a class="btn btn-default" href="{release_download_link}"><i class="fa fa-download"></i>Source Code (TAR.GZ)</a> --> </p> <span class="dot"> </span> </div> {{else}} <div class="col-md-2 text-right"> - <a class="commit" href="{{$.RepoLink}}/src/{{.SHA1}}"><i class="fa fa-code"></i>{{ShortSha .SHA1}}</a> + <a class="commit" href="{{$.RepoLink}}/src/{{.SHA1}}" rel="nofollow"><i class="fa fa-code"></i>{{ShortSha .SHA1}}</a> </div> <div class="col-md-10"> - <h5 class="title"><a href="{{$.RepoLink}}/src/{{.TagName}}">{{.TagName}}</a><i class="fa fa-tag"></i></h5> + <h5 class="title"><a href="{{$.RepoLink}}/src/{{.TagName}}" rel="nofollow">{{.TagName}}</a><i class="fa fa-tag"></i></h5> <p class="download"> - <a class="download-link" href="{{$.RepoLink}}/archive/{{.TagName}}/{{$.Repository.Name}}.zip"><i class="fa fa-download"></i>zip</a> + <a class="download-link" href="{{$.RepoLink}}/archive/{{.TagName}}/{{$.Repository.Name}}.zip" rel="nofollow"><i class="fa fa-download"></i>zip</a> <!-- <a class="download-link" href="{release_download_link}"><i class="fa fa-download"></i>tar.gz</a> --> </p> <span class="dot"> </span> @@ -50,30 +50,6 @@ {{end}} </li> {{end}} - <!-- <li class="release-item clearfix" id="release-{release_id}"> - <div class="col-md-2 text-right"> - <span class="btn btn-warning status pre-release">Pre-Release</span> - <a class="tag" href="{commit_link}"><i class="fa fa-tag"></i>release tag</a> - <a class="commit" href="{commit_link}"><i class="fa fa-code"></i>commit-sha</a> - </div> - <div class="col-md-10"> - <h4 class="title"><a href="{release_single_link}">Release Title</a></h4> - <p class="info"> - <span class="author"><img class="avatar" src="http://1.gravatar.com/avatar/f72f7454ce9d710baa506394f68f4132" alt="" width="20"> - <a href="/user/fuxiaohei">fuxiaohei</a></span> - <span class="time">1 week ago</span> - <span class="ahead"><strong>0</strong> commits since this tag</span> - </p> - <div class="markdown desc"> - release descriptions, support markdown content - </div> - <p class="download"> - <a class="btn btn-default" href="{release_download_link}"><i class="fa fa-download"></i>Source Code (ZIP)</a> - <a class="btn btn-default" href="{release_download_link}"><i class="fa fa-download"></i>Source Code (TAR.GZ)</a> - </p> - <span class="dot"> </span> - </div> - </li> --> </ul> </div> </div> diff --git a/templates/repo/commits.tmpl b/templates/repo/commits.tmpl index b14c6bc8c6..bfc0bf21bf 100644 --- a/templates/repo/commits.tmpl +++ b/templates/repo/commits.tmpl @@ -41,8 +41,8 @@ </table> </div> {{if not .IsSearchPage}}<ul class="pagination" id="commits-pager"> - {{if .LastPageNum}}<li><a href="{{.RepoLink}}/commits/{{.BranchName}}?p={{.LastPageNum}}">« Newer</a></li>{{end}} - {{if .NextPageNum}}<li><a href="{{.RepoLink}}/commits/{{.BranchName}}?p={{.NextPageNum}}">» Older</a></li>{{end}} + {{if .LastPageNum}}<li><a href="{{.RepoLink}}/commits/{{.BranchName}}?p={{.LastPageNum}}" rel="nofollow">« Newer</a></li>{{end}} + {{if .NextPageNum}}<li><a href="{{.RepoLink}}/commits/{{.BranchName}}?p={{.NextPageNum}}" rel="nofollow">» Older</a></li>{{end}} </ul>{{end}} </div> </div> diff --git a/templates/repo/nav.tmpl b/templates/repo/nav.tmpl index ce9c112b8d..48fe31a619 100644 --- a/templates/repo/nav.tmpl +++ b/templates/repo/nav.tmpl @@ -23,10 +23,10 @@ <button class="btn btn-default" type="button" data-toggle="tooltip" title="copy to clipboard" data-placement="top" data-init="copy" data-copy-val="val" data-copy-from="#repo-clone-ipt"><i class="fa fa-copy"></i></button> </span> </div> - <p class="help-block text-center">Need help cloning? Visit <a href="#">Help</a>!</p> + <p class="help-block text-center">Need help cloning? Visit <a target="_blank" href="https://help.github.com/articles/fork-a-repo">Help</a>!</p> <hr/> <div class="clone-zip text-center"> - <a class="btn btn-success btn-lg" href="{{.RepoLink}}/archive/{{.BranchName}}/{{.Repository.Name}}.zip"><i class="fa fa-suitcase"></i>Download ZIP</a> + <a class="btn btn-success btn-lg" href="{{.RepoLink}}/archive/{{.BranchName}}/{{.Repository.Name}}.zip" rel="nofollow"><i class="fa fa-suitcase"></i>Download ZIP</a> </div> </div> </div> diff --git a/templates/repo/single_file.tmpl b/templates/repo/single_file.tmpl index b8205024c5..95c41b7017 100644 --- a/templates/repo/single_file.tmpl +++ b/templates/repo/single_file.tmpl @@ -14,7 +14,7 @@ {{if not .ReadmeInSingle}} <div class="btn-group pull-right"> <a class="btn btn-default hidden" href="#">Edit</a> - <a class="btn btn-default" href="{{.FileLink}}">Raw</a> + <a class="btn btn-default" href="{{.FileLink}}" rel="nofollow">Raw</a> <a class="btn btn-default hidden" href="#">Blame</a> <a class="btn btn-default hidden" href="#">History</a> <a class="btn btn-danger hidden" href="#">Delete</a> @@ -27,7 +27,7 @@ {{if .IsImageFile}} <img src="{{.FileLink}}"> {{else}} - <a href="{{.FileLink}}" class="btn btn-default">View Raw</a> + <a href="{{.FileLink}}" rel="nofollow" class="btn btn-default">View Raw</a> {{end}} </div> {{else}} diff --git a/templates/repo/single_list.tmpl b/templates/repo/single_list.tmpl index 7b6c6e5e9c..49a0ec5af4 100644 --- a/templates/repo/single_list.tmpl +++ b/templates/repo/single_list.tmpl @@ -1,6 +1,6 @@ <div class="panel panel-default info-box"> <div class="panel-heading info-head"> - <a href="/{{.Username}}/{{.Reponame}}/commit/{{.LastCommit.Id}}">{{.LastCommit.Message}}</a> + <a href="/{{.Username}}/{{.Reponame}}/commit/{{.LastCommit.Id}}" rel="nofollow">{{.LastCommit.Message}}</a> </div> <div class="panel-body info-content"> <a href="/user/{{.LastCommit.Author.Name}}">{{.LastCommit.Author.Name}}</a> <span class="text-muted">{{TimeSince .LastCommit.Author.When}}</span> diff --git a/templates/user/profile.tmpl b/templates/user/profile.tmpl index 0319f46c2e..15d2a0bd5a 100644 --- a/templates/user/profile.tmpl +++ b/templates/user/profile.tmpl @@ -11,13 +11,13 @@ <div class="profile-info"> <ul class="list-group"> {{if .Owner.Location}} - <li class="list-group-item"><i class="fa fa-thumb-tack"></i>{{.Owner.Location}}</li> + <li class="list-group-item"><i class="fa fa-thumb-tack"></i>{{.Owner.Location}}</li> {{end}} {{if .Owner.Email}} - <li class="list-group-item"><i class="fa fa-envelope"></i><a href="mailto:{{.Owner.Email}}">{{.Owner.Email}}</a></li> + <li class="list-group-item"><i class="fa fa-envelope"></i><a href="mailto:{{.Owner.Email}}" rel="nofollow">{{.Owner.Email}}</a></li> {{end}} {{if .Owner.Website}} - <li class="list-group-item"><i class="fa fa-link"></i><a target="_blank" href="{{.Owner.Website}}">{{.Owner.Website}}</a></li> + <li class="list-group-item"><i class="fa fa-link"></i><a target="_blank" href="{{.Owner.Website}}">{{.Owner.Website}}</a></li> {{end}} <li class="list-group-item"><i class="fa fa-clock-o"></i>Joined on {{DateFormat .Owner.Created "M d, Y"}}</li> <!-- <hr> --> |