|
|
|
@ -9,6 +9,7 @@ import (
|
|
|
|
|
"fmt" |
|
|
|
|
"net/http" |
|
|
|
|
"path" |
|
|
|
|
"reflect" |
|
|
|
|
"strings" |
|
|
|
|
|
|
|
|
|
"code.gitea.io/gitea/models" |
|
|
|
@ -158,18 +159,30 @@ func Profile(ctx *context.Context) {
|
|
|
|
|
ctx.Data["HeatmapData"] = data |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if len(ctxUser.Description) != 0 { |
|
|
|
|
content, err := markdown.RenderString(&markup.RenderContext{ |
|
|
|
|
URLPrefix: ctx.Repo.RepoLink, |
|
|
|
|
Metas: map[string]string{"mode": "document"}, |
|
|
|
|
GitRepo: ctx.Repo.GitRepo, |
|
|
|
|
Ctx: ctx, |
|
|
|
|
}, ctxUser.Description) |
|
|
|
|
if err != nil { |
|
|
|
|
ctx.ServerError("RenderString", err) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
ctx.Data["RenderedDescription"] = content |
|
|
|
|
var renderErr error |
|
|
|
|
|
|
|
|
|
renderErr = getRenderedTextField(ctx, ctxUser, "Description") |
|
|
|
|
if renderErr != nil { |
|
|
|
|
ctx.ServerError("RenderString", renderErr) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
renderErr = getRenderedTextField(ctx, ctxUser, "Competences") |
|
|
|
|
if renderErr != nil { |
|
|
|
|
ctx.ServerError("RenderString", renderErr) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
renderErr = getRenderedTextField(ctx, ctxUser, "Resources") |
|
|
|
|
if renderErr != nil { |
|
|
|
|
ctx.ServerError("RenderString", renderErr) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
renderErr = getRenderedTextField(ctx, ctxUser, "Interests") |
|
|
|
|
if renderErr != nil { |
|
|
|
|
ctx.ServerError("RenderString", renderErr) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
showPrivate := ctx.IsSigned && (ctx.User.IsAdmin || ctx.User.ID == ctxUser.ID) |
|
|
|
@ -377,3 +390,28 @@ func Action(ctx *context.Context) {
|
|
|
|
|
// FIXME: We should check this URL and make sure that it's a valid Gitea URL
|
|
|
|
|
ctx.RedirectToFirst(ctx.FormString("redirect_to"), u.HomeLink()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func getTextField(user *user_model.User, fieldName string) string { |
|
|
|
|
reflectedObj := reflect.ValueOf(user) |
|
|
|
|
dynamicField := reflect.Indirect(reflectedObj).FieldByName(fieldName) |
|
|
|
|
return dynamicField.String() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func getRenderedTextField(ctx *context.Context, ctxUser *user_model.User, fieldName string) error { |
|
|
|
|
var err error = nil |
|
|
|
|
var content string |
|
|
|
|
fieldVal := getTextField(ctxUser, fieldName) |
|
|
|
|
if len(fieldVal) != 0 { |
|
|
|
|
content, err = markdown.RenderString(&markup.RenderContext{ |
|
|
|
|
URLPrefix: ctx.Repo.RepoLink, |
|
|
|
|
Metas: map[string]string{"mode": "document"}, |
|
|
|
|
GitRepo: ctx.Repo.GitRepo, |
|
|
|
|
Ctx: ctx, |
|
|
|
|
}, fieldVal) |
|
|
|
|
if err == nil { |
|
|
|
|
renderedFieldName := fmt.Sprintf("Rendered%s", fieldName) |
|
|
|
|
ctx.Data[renderedFieldName] = content |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|