work on #470 and fix miror JS issue when choose targets on compare and pull

This commit is contained in:
Unknwon 2015-10-29 21:09:48 -04:00
parent 706b0f72e2
commit 7d72c8333e
7 changed files with 26 additions and 18 deletions

View File

@ -111,7 +111,7 @@ admin_title = Admin Account Settings
admin_name = Username admin_name = Username
admin_password = Password admin_password = Password
confirm_password = Confirm Password confirm_password = Confirm Password
admin_email = E-mail admin_email = Admin E-mail
install_gogs = Install Gogs install_gogs = Install Gogs
test_git_failed = Fail to test 'git' command: %v test_git_failed = Fail to test 'git' command: %v
sqlite3_not_available = Your release version does not support SQLite3, please download the official binary version from %s, NOT the gobuild version. sqlite3_not_available = Your release version does not support SQLite3, please download the official binary version from %s, NOT the gobuild version.
@ -192,6 +192,7 @@ min_size_error = ` must contain at least %s characters.`
max_size_error = ` must contain at most %s characters.` max_size_error = ` must contain at most %s characters.`
email_error = ` is not a valid e-mail address.` email_error = ` is not a valid e-mail address.`
url_error = ` is not a valid URL.` url_error = ` is not a valid URL.`
include_error = ` must contain substring '%s'.`
unknown_error = Unknown error: unknown_error = Unknown error:
captcha_incorrect = Captcha didn't match. captcha_incorrect = Captcha didn't match.
password_not_match = Password and confirm password are not same. password_not_match = Password and confirm password are not same.

View File

@ -181,7 +181,7 @@ func AssignForm(form interface{}, data map[string]interface{}) {
} }
} }
func getSize(field reflect.StructField, prefix string) string { func getRuleBody(field reflect.StructField, prefix string) string {
for _, rule := range strings.Split(field.Tag.Get("binding"), ";") { for _, rule := range strings.Split(field.Tag.Get("binding"), ";") {
if strings.HasPrefix(rule, prefix) { if strings.HasPrefix(rule, prefix) {
return rule[len(prefix) : len(rule)-1] return rule[len(prefix) : len(rule)-1]
@ -191,15 +191,19 @@ func getSize(field reflect.StructField, prefix string) string {
} }
func GetSize(field reflect.StructField) string { func GetSize(field reflect.StructField) string {
return getSize(field, "Size(") return getRuleBody(field, "Size(")
} }
func GetMinSize(field reflect.StructField) string { func GetMinSize(field reflect.StructField) string {
return getSize(field, "MinSize(") return getRuleBody(field, "MinSize(")
} }
func GetMaxSize(field reflect.StructField) string { func GetMaxSize(field reflect.StructField) string {
return getSize(field, "MaxSize(") return getRuleBody(field, "MaxSize(")
}
func GetInclude(field reflect.StructField) string {
return getRuleBody(field, "Include(")
} }
// FIXME: struct contains a struct // FIXME: struct contains a struct
@ -260,6 +264,8 @@ func validate(errs binding.Errors, data map[string]interface{}, f Form, l macaro
data["ErrorMsg"] = trName + l.Tr("form.email_error") data["ErrorMsg"] = trName + l.Tr("form.email_error")
case binding.ERR_URL: case binding.ERR_URL:
data["ErrorMsg"] = trName + l.Tr("form.url_error") data["ErrorMsg"] = trName + l.Tr("form.url_error")
case binding.ERR_INCLUDE:
data["ErrorMsg"] = trName + l.Tr("form.include_error", GetInclude(field))
default: default:
data["ErrorMsg"] = l.Tr("form.unknown_error") + " " + errs[0].Classification data["ErrorMsg"] = l.Tr("form.unknown_error") + " " + errs[0].Classification
} }

View File

@ -44,7 +44,7 @@ type InstallForm struct {
AdminName string `binding:"OmitEmpty;AlphaDashDot;MaxSize(30)" locale:"install.admin_name"` AdminName string `binding:"OmitEmpty;AlphaDashDot;MaxSize(30)" locale:"install.admin_name"`
AdminPasswd string `binding:"OmitEmpty;MaxSize(255)" locale:"install.admin_password"` AdminPasswd string `binding:"OmitEmpty;MaxSize(255)" locale:"install.admin_password"`
AdminConfirmPasswd string AdminConfirmPasswd string
AdminEmail string `binding:"OmitEmpty;Email;MaxSize(50)" locale:"install.admin_email"` AdminEmail string `binding:"OmitEmpty;MinSize(3);MaxSize(50);Include(@)" locale:"install.admin_email"`
} }
func (f *InstallForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors { func (f *InstallForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {

File diff suppressed because one or more lines are too long

View File

@ -384,9 +384,7 @@ function initRepository() {
// Diff // Diff
if ($('.repository.diff').length > 0) { if ($('.repository.diff').length > 0) {
var $counter = $('.diff-counter'); var $counter = $('.diff-counter');
if ($counter.length < 1) { if ($counter.length >= 1) {
return;
}
$counter.each(function (i, item) { $counter.each(function (i, item) {
var $item = $(item); var $item = $(item);
var addLine = $item.find('span[data-line].add').data("line"); var addLine = $item.find('span[data-line].add').data("line");
@ -395,6 +393,7 @@ function initRepository() {
$item.find(".bar .add").css("width", addPercent + "%"); $item.find(".bar .add").css("width", addPercent + "%");
}); });
} }
}
// Quick start // Quick start
if ($('.repository.quickstart').length > 0) { if ($('.repository.quickstart').length > 0) {
@ -419,6 +418,7 @@ function initRepository() {
fullTextSearch: true, fullTextSearch: true,
onChange: function (text, value, $choice) { onChange: function (text, value, $choice) {
window.location.href = $choice.data('url'); window.location.href = $choice.data('url');
console.log($choice.data('url'))
}, },
message: {noResults: $branch_dropdown.data('no-results')} message: {noResults: $branch_dropdown.data('no-results')}
}); });

View File

@ -173,6 +173,7 @@ func InstallPost(ctx *middleware.Context, form auth.InstallForm) {
ctx.HTML(200, INSTALL) ctx.HTML(200, INSTALL)
return return
} }
return
if _, err := exec.LookPath("git"); err != nil { if _, err := exec.LookPath("git"); err != nil {
ctx.RenderWithErr(ctx.Tr("install.test_git_failed", err), INSTALL, &form) ctx.RenderWithErr(ctx.Tr("install.test_git_failed", err), INSTALL, &form)

View File

@ -214,7 +214,7 @@
</div> </div>
<div class="inline field {{if .Err_AdminEmail}}error{{end}}"> <div class="inline field {{if .Err_AdminEmail}}error{{end}}">
<label for="admin_email">{{.i18n.Tr "install.admin_email"}}</label> <label for="admin_email">{{.i18n.Tr "install.admin_email"}}</label>
<input id="admin_email" name="admin_email" value="{{.admin_email}}"> <input id="admin_email" name="admin_email" type="email1" value="{{.admin_email}}">
</div> </div>
</div> </div>
</div> </div>