summaryrefslogtreecommitdiffstats
path: root/web.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2014-03-14 23:54:16 +0800
committerLunny Xiao <xiaolunwen@gmail.com>2014-03-14 23:54:16 +0800
commitb27e8e87f8be2d11468e9057254b6c8933e0af33 (patch)
treebbfb32d7e248ae6f2ec63164722523d96447848a /web.go
parent607303e4dee3ddf9ba3d9d67b0186fc5213b167b (diff)
parentd18237850c6a4ae855b3f8592994c91462fcdb0a (diff)
downloadgitea-b27e8e87f8be2d11468e9057254b6c8933e0af33.tar.gz
gitea-b27e8e87f8be2d11468e9057254b6c8933e0af33.zip
add tree view
Diffstat (limited to 'web.go')
-rw-r--r--web.go60
1 files changed, 59 insertions, 1 deletions
diff --git a/web.go b/web.go
index 475b662b39..c60a262b00 100644
--- a/web.go
+++ b/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)