From 721834a2673fed7fc21988b8e91a88a26bcef051 Mon Sep 17 00:00:00 2001 From: FuXiaoHei Date: Wed, 9 Apr 2014 20:10:56 +0800 Subject: [PATCH 1/3] change new-repo button to dropdown menu in dashboard page --- public/css/gogs.css | 28 +++++++++++++++++++++++++++- templates/user/dashboard.tmpl | 15 ++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/public/css/gogs.css b/public/css/gogs.css index da2a7fd1a2..bf39ea39ce 100755 --- a/public/css/gogs.css +++ b/public/css/gogs.css @@ -444,6 +444,32 @@ html, body { margin-right: 1em; } +#user-dashboard-repo-new .btn-sm.dropdown-toggle { + padding: 3px 8px; +} + +#user-dashboard-repo-new .dropdown-menu { + padding: 0; + margin: 0; +} + +#user-dashboard-repo-new ul { + margin: 0; + width: 200px; +} + +#user-dashboard-repo-new li a { + line-height: 36px; + display: block; + padding: 0 18px; + color: #444; +} + +#user-dashboard-repo-new li a:hover { + background: #0093c4; + color: #FFF; +} + /* gogits repo single page */ #body-nav.repo-nav { @@ -1372,6 +1398,6 @@ html, body { margin: 16px 0; } -#release-preview{ +#release-preview { margin: 6px 0; } \ No newline at end of file diff --git a/templates/user/dashboard.tmpl b/templates/user/dashboard.tmpl index bc0853fb0d..39e277e3c9 100644 --- a/templates/user/dashboard.tmpl +++ b/templates/user/dashboard.tmpl @@ -29,7 +29,20 @@
Your Repositories - New Repo +
+ + + +
    {{range .MyRepos}} From c72e1b5c2ac8d2cbd123f3f53db7b4a125045725 Mon Sep 17 00:00:00 2001 From: FuXiaoHei Date: Wed, 9 Apr 2014 21:28:00 +0800 Subject: [PATCH 2/3] 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 bf39ea39ce..dcfb2758a0 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 d223600c52..0ab1c9e420 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 0000000000..75d928d138 --- /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 39e277e3c9..f0a0a0ccaa 100644 --- a/templates/user/dashboard.tmpl +++ b/templates/user/dashboard.tmpl @@ -37,7 +37,7 @@