From c72e1b5c2ac8d2cbd123f3f53db7b4a125045725 Mon Sep 17 00:00:00 2001 From: FuXiaoHei Date: Wed, 9 Apr 2014 21:28:00 +0800 Subject: [PATCH] repo-import page ui --- public/css/gogs.css | 12 ++++ routers/repo/repo.go | 32 ++++++++++ templates/repo/import.tmpl | 112 ++++++++++++++++++++++++++++++++++ templates/user/dashboard.tmpl | 2 +- web.go | 1 + 5 files changed, 158 insertions(+), 1 deletion(-) create mode 100644 templates/repo/import.tmpl diff --git a/public/css/gogs.css b/public/css/gogs.css index bf39ea39c..dcfb2758a 100755 --- a/public/css/gogs.css +++ b/public/css/gogs.css @@ -309,6 +309,18 @@ html, body { height: 8em; } +#repo-import-auth{ + width: 100%; + margin-top: 48px; + box-sizing: border-box; +} + +#repo-import-auth .form-group{ + box-sizing: border-box; + margin-left: 0; + margin-right: 0; +} + /* gogits user setting */ #user-setting-nav > h4, #user-setting-container > h4, #user-setting-container > div > h4, diff --git a/routers/repo/repo.go b/routers/repo/repo.go index d223600c5..0ab1c9e42 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -55,6 +55,38 @@ func Create(ctx *middleware.Context, form auth.CreateRepoForm) { ctx.Handle(200, "repo.Create", err) } +func Import(ctx *middleware.Context, form auth.CreateRepoForm) { + ctx.Data["Title"] = "Import repository" + ctx.Data["PageIsNewRepo"] = true // For navbar arrow. + ctx.Data["LanguageIgns"] = models.LanguageIgns + ctx.Data["Licenses"] = models.Licenses + + if ctx.Req.Method == "GET" { + ctx.HTML(200, "repo/import") + return + } + + if ctx.HasError() { + ctx.HTML(200, "repo/import") + return + } + + _, err := models.CreateRepository(ctx.User, form.RepoName, form.Description, + form.Language, form.License, form.Visibility == "private", form.InitReadme == "on") + if err == nil { + log.Trace("%s Repository created: %s/%s", ctx.Req.RequestURI, ctx.User.LowerName, form.RepoName) + ctx.Redirect("/" + ctx.User.Name + "/" + form.RepoName) + return + } else if err == models.ErrRepoAlreadyExist { + ctx.RenderWithErr("Repository name has already been used", "repo/import", &form) + return + } else if err == models.ErrRepoNameIllegal { + ctx.RenderWithErr(models.ErrRepoNameIllegal.Error(), "repo/import", &form) + return + } + ctx.Handle(200, "repo.Import", err) +} + func Single(ctx *middleware.Context, params martini.Params) { branchName := ctx.Repo.BranchName commitId := ctx.Repo.CommitId diff --git a/templates/repo/import.tmpl b/templates/repo/import.tmpl new file mode 100644 index 000000000..75d928d13 --- /dev/null +++ b/templates/repo/import.tmpl @@ -0,0 +1,112 @@ +{{template "base/head" .}} +{{template "base/navbar" .}} +
+
+ {{.CsrfTokenHtml}} +

Import Repository

+
{{.ErrorMsg}}
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+
+ +
+

{{.SignedUserName}}

+ +
+
+ +
+ +
+ + Great repository names are short and memorable. +
+
+ +
+ +
+

Public

+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ + + +
+
+ + Cancel +
+
+
+
+{{template "base/footer" .}} \ No newline at end of file diff --git a/templates/user/dashboard.tmpl b/templates/user/dashboard.tmpl index 39e277e3c..f0a0a0cca 100644 --- a/templates/user/dashboard.tmpl +++ b/templates/user/dashboard.tmpl @@ -37,7 +37,7 @@