Batch mirror fix

This commit is contained in:
Unknown 2014-04-26 22:34:48 -06:00
parent 1badb2bbcc
commit 59d0e73c35
13 changed files with 68 additions and 80 deletions

View file

@ -19,6 +19,7 @@ github.com/lib/pq =
github.com/nfnt/resize = github.com/nfnt/resize =
github.com/qiniu/log = github.com/qiniu/log =
github.com/robfig/cron = github.com/robfig/cron =
github.com/juju2013/goldap =
[res] [res]
include = templates|public|conf include = templates|public|conf

View file

@ -10,6 +10,8 @@ Want to hack on Gogs? Awesome! Here are instructions to get you started. They ar
### Pull requests are always welcome ### Pull requests are always welcome
**ALL PULL REQUESTS MUST SEND TO `DEV` BRANCH**
We are always thrilled to receive pull requests, and do our best to process them as fast as possible. Not sure if that typo is worth a pull request? Do it! We will appreciate it. We are always thrilled to receive pull requests, and do our best to process them as fast as possible. Not sure if that typo is worth a pull request? Do it! We will appreciate it.
If your pull request is not accepted on the first try, don't be discouraged! If there's a problem with the implementation, hopefully you received feedback on what to improve. If your pull request is not accepted on the first try, don't be discouraged! If there's a problem with the implementation, hopefully you received feedback on what to improve.

View file

