diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/dump.go | 13 | ||||
-rw-r--r-- | cmd/web.go | 15 |
2 files changed, 20 insertions, 8 deletions
diff --git a/cmd/dump.go b/cmd/dump.go index 035f7828b8..1bac1aeeb2 100644 --- a/cmd/dump.go +++ b/cmd/dump.go @@ -5,9 +5,11 @@ package cmd import ( + "fmt" "log" "os" "path" + "time" "github.com/Unknwon/cae/zip" "github.com/codegangsta/cli" @@ -43,11 +45,12 @@ func runDump(*cli.Context) { log.Fatalf("Fail to dump database: %v", err) } + fileName := fmt.Sprintf("gogs-dump-%d.zip", time.Now().Unix()) log.Printf("Packing dump files...") - z, err := zip.Create("gogs-dump.zip") + z, err := zip.Create(fileName) if err != nil { - os.Remove("gogs-dump.zip") - log.Fatalf("Fail to create gogs-dump.zip: %v", err) + os.Remove(fileName) + log.Fatalf("Fail to create %s: %v", fileName, err) } execDir, _ := base.ExecDir() @@ -56,8 +59,8 @@ func runDump(*cli.Context) { z.AddFile("custom/conf/app.ini", path.Join(execDir, "custom/conf/app.ini")) z.AddDir("log", path.Join(execDir, "log")) if err = z.Close(); err != nil { - os.Remove("gogs-dump.zip") - log.Fatalf("Fail to save gogs-dump.zip: %v", err) + os.Remove(fileName) + log.Fatalf("Fail to save %s: %v", fileName, err) } log.Println("Finish dumping!") diff --git a/cmd/web.go b/cmd/web.go index bad19bfeb1..2d80a89b7d 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -15,6 +15,7 @@ import ( qlog "github.com/qiniu/log" "github.com/gogits/gogs/modules/auth" + "github.com/gogits/gogs/modules/auth/apiv1" "github.com/gogits/gogs/modules/avatar" "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/log" @@ -54,7 +55,10 @@ func runWeb(*cli.Context) { m := newMartini() // Middlewares. - m.Use(middleware.Renderer(middleware.RenderOptions{Funcs: []template.FuncMap{base.TemplateFuncs}})) + m.Use(middleware.Renderer(middleware.RenderOptions{ + Funcs: []template.FuncMap{base.TemplateFuncs}, + IndentJSON: true, + })) m.Use(middleware.InitContext()) reqSignIn := middleware.Toggle(&middleware.ToggleOptions{SignInRequire: true}) @@ -76,10 +80,15 @@ func runWeb(*cli.Context) { m.Group("/api/v1", func(r martini.Router) { // Miscellaneous. - r.Post("/markdown", v1.Markdown) + r.Post("/markdown", bindIgnErr(apiv1.MarkdownForm{}), v1.Markdown) + r.Post("/markdown/raw", v1.MarkdownRaw) // Users. r.Get("/users/search", v1.SearchUser) + + r.Any("**", func(ctx *middleware.Context) { + ctx.JSON(404, &base.ApiJsonErr{"Not Found", v1.DOC_URL}) + }) }) avt := avatar.CacheServer("public/img/avatar/", "public/img/avatar_default.jpg") @@ -87,7 +96,7 @@ func runWeb(*cli.Context) { m.Get("/avatar/:hash", avt.ServeHTTP) m.Group("/user", func(r martini.Router) { - r.Get("/login", user.SignIn) + r.Get("/login", user.SignIn) // TODO r.Post("/login", bindIgnErr(auth.LogInForm{}), user.SignInPost) r.Get("/login/:name", user.SocialSignIn) r.Get("/sign_up", user.SignUp) |