diff options
Diffstat (limited to 'cmd/web.go')
-rw-r--r-- | cmd/web.go | 40 |
1 files changed, 35 insertions, 5 deletions
@@ -325,7 +325,36 @@ func runWeb(ctx *cli.Context) { }) }, adminReq) - m.Get("/:username", ignSignIn, user.Profile) + m.Group("", func() { + m.Get("/:username", user.Profile) + m.Get("/attachments/:uuid", func(ctx *middleware.Context) { + attach, err := models.GetAttachmentByUUID(ctx.Params(":uuid")) + if err != nil { + if models.IsErrAttachmentNotExist(err) { + ctx.Error(404) + } else { + ctx.Handle(500, "GetAttachmentByUUID", err) + } + return + } + + fr, err := os.Open(attach.LocalPath()) + if err != nil { + ctx.Handle(500, "Open", err) + return + } + defer fr.Close() + + ctx.Header().Set("Cache-Control", "public,max-age=86400") + // Fix #312. Attachments with , in their name are not handled correctly by Google Chrome. + // We must put the name in " manually. + if err = repo.ServeData(ctx, "\""+attach.Name+"\"", fr); err != nil { + ctx.Handle(500, "ServeData", err) + return + } + }) + m.Post("/issues/attachments", repo.UploadIssueAttachment) + }, ignSignIn) if macaron.Env == macaron.DEV { m.Get("/template/*", dev.TemplatePreview) @@ -419,13 +448,12 @@ func runWeb(ctx *cli.Context) { m.Get("/action/:action", repo.Action) m.Group("/issues", func() { - m.Get("/new", repo.CreateIssue) - m.Post("/new", bindIgnErr(auth.CreateIssueForm{}), repo.CreateIssuePost) + m.Combo("/new").Get(repo.NewIssue). + Post(bindIgnErr(auth.CreateIssueForm{}), repo.NewIssuePost) m.Post("/:index", bindIgnErr(auth.CreateIssueForm{}), repo.UpdateIssue) m.Post("/:index/label", repo.UpdateIssueLabel) m.Post("/:index/milestone", repo.UpdateIssueMilestone) m.Post("/:index/assignee", repo.UpdateAssignee) - m.Get("/:index/attachment/:id", repo.IssueGetAttachment) }) m.Group("/labels", func() { m.Post("/new", bindIgnErr(auth.CreateLabelForm{}), repo.NewLabel) @@ -449,6 +477,8 @@ func runWeb(ctx *cli.Context) { m.Get("/edit/:tagname", repo.EditRelease) m.Post("/edit/:tagname", bindIgnErr(auth.EditReleaseForm{}), repo.EditReleasePost) }, reqRepoAdmin, middleware.RepoRef()) + + m.Combo("/compare/*").Get(repo.CompareAndPullRequest) }, reqSignIn, middleware.RepoAssignment(true)) m.Group("/:username/:reponame", func() { @@ -469,7 +499,7 @@ func runWeb(ctx *cli.Context) { m.Get("/commit/*", repo.Diff) }, middleware.RepoRef()) - m.Get("/compare/:before([a-z0-9]+)...:after([a-z0-9]+)", repo.CompareDiff) + m.Get("/compare/:before([a-z0-9]{40})...:after([a-z0-9]{40})", repo.CompareDiff) }, ignSignIn, middleware.RepoAssignment(true)) m.Group("/:username", func() { |