From 2c073afbec4b9845e8ddd10a4d3f469874fdcd37 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 29 Mar 2014 10:01:52 -0400 Subject: [PATCH] Mirror fix and update --- README.md | 2 ++ models/repo.go | 13 ++++++++++--- routers/{preview.go => api/v1/miscellaneous.go} | 13 +++++++------ templates/issue/create.tmpl | 4 ++-- templates/issue/view.tmpl | 4 ++-- templates/user/signin.tmpl | 2 +- web.go | 7 ++++++- 7 files changed, 30 insertions(+), 15 deletions(-) rename routers/{preview.go => api/v1/miscellaneous.go} (56%) diff --git a/README.md b/README.md index 7d688506d6..e88a247705 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 4be655d287..a848694da6 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/preview.go b/routers/api/v1/miscellaneous.go similarity index 56% rename from routers/preview.go rename to routers/api/v1/miscellaneous.go index cc34c8fa02..0ff1eb04a0 100644 --- a/routers/preview.go +++ b/routers/api/v1/miscellaneous.go @@ -2,16 +2,17 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -package routers +package v1 -import "github.com/gogits/gogs/modules/middleware" +import ( + "github.com/gogits/gogs/modules/base" + "github.com/gogits/gogs/modules/middleware" +) -func Preview(ctx *middleware.Context) { +func Markdown(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, + "content": string(base.RenderMarkdown([]byte(content), "")), }) } diff --git a/templates/issue/create.tmpl b/templates/issue/create.tmpl index b8a533a198..f5cec0c05a 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 431b1d1042..c357f5354c 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 49a2262633..b6c39af1b8 100644 --- a/templates/user/signin.tmpl +++ b/templates/user/signin.tmpl @@ -44,7 +44,7 @@
diff --git a/web.go b/web.go index 451e52ff8c..7725791e84 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)