mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-09-10 20:22:14 +02:00
HTTP no follow and offline mode
This commit is contained in:
parent
59d0e73c35
commit
62d23e9154
17 changed files with 55 additions and 75 deletions
|
@ -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:
|
||||
|
|
2
gogs.go
2
gogs.go
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
||||
"github.com/gogits/git"
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
qlog "github.com/qiniu/log"
|
||||
|
||||
"github.com/gogits/git"
|
||||
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
)
|
||||
|
||||
func Update(refName, oldCommitId, newCommitId, userName, repoName string, userId int64) {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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">
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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}}
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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> -->
|
||||
|
|
Loading…
Reference in a new issue