[repository]
ROOT = /Users/lunny/git/gogs-repositories
-LANG_IGNS=Google Go
-LICENSES=Apache v2 License
+LANG_IGNS=Google Go|C
+LICENSES=Apache v2 License|BSD (3-Clause) License
[server]
HTTP_ADDR =
--- /dev/null
+# Object files
+*.o
+*.ko
+
+# Libraries
+*.lib
+*.a
+
+# Shared objects (inc. Windows DLLs)
+*.dll
+*.so
+*.so.*
+*.dylib
+
+# Executables
+*.exe
+*.out
+*.app
\ No newline at end of file
--- /dev/null
+Copyright (c) 2014
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+* Neither the name of the {organization} nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
// Test that go1.1 tag above is included in builds. main.go refers to this definition.
const go11tag = true
-const APP_VER = "0.0.6.0313"
+const APP_VER = "0.0.7.0313"
func init() {
runtime.GOMAXPROCS(runtime.NumCPU())
session.Rollback()
return err
}
+ if _, err := session.Delete(&Access{UserName: userName, RepoName: repo.Name}); err != nil {
+ session.Rollback()
+ return err
+ }
if _, err = session.Exec("update user set num_repos = num_repos - 1 where id = ?", userId); err != nil {
session.Rollback()
return err
NumFollowings int
NumStars int
NumRepos int
- Avatar string `xorm:"varchar(2048) not null"`
+ Avatar string `xorm:"varchar(2048) not null"`
+ Location string
+ Website string
Created time.Time `xorm:"created"`
Updated time.Time `xorm:"updated"`
}
validate(errors, data, f)
}
-type FeedsForm struct {
- UserId int64 `form:"userid" binding:"Required"`
- Offset int64 `form:"offset"`
-}
-
func getMinMaxSize(field reflect.StructField) string {
for _, rule := range strings.Split(field.Tag.Get("binding"), ";") {
if strings.HasPrefix(rule, "MinSize(") || strings.HasPrefix(rule, "MaxSize(") {
package auth
import (
+ "net/http"
+ "reflect"
+
"github.com/codegangsta/martini"
"github.com/martini-contrib/render"
"github.com/martini-contrib/sessions"
+ "github.com/gogits/binding"
+
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/log"
}
}
}
+
+type FeedsForm struct {
+ UserId int64 `form:"userid" binding:"Required"`
+ Offset int64 `form:"offset"`
+}
+
+type UpdateProfileForm struct {
+ Email string `form:"email" binding:"Required;Email;MaxSize(50)"`
+ Website string `form:"website" binding:"AlphaDash;MaxSize(50)"`
+ Location string `form:"location" binding:"MaxSize(50)"`
+ Avatar string `form:"avatar" binding:"Required;Email;MaxSize(50)"`
+}
+
+func (f *UpdateProfileForm) Name(field string) string {
+ names := map[string]string{
+ "Email": "Email address",
+ "Website": "Website",
+ "Location": "Location",
+ "Avatar": "Gravatar Email",
+ }
+ return names[field]
+}
+
+func (f *UpdateProfileForm) Validate(errors *binding.Errors, req *http.Request, context martini.Context) {
+ if req.Method == "GET" || errors.Count() == 0 {
+ return
+ }
+
+ data := context.Get(reflect.TypeOf(base.TmplData{})).Interface().(base.TmplData)
+ data["HasError"] = true
+
+ if len(errors.Overall) > 0 {
+ for _, err := range errors.Overall {
+ log.Error("UpdateProfileForm.Validate: %v", err)
+ }
+ return
+ }
+
+ validate(errors, data, f)
+}
if err == nil {
if _, err = models.CreateRepository(user,
form.RepoName, form.Description, form.Language, form.License,
- form.Visibility == "private", form.InitReadme == "true"); err == nil {
+ form.Visibility == "private", form.InitReadme == "on"); err == nil {
if err == nil {
data["RepoName"] = user.Name + "/" + form.RepoName
r.HTML(200, "repo/created", data)
return
}
- r.Redirect("/", 200)
+ r.Redirect("/", 302)
}
func List(req *http.Request, r render.Render, data base.TmplData, session sessions.Session) {
"github.com/gogits/gogs/modules/log"
)
-func Setting(r render.Render, data base.TmplData, session sessions.Session) {
+func Setting(form auth.UpdateProfileForm, r render.Render, data base.TmplData, req *http.Request, session sessions.Session) {
data["Title"] = "Setting"
data["PageIsUserSetting"] = true
+
+ user := auth.SignedInUser(session)
+ if req.Method == "GET" {
+ data["Owner"] = user
+ }
+
+ if hasErr, ok := data["HasError"]; ok && hasErr.(bool) {
+ r.HTML(200, "user/setting", data)
+ return
+ }
+
+ user.Email = form.Email
+ user.Website = form.Website
+ user.Location = form.Location
+ user.Avatar = base.EncodeMd5(form.Avatar)
+ if err := models.UpdateUser(user); err != nil {
+ data["ErrorMsg"] = err
+ log.Error("setting.Setting: %v", err)
+ r.HTML(200, "base/error", data)
+ return
+ }
+
r.HTML(200, "user/setting", data)
}
return
}
- data["Avatar"] = user.Avatar
- data["Username"] = user.Name
+ data["Owner"] = user
r.HTML(200, "user/profile", data)
}
<div id="gogs-user-profile" class="col-md-3">
<div class="profile-avatar text-center">
<a href="#" class="center-block" data-toggle="tooltip" data-placement="bottom" title="Change Avatar">
- <img id="gogs-user-avatar" src="http://1.gravatar.com/avatar/{{.Avatar}}?s=200" alt="user-avatar" title="username"/>
+ <img id="gogs-user-avatar" src="http://1.gravatar.com/avatar/{{.Owner.Avatar}}?s=200" alt="user-avatar" title="username"/>
</a>
- <span id="gogs-user-name" class="center-block" href="#">{{.Username}}</span>
+ <span id="gogs-user-name" class="center-block" href="#">{{.Owner.Name}}</span>
</div>
<div class="profile-info">
<ul class="list-group">
- <li class="list-group-item"><i class="fa fa-thumb-tack"></i>City, County, State, Nation</li>
- <li class="list-group-item"><i class="fa fa-envelope"></i><a href="#">Email@EmailAddress.com</a></li>
- <li class="list-group-item"><i class="fa fa-link"></i><a href="#">http://yousite/</a></li>
- <li class="list-group-item"><i class="fa fa-clock-o"></i>Joined At 03.02, 2014</li>
+ <li class="list-group-item"><i class="fa fa-thumb-tack"></i>{{.Owner.Location}}</li>
+ <li class="list-group-item"><i class="fa fa-envelope"></i><a href="#">{{.Owner.Email}}</a></li>
+ <li class="list-group-item"><i class="fa fa-link"></i><a href="#">{{.Owner.Website}}</a></li>
+ <li class="list-group-item"><i class="fa fa-clock-o"></i>{{.Owner.Created}}</li>
</ul>
</div>
</div>
m.Any("/user/delete", auth.SignInRequire(true), user.Delete)
m.Get("/user/feeds", binding.Bind(auth.FeedsForm{}), user.Feeds)
- m.Any("/user/setting", auth.SignInRequire(true), user.Setting)
+ m.Any("/user/setting", auth.SignInRequire(true), binding.BindIgnErr(auth.UpdateProfileForm{}), user.Setting)
m.Any("/user/setting/ssh", auth.SignInRequire(true), binding.BindIgnErr(auth.AddSSHKeyForm{}), user.SettingSSHKeys)
m.Get("/user/:username", auth.SignInRequire(false), user.Profile)