summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/miscellaneous.go36
-rw-r--r--routers/dashboard.go14
-rw-r--r--routers/install.go12
3 files changed, 48 insertions, 14 deletions
diff --git a/routers/api/v1/miscellaneous.go b/routers/api/v1/miscellaneous.go
index babdfce9b2..30751efcca 100644
--- a/routers/api/v1/miscellaneous.go
+++ b/routers/api/v1/miscellaneous.go
@@ -5,14 +5,38 @@
package v1
import (
+ "io/ioutil"
+ "strings"
+
+ "github.com/gogits/gogs/modules/auth/apiv1"
"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), ctx.Query("repoLink"))),
- })
+const DOC_URL = "http://gogs.io/docs"
+
+// Render an arbitrary Markdown document.
+func Markdown(ctx *middleware.Context, form apiv1.MarkdownForm) {
+ if ctx.HasApiError() {
+ ctx.JSON(422, base.ApiJsonErr{ctx.GetErrMsg(), DOC_URL})
+ return
+ }
+
+ switch form.Mode {
+ case "gfm":
+ ctx.Write(base.RenderMarkdown([]byte(form.Text),
+ base.AppUrl+strings.TrimPrefix(form.Context, "/")))
+ default:
+ ctx.Write(base.RenderRawMarkdown([]byte(form.Text), ""))
+ }
+}
+
+// Render a Markdown document in raw mode.
+func MarkdownRaw(ctx *middleware.Context) {
+ body, err := ioutil.ReadAll(ctx.Req.Body)
+ if err != nil {
+ ctx.JSON(422, base.ApiJsonErr{err.Error(), DOC_URL})
+ return
+ }
+ ctx.Write(base.RenderRawMarkdown(body, ""))
}
diff --git a/routers/dashboard.go b/routers/dashboard.go
index 71bdcc9f13..78533127fd 100644
--- a/routers/dashboard.go
+++ b/routers/dashboard.go
@@ -24,9 +24,19 @@ func Home(ctx *middleware.Context) {
return
}
- repos, _ := models.GetRecentUpdatedRepositories()
+ // Show recent updated repositoires for new visiters.
+ repos, err := models.GetRecentUpdatedRepositories()
+ if err != nil {
+ ctx.Handle(500, "dashboard.Home(GetRecentUpdatedRepositories)", err)
+ return
+ }
+
for _, repo := range repos {
- repo.Owner, _ = models.GetUserById(repo.OwnerId)
+ repo.Owner, err = models.GetUserById(repo.OwnerId)
+ if err != nil {
+ ctx.Handle(500, "dashboard.Home(GetUserById)", err)
+ return
+ }
}
ctx.Data["Repos"] = repos
ctx.Data["PageIsHome"] = true
diff --git a/routers/install.go b/routers/install.go
index 38bf896f4e..53ce90d5b6 100644
--- a/routers/install.go
+++ b/routers/install.go
@@ -78,7 +78,7 @@ func Install(ctx *middleware.Context, form auth.InstallForm) {
ctx.Data["Title"] = "Install"
ctx.Data["PageIsInstall"] = true
- // Get and assign value to install form.
+ // Get and assign values to install form.
if len(form.Host) == 0 {
form.Host = models.DbCfg.Host
}
@@ -109,11 +109,11 @@ func Install(ctx *middleware.Context, form auth.InstallForm) {
}
renderDbOption(ctx)
- curDbValue := ""
+ curDbOp := ""
if models.EnableSQLite3 {
- curDbValue = "SQLite3" // Default when enabled.
+ curDbOp = "SQLite3" // Default when enabled.
}
- ctx.Data["CurDbValue"] = curDbValue
+ ctx.Data["CurDbOption"] = curDbOp
auth.AssignForm(form, ctx.Data)
ctx.HTML(200, "install")
@@ -129,7 +129,7 @@ func InstallPost(ctx *middleware.Context, form auth.InstallForm) {
ctx.Data["PageIsInstall"] = true
renderDbOption(ctx)
- ctx.Data["CurDbValue"] = form.Database
+ ctx.Data["CurDbOption"] = form.Database
if ctx.HasError() {
ctx.HTML(200, "install")
@@ -157,7 +157,7 @@ func InstallPost(ctx *middleware.Context, form auth.InstallForm) {
if err := models.NewTestEngine(x); err != nil {
if strings.Contains(err.Error(), `Unknown database type: sqlite3`) {
ctx.RenderWithErr("Your release version does not support SQLite3, please download the official binary version "+
- "from https://github.com/gogits/gogs/wiki/Install-from-binary, NOT the gobuild version.", "install", &form)
+ "from http://gogs.io/docs/installation/install_from_binary.md, NOT the gobuild version.", "install", &form)
} else {
ctx.RenderWithErr("Database setting is not correct: "+err.Error(), "install", &form)
}