add tree view
This commit is contained in:
commit
b27e8e87f8
34 changed files with 716 additions and 166 deletions
60
web.go
60
web.go
|
@ -33,6 +33,55 @@ gogs web`,
|
|||
Flags: []cli.Flag{},
|
||||
}
|
||||
|
||||
func Subtract(left interface{}, right interface{}) interface{} {
|
||||
var rleft, rright int64
|
||||
var fleft, fright float64
|
||||
var isInt bool = true
|
||||
switch left.(type) {
|
||||
case int:
|
||||
rleft = int64(left.(int))
|
||||
case int8:
|
||||
rleft = int64(left.(int8))
|
||||
case int16:
|
||||
rleft = int64(left.(int16))
|
||||
case int32:
|
||||
rleft = int64(left.(int32))
|
||||
case int64:
|
||||
rleft = left.(int64)
|
||||
case float32:
|
||||
fleft = float64(left.(float32))
|
||||
isInt = false
|
||||
case float64:
|
||||
fleft = left.(float64)
|
||||
isInt = false
|
||||
}
|
||||
|
||||
switch right.(type) {
|
||||
case int:
|
||||
rright = int64(right.(int))
|
||||
case int8:
|
||||
rright = int64(right.(int8))
|
||||
case int16:
|
||||
rright = int64(right.(int16))
|
||||
case int32:
|
||||
rright = int64(right.(int32))
|
||||
case int64:
|
||||
rright = right.(int64)
|
||||
case float32:
|
||||
fright = float64(left.(float32))
|
||||
isInt = false
|
||||
case float64:
|
||||
fleft = left.(float64)
|
||||
isInt = false
|
||||
}
|
||||
|
||||
if isInt {
|
||||
return rleft - rright
|
||||
} else {
|
||||
return fleft + float64(rleft) - (fright + float64(rright))
|
||||
}
|
||||
}
|
||||
|
||||
var AppHelpers template.FuncMap = map[string]interface{}{
|
||||
"AppName": func() string {
|
||||
return base.Cfg.MustValue("", "APP_NAME")
|
||||
|
@ -40,6 +89,8 @@ var AppHelpers template.FuncMap = map[string]interface{}{
|
|||
"AppVer": func() string {
|
||||
return APP_VER
|
||||
},
|
||||
"TimeSince": base.TimeSince,
|
||||
"Subtract": Subtract,
|
||||
}
|
||||
|
||||
func runWeb(*cli.Context) {
|
||||
|
@ -63,8 +114,11 @@ func runWeb(*cli.Context) {
|
|||
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/password", auth.SignInRequire(true), binding.BindIgnErr(auth.UpdatePasswdForm{}), user.SettingPassword)
|
||||
m.Any("/user/setting/ssh", auth.SignInRequire(true), binding.BindIgnErr(auth.AddSSHKeyForm{}), user.SettingSSHKeys)
|
||||
m.Any("/user/setting/notification", auth.SignInRequire(true), user.SettingNotification)
|
||||
m.Any("/user/setting/security", auth.SignInRequire(true), user.SettingSecurity)
|
||||
|
||||
m.Get("/user/:username", auth.SignInRequire(false), user.Profile)
|
||||
|
||||
|
@ -73,6 +127,10 @@ func runWeb(*cli.Context) {
|
|||
m.Any("/repo/list", auth.SignInRequire(false), repo.List)
|
||||
|
||||
m.Get("/:username/:reponame/settings", auth.SignInRequire(false), auth.RepoAssignment(true), repo.Setting)
|
||||
m.Get("/:username/:reponame/tree/:branchname/**",
|
||||
auth.SignInRequire(false), auth.RepoAssignment(true), repo.Single)
|
||||
m.Get("/:username/:reponame/tree/:branchname",
|
||||
auth.SignInRequire(false), auth.RepoAssignment(true), repo.Single)
|
||||
m.Get("/:username/:reponame", auth.SignInRequire(false), auth.RepoAssignment(true), repo.Single)
|
||||
|
||||
//m.Get("/:username/:reponame", repo.Repo)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue