From ecce694d77756264864b03e6b06077592ed1676a Mon Sep 17 00:00:00 2001 From: FuXiaoHei Date: Sat, 29 Mar 2014 21:16:06 +0800 Subject: issue content ajax preview --- web.go | 1 + 1 file changed, 1 insertion(+) (limited to 'web.go') diff --git a/web.go b/web.go index 35695f0b..451e52ff 100644 --- a/web.go +++ b/web.go @@ -95,6 +95,7 @@ func runWeb(*cli.Context) { m.Get("/pulls", reqSignIn, user.Pulls) m.Get("/stars", reqSignIn, user.Stars) m.Get("/help", routers.Help) + m.Post("/preview", routers.Preview) avt := avatar.CacheServer("public/img/avatar/", "public/img/avatar_default.jpg") m.Get("/avatar/:hash", avt.ServeHTTP) -- cgit v1.2.3 From 2c073afbec4b9845e8ddd10a4d3f469874fdcd37 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 29 Mar 2014 10:01:52 -0400 Subject: Mirror fix and update --- README.md | 2 ++ models/repo.go | 13 ++++++++++--- routers/api/v1/miscellaneous.go | 18 ++++++++++++++++++ routers/preview.go | 17 ----------------- templates/issue/create.tmpl | 4 ++-- templates/issue/view.tmpl | 4 ++-- templates/user/signin.tmpl | 2 +- web.go | 7 ++++++- 8 files changed, 41 insertions(+), 26 deletions(-) create mode 100644 routers/api/v1/miscellaneous.go delete mode 100644 routers/preview.go (limited to 'web.go') diff --git a/README.md b/README.md index 7d688506..e88a2477 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,8 @@ Gogs(Go Git Service) is a Self Hosted Git Service in the Go Programming Language ##### Current version: 0.1.9 Alpha +#### Due to testing purpose, data of [try.gogits.org](http://try.gogits.org) has been reset in March 29, 2014 and will reset multiple times after. Please do NOT put your important data on the site. + #### Other language version - [简体中文](README_ZH.md) diff --git a/models/repo.go b/models/repo.go index 4be655d2..a848694d 100644 --- a/models/repo.go +++ b/models/repo.go @@ -198,12 +198,19 @@ func CreateRepository(user *User, repoName, desc, repoLang, license string, priv c := exec.Command("git", "update-server-info") c.Dir = repoPath - err = c.Run() - if err != nil { + if err = c.Run(); err != nil { log.Error("repo.CreateRepository(exec update-server-info): %v", err) } - return repo, NewRepoAction(user, repo) + if err = NewRepoAction(user, repo); err != nil { + log.Error("repo.CreateRepository(NewRepoAction): %v", err) + } + + if err = WatchRepo(user.Id, repo.Id, true); err != nil { + log.Error("repo.CreateRepository(WatchRepo): %v", err) + } + + return repo, nil } // extractGitBareZip extracts git-bare.zip to repository path. diff --git a/routers/api/v1/miscellaneous.go b/routers/api/v1/miscellaneous.go new file mode 100644 index 00000000..0ff1eb04 --- /dev/null +++ b/routers/api/v1/miscellaneous.go @@ -0,0 +1,18 @@ +// Copyright 2014 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package v1 + +import ( + "github.com/gogits/gogs/modules/base" + "github.com/gogits/gogs/modules/middleware" +) + +func Markdown(ctx *middleware.Context) { + content := ctx.Query("content") + ctx.Render.JSON(200, map[string]interface{}{ + "ok": true, + "content": string(base.RenderMarkdown([]byte(content), "")), + }) +} diff --git a/routers/preview.go b/routers/preview.go deleted file mode 100644 index cc34c8fa..00000000 --- a/routers/preview.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package routers - -import "github.com/gogits/gogs/modules/middleware" - -func Preview(ctx *middleware.Context) { - content := ctx.Query("content") - // todo : gfm render content - // content = Markdown(content) - ctx.Render.JSON(200, map[string]interface{}{ - "ok": true, - "content": "preview : " + content, - }) -} diff --git a/templates/issue/create.tmpl b/templates/issue/create.tmpl index b8a533a1..f5cec0c0 100644 --- a/templates/issue/create.tmpl +++ b/templates/issue/create.tmpl @@ -15,11 +15,11 @@
- Content with Markdown + Content with Markdown
diff --git a/templates/issue/view.tmpl b/templates/issue/view.tmpl index 431b1d10..c357f535 100644 --- a/templates/issue/view.tmpl +++ b/templates/issue/view.tmpl @@ -69,11 +69,11 @@
- Content with Markdown + Content with Markdown
diff --git a/templates/user/signin.tmpl b/templates/user/signin.tmpl index 49a22626..b6c39af1 100644 --- a/templates/user/signin.tmpl +++ b/templates/user/signin.tmpl @@ -44,7 +44,7 @@
diff --git a/web.go b/web.go index 451e52ff..7725791e 100644 --- a/web.go +++ b/web.go @@ -24,6 +24,7 @@ import ( "github.com/gogits/gogs/modules/middleware" "github.com/gogits/gogs/routers" "github.com/gogits/gogs/routers/admin" + "github.com/gogits/gogs/routers/api/v1" "github.com/gogits/gogs/routers/dev" "github.com/gogits/gogs/routers/repo" "github.com/gogits/gogs/routers/user" @@ -72,6 +73,7 @@ func newMartini() *martini.ClassicMartini { } func runWeb(*cli.Context) { + fmt.Println("Server is running...") globalInit() base.NewServices() checkRunMode() @@ -95,7 +97,10 @@ func runWeb(*cli.Context) { m.Get("/pulls", reqSignIn, user.Pulls) m.Get("/stars", reqSignIn, user.Stars) m.Get("/help", routers.Help) - m.Post("/preview", routers.Preview) + + m.Group("/api/v1", func(r martini.Router) { + r.Post("/markdown", v1.Markdown) + }) avt := avatar.CacheServer("public/img/avatar/", "public/img/avatar_default.jpg") m.Get("/avatar/:hash", avt.ServeHTTP) -- cgit v1.2.3 From cad2ced3945401243d7b644cb613432e1712ab41 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 29 Mar 2014 11:56:00 -0400 Subject: Bug fix --- routers/repo/issue.go | 8 ++++---- templates/install.tmpl | 2 +- templates/issue/view.tmpl | 8 ++++---- web.go | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) (limited to 'web.go') diff --git a/routers/repo/issue.go b/routers/repo/issue.go index b38967f7..337bd4bf 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -175,6 +175,7 @@ func ViewIssue(ctx *middleware.Context, params martini.Params) { ctx.Data["Title"] = issue.Name ctx.Data["Issue"] = issue ctx.Data["Comments"] = comments + ctx.Data["IsIssueOwner"] = issue.PosterId == ctx.User.Id ctx.Data["IsRepoToolbarIssues"] = true ctx.Data["IsRepoToolbarIssuesList"] = false ctx.HTML(200, "issue/view") @@ -217,10 +218,9 @@ func UpdateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat } ctx.JSON(200, map[string]interface{}{ - "ok": true, - "title": issue.Name, - "content": string(base.RenderMarkdown([]byte(issue.Content), "")), - "raw_content": issue.Content, + "ok": true, + "title": issue.Name, + "content": string(base.RenderMarkdown([]byte(issue.Content), "")), }) } diff --git a/templates/install.tmpl b/templates/install.tmpl index d8f05fca..a456ac5f 100644 --- a/templates/install.tmpl +++ b/templates/install.tmpl @@ -133,7 +133,7 @@
- +
-->
-
+ {{if .SignedUser}}
{{.CsrfTokenHtml}} @@ -95,7 +95,7 @@
-
+
{{else}}
Sign up for free to join this conversation. Already have an account? Sign in to comment
{{end}}
- +
- +

@@ -175,7 +180,7 @@
@@ -186,7 +191,7 @@
diff --git a/templates/issue/view.tmpl b/templates/issue/view.tmpl index 0481a33b..91e5250c 100644 --- a/templates/issue/view.tmpl +++ b/templates/issue/view.tmpl @@ -30,37 +30,37 @@
{{range .Comments}} -
- -
-
- {{.Poster.Name}} commented {{TimeSince .Created}} - - Owner -
-
- {{str2html .Content}} -
-
-
- {{end}} - + Owner + +
+ {{str2html .Content}} +
+ + + {{else if eq .Type 1}} +
+ +
+ {{.Poster.Name}} Reopened this issue {{TimeSince .Created}} +
+
+ {{else if eq .Type 2}} +
+
- {user.name} - Closed this - {close.time} + {{.Poster.Name}} Closed this issue {{TimeSince .Created}}
-
-
- -
- {user.name} - Reopened this - {close.time} -
-
--> + + {{end}} + {{end}}
{{if .SignedUser}}
@@ -68,8 +68,7 @@ {{.CsrfTokenHtml}}
-
- Content with Markdown +
Content with Markdown
-
loading...
+
Loading...
{{if .Issue.IsClosed}} - {{else}} + {{else}} {{end}}  
diff --git a/web.go b/web.go index 7098717a..6aabc0e9 100644 --- a/web.go +++ b/web.go @@ -8,19 +8,16 @@ import ( "fmt" "html/template" "net/http" - "strings" "github.com/codegangsta/cli" "github.com/codegangsta/martini" "github.com/gogits/binding" - "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/auth" "github.com/gogits/gogs/modules/avatar" "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/log" - "github.com/gogits/gogs/modules/mailer" "github.com/gogits/gogs/modules/middleware" "github.com/gogits/gogs/routers" "github.com/gogits/gogs/routers/admin" @@ -40,27 +37,6 @@ and it takes care of all the other things for you`, Flags: []cli.Flag{}, } -// globalInit is for global configuration reload-able. -func globalInit() { - base.NewConfigContext() - mailer.NewMailerContext() - models.LoadModelsConfig() - models.LoadRepoConfig() - models.NewRepoContext() - models.NewEngine() -} - -// Check run mode(Default of martini is Dev). -func checkRunMode() { - switch base.Cfg.MustValue("", "RUN_MODE") { - case "prod": - martini.Env = martini.Prod - case "test": - martini.Env = martini.Test - } - log.Info("Run Mode: %s", strings.Title(martini.Env)) -} - func newMartini() *martini.ClassicMartini { r := martini.NewRouter() m := martini.New() @@ -74,9 +50,7 @@ func newMartini() *martini.ClassicMartini { func runWeb(*cli.Context) { fmt.Println("Server is running...") - globalInit() - base.NewServices() - checkRunMode() + routers.GlobalInit() log.Info("%s %s", base.AppName, base.AppVer) m := newMartini() -- cgit v1.2.3 From e60676aec607471ebfff3a463a7cd7050d645672 Mon Sep 17 00:00:00 2001 From: slene Date: Sun, 30 Mar 2014 10:06:53 +0800 Subject: remove repeat routers & change commitd to branchname --- web.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'web.go') diff --git a/web.go b/web.go index 6aabc0e9..465d7da7 100644 --- a/web.go +++ b/web.go @@ -130,8 +130,8 @@ func runWeb(*cli.Context) { r.Post("/issues/:index", binding.BindIgnErr(auth.CreateIssueForm{}), repo.UpdateIssue) r.Post("/comment/:action", repo.Comment) }, reqSignIn, middleware.RepoAssignment(true)) + m.Group("/:username/:reponame", func(r martini.Router) { - r.Get("/commits/:branchname", repo.Commits) r.Get("/issues", repo.Issues) r.Get("/issues/:index", repo.ViewIssue) r.Get("/pulls", repo.Pulls) @@ -140,11 +140,10 @@ func runWeb(*cli.Context) { r.Get("/src/:branchname/**", repo.Single) r.Get("/raw/:branchname/**", repo.SingleDownload) r.Get("/commits/:branchname", repo.Commits) - r.Get("/commits/:branchname", repo.Commits) }, ignSignIn, middleware.RepoAssignment(true)) - m.Get("/:username/:reponame/commit/:commitid/**", ignSignIn, middleware.RepoAssignment(true), repo.Diff) - m.Get("/:username/:reponame/commit/:commitid", ignSignIn, middleware.RepoAssignment(true), repo.Diff) + m.Get("/:username/:reponame/commit/:branchname/**", ignSignIn, middleware.RepoAssignment(true), repo.Diff) + m.Get("/:username/:reponame/commit/:branchname", ignSignIn, middleware.RepoAssignment(true), repo.Diff) m.Group("/:username", func(r martini.Router) { r.Get("/:reponame", middleware.RepoAssignment(true), repo.Single) -- cgit v1.2.3