@ -53,7 +53,6 @@ var (
Domain string Domain string
SecretKey string SecretKey string
RunUser string RunUser string
LdapAuth bool
RepoRootPath string RepoRootPath string
ScriptType string ScriptType string
@ -93,6 +92,7 @@ var Service struct {
NotifyMail bool NotifyMail bool
ActiveCodeLives int ActiveCodeLives int
ResetPwdCodeLives int ResetPwdCodeLives int
LdapAuth bool
} }
func ExecDir() (string, error) { func ExecDir() (string, error) {
@ -179,8 +179,8 @@ func newLogService() {
} }
func newLdapService() { func newLdapService() {
LdapAuth = Cfg.MustBool("security", "LDAP_AUTH", false) Service.LdapAuth = Cfg.MustBool("security", "LDAP_AUTH", false)
if !LdapAuth { if !Service.LdapAuth {
return return
} }
@ -201,7 +201,7 @@ func newLdapService() {
} }
if nbsrc == 0 { if nbsrc == 0 {
log.Warn("No valide LDAP found, LDAP Authentication NOT enabled") log.Warn("No valide LDAP found, LDAP Authentication NOT enabled")
LdapAuth = false Service.LdapAuth = false
return return
} }

View file

@ -26,11 +26,14 @@ func RepoAssignment(redirect bool, args ...bool) martini.Handler {
var displayBare bool var displayBare bool
if len(args) >= 1 { if len(args) >= 1 {
validBranch = args[0] // Note: argument has wrong value in Go1.3 martini.
// validBranch = args[0]
validBranch = true
} }
if len(args) >= 2 { if len(args) >= 2 {
displayBare = args[1] // displayBare = args[1]
displayBare = true
} }
var ( var (

View file

@ -470,10 +470,10 @@ function initInstall() {
(function () { (function () {
$('#install-database').on("change", function () { $('#install-database').on("change", function () {
var val = $(this).val(); var val = $(this).val();
if (val != "sqlite") { if (val != "SQLite3") {
$('.server-sql').show(); $('.server-sql').show();
$('.sqlite-setting').addClass("hide"); $('.sqlite-setting').addClass("hide");
if (val == "pgsql") { if (val == "PostgreSQL") {
$('.pgsql-setting').removeClass("hide"); $('.pgsql-setting').removeClass("hide");
} else { } else {
$('.pgsql-setting').addClass("hide"); $('.pgsql-setting').addClass("hide");

View file

@ -65,6 +65,10 @@ func GlobalInit() {
checkRunMode() checkRunMode()
} }
func renderDbOption(ctx *middleware.Context) {
ctx.Data["DbOptions"] = []string{"MySQL", "PostgreSQL", "SQLite3"}
}
func Install(ctx *middleware.Context, form auth.InstallForm) { func Install(ctx *middleware.Context, form auth.InstallForm) {
if base.InstallLock { if base.InstallLock {
ctx.Handle(404, "install.Install", errors.New("Installation is prohibited")) ctx.Handle(404, "install.Install", errors.New("Installation is prohibited"))
@ -104,6 +108,13 @@ func Install(ctx *middleware.Context, form auth.InstallForm) {
form.AppUrl = base.AppUrl form.AppUrl = base.AppUrl
} }
renderDbOption(ctx)
curDbValue := ""
if models.EnableSQLite3 {
curDbValue = "SQLite3" // Default when enabled.
}
ctx.Data["CurDbValue"] = curDbValue
auth.AssignForm(form, ctx.Data) auth.AssignForm(form, ctx.Data)
ctx.HTML(200, "install") ctx.HTML(200, "install")
} }
@ -117,6 +128,9 @@ func InstallPost(ctx *middleware.Context, form auth.InstallForm) {
ctx.Data["Title"] = "Install" ctx.Data["Title"] = "Install"
ctx.Data["PageIsInstall"] = true ctx.Data["PageIsInstall"] = true
renderDbOption(ctx)
ctx.Data["CurDbValue"] = form.Database
if ctx.HasError() { if ctx.HasError() {
ctx.HTML(200, "install") ctx.HTML(200, "install")
return return
@ -129,7 +143,7 @@ func InstallPost(ctx *middleware.Context, form auth.InstallForm) {
// Pass basic check, now test configuration. // Pass basic check, now test configuration.
// Test database setting. // Test database setting.
dbTypes := map[string]string{"mysql": "mysql", "pgsql": "postgres", "sqlite": "sqlite3"} dbTypes := map[string]string{"MySQL": "mysql", "PostgreSQL": "postgres", "SQLite3": "sqlite3"}
models.DbCfg.Type = dbTypes[form.Database] models.DbCfg.Type = dbTypes[form.Database]
models.DbCfg.Host = form.Host models.DbCfg.Host = form.Host
models.DbCfg.User = form.User models.DbCfg.User = form.User

View file

@ -91,12 +91,14 @@ func SignInPost(ctx *middleware.Context, form auth.LogInForm) {
var user *models.User var user *models.User
var err error var err error
// try to login against LDAP if defined if base.Service.LdapAuth {
if base.LdapAuth {
user, err = models.LoginUserLdap(form.UserName, form.Password) user, err = models.LoginUserLdap(form.UserName, form.Password)
if err != nil {
log.Error("Fail to login through LDAP: %v", err)
}
} }
// try local if not LDAP or it's failed // try local if not LDAP or it's failed
if (!base.LdapAuth) || (err != nil) { if !base.Service.LdapAuth || err != nil {
user, err = models.LoginUserPlain(form.UserName, form.Password) user, err = models.LoginUserPlain(form.UserName, form.Password)
} }
if err != nil { if err != nil {

View file

@ -13,7 +13,10 @@
<div class="col-md-1" style="margin: -5px;"> <div class="col-md-1" style="margin: -5px;">
<a target="_blank" href="https://github.com/gogits/gogs"><i class="fa fa-github fa-2x"></i></a> <a target="_blank" href="https://github.com/gogits/gogs"><i class="fa fa-github fa-2x"></i></a>
</div> </div>
<p class="desc"></p>
<div class="col-md-5">
<p class="desc"></p>
</div>
</div> </div>
</div> </div>
</footer> </footer>

View file

@ -9,14 +9,15 @@
<label class="col-md-3 control-label">Database Type: </label> <label class="col-md-3 control-label">Database Type: </label>
<div class="col-md-8"> <div class="col-md-8">
<select name="database" id="install-database" class="form-control"> <select name="database" id="install-database" class="form-control">
<option value="mysql">MySQL</option> {{if .CurDbValue}}<option value="{{.CurDbValue}}">{{.CurDbValue}}</option>{{end}}
<option value="pgsql">PostgreSQL</option> {{range .DbOptions}}
<option value="sqlite">SQLite3</option> {{if not (eq $.CurDbValue .)}}<option value="{{.}}">{{.}}</option>{{end}}
{{end}}
</select> </select>
</div> </div>
</div> </div>
<div class="server-sql"> <div class="server-sql {{if eq .CurDbValue "SQLite3"}}hide{{end}}">
<div class="form-group"> <div class="form-group">
<label class="col-md-3 control-label">Host: </label> <label class="col-md-3 control-label">Host: </label>
<div class="col-md-8"> <div class="col-md-8">
@ -49,7 +50,7 @@
</div> </div>
</div> </div>
<div class="form-group pgsql-setting hide"> <div class="form-group pgsql-setting {{if not (eq .CurDbValue "PostgreSQL")}}hide{{end}}">
<label class="col-md-3 control-label">SSL Mode: </label> <label class="col-md-3 control-label">SSL Mode: </label>
<div class="col-md-8"> <div class="col-md-8">
<select name="ssl_mode" class="form-control"> <select name="ssl_mode" class="form-control">
@ -61,7 +62,7 @@
</div> </div>
</div> </div>
<div class="sqlite-setting hide"> <div class="sqlite-setting {{if not (eq .CurDbValue "SQLite3")}}hide{{end}}">
<div class="form-group"> <div class="form-group">
<label class="col-md-3 control-label">Path: </label> <label class="col-md-3 control-label">Path: </label>

View file

@ -21,30 +21,31 @@
</div> </div>
{{end}} {{end}}
</div> </div>
{{if not .FileIsText}} {{if not .FileIsText}}
<div class="panel-footer text-center"> <div class="panel-body file-body file-code code-view">
{{if .IsImageFile}} {{if .IsImageFile}}
<img src="{{.FileLink}}"> <img src="{{.FileLink}}">
{{else}}
<a href="{{.FileLink}}" class="btn btn-default">View Raw</a>
{{end}}
</div>
{{else}}
{{if .ReadmeExist}}
<div class="panel-body file-body markdown">
{{.FileContent|str2html}}
</div>
{{else}} {{else}}
<div class="panel-body file-body file-code code-view"> <a href="{{.FileLink}}" class="btn btn-default">View Raw</a>
<table>
<tbody>
<tr>
<td class="lines-num"></td>
<td class="lines-code markdown"><pre class="prettyprint linenums{{if .FileExt}} lang-{{.FileExt}}{{end}}">{{.FileContent}}</pre></td>
</tr>
</tbody>
</table>
</div>
{{end}} {{end}}
</div>
{{else}}
{{if .ReadmeExist}}
<div class="panel-body file-body markdown">
{{.FileContent|str2html}}
</div>
{{else}}
<div class="panel-body file-body file-code code-view">
<table>
<tbody>
<tr>
<td class="lines-num"></td>
<td class="lines-code markdown"><pre class="prettyprint linenums{{if .FileExt}} lang-{{.FileExt}}{{end}}">{{.FileContent}}</pre></td>
</tr>
</tbody>
</table>
</div>
{{end}}
{{end}} {{end}}
</div> </div>

View file

@ -1,9 +0,0 @@
command: go test -v {}
include: ^.+_test\.go$
path: ./
depth: 1
verbose: true
timeout: 1m
reload: false
html: test.html
notify: []

View file

@ -1,13 +0,0 @@
## Gogs Test
This is for developers.
## Prepare Environment
go get -u github.com/shxsun/travelexec
# start gogs server
gogs web
## Start Testing
travelexec

View file

@ -1,17 +0,0 @@
package test
import (
"net/http"
"testing"
)
func TestMain(t *testing.T) {
r, err := http.Get("http://localhost:3000/")
if err != nil {
t.Fatal(err)
}
defer r.Body.Close()
if r.StatusCode != http.StatusOK {
t.Error(r.StatusCode)
}
}