diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 815cba6eecaf1..1dff0a2777a74 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -697,7 +697,7 @@ uid = UID webauthn = Two-Factor Authentication (Security Keys) public_profile = Public Profile -biography_placeholder = Tell us a little bit about yourself! (You can use Markdown) +biography_placeholder = Tell us a little bit about yourself! location_placeholder = Share your approximate location with others profile_desc = Control how your profile is show to other users. Your primary email address will be used for notifications, password recovery and web-based Git operations. password_username_disabled = Non-local users are not allowed to change their username. Please contact your site administrator for more details. diff --git a/routers/web/org/projects.go b/routers/web/org/projects.go index eea539f6d9fb5..e8ca91f2faff7 100644 --- a/routers/web/org/projects.go +++ b/routers/web/org/projects.go @@ -16,6 +16,8 @@ import ( "code.gitea.io/gitea/models/unit" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/json" + "code.gitea.io/gitea/modules/markup" + "code.gitea.io/gitea/modules/markup/markdown" "code.gitea.io/gitea/modules/optional" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/templates" @@ -145,6 +147,10 @@ func RenderNewProject(ctx *context.Context) { ctx.Data["PageIsViewProjects"] = true ctx.Data["HomeLink"] = ctx.ContextUser.HomeLink() ctx.Data["CancelLink"] = ctx.ContextUser.HomeLink() + "/-/projects" + ctx.Data["ProjectMarkdownPreviewURL"] = fmt.Sprintf("%s/-/markup", ctx.ContextUser.HomeLink()) + ctx.Data["ProjectMarkdownPreviewContext"] = ctx.ContextUser.HomeLink() + ctx.Data["ProjectMarkdownPreviewMode"] = "markdown" + ctx.Data["ProjectMarkdownHideRepoButtons"] = true shared_user.RenderUserHeader(ctx) err := shared_user.LoadHeaderCount(ctx) @@ -260,6 +266,10 @@ func RenderEditProject(ctx *context.Context) { ctx.Data["HomeLink"] = ctx.ContextUser.HomeLink() ctx.Data["card_type"] = p.CardType ctx.Data["CancelLink"] = fmt.Sprintf("%s/-/projects/%d", ctx.ContextUser.HomeLink(), p.ID) + ctx.Data["ProjectMarkdownPreviewURL"] = fmt.Sprintf("%s/-/markup", ctx.ContextUser.HomeLink()) + ctx.Data["ProjectMarkdownPreviewContext"] = ctx.ContextUser.HomeLink() + ctx.Data["ProjectMarkdownPreviewMode"] = "markdown" + ctx.Data["ProjectMarkdownHideRepoButtons"] = true ctx.HTML(http.StatusOK, tplProjectsNew) } diff --git a/routers/web/repo/projects.go b/routers/web/repo/projects.go index fdeead57035a7..8aeafc47519e5 100644 --- a/routers/web/repo/projects.go +++ b/routers/web/repo/projects.go @@ -137,6 +137,10 @@ func RenderNewProject(ctx *context.Context) { ctx.Data["CardTypes"] = project_model.GetCardConfig() ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(unit.TypeProjects) ctx.Data["CancelLink"] = ctx.Repo.Repository.Link() + "/projects" + ctx.Data["ProjectMarkdownPreviewURL"] = fmt.Sprintf("%s/markup", ctx.Repo.Repository.Link()) + ctx.Data["ProjectMarkdownPreviewContext"] = ctx.Repo.Repository.Link() + ctx.Data["ProjectMarkdownPreviewMode"] = "comment" + ctx.Data["ProjectMarkdownHideRepoButtons"] = false ctx.HTML(http.StatusOK, tplProjectsNew) } @@ -240,6 +244,10 @@ func RenderEditProject(ctx *context.Context) { ctx.Data["card_type"] = p.CardType ctx.Data["redirect"] = ctx.FormString("redirect") ctx.Data["CancelLink"] = fmt.Sprintf("%s/projects/%d", ctx.Repo.Repository.Link(), p.ID) + ctx.Data["ProjectMarkdownPreviewURL"] = fmt.Sprintf("%s/markup", ctx.Repo.Repository.Link()) + ctx.Data["ProjectMarkdownPreviewContext"] = ctx.Repo.Repository.Link() + ctx.Data["ProjectMarkdownPreviewMode"] = "comment" + ctx.Data["ProjectMarkdownHideRepoButtons"] = false ctx.HTML(http.StatusOK, tplProjectsNew) } diff --git a/routers/web/web.go b/routers/web/web.go index 9f9a1bb0988e6..682c8aa0f6147 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -974,6 +974,8 @@ func registerRoutes(m *web.Router) { // end "/repo": create, migrate, search m.Group("/{username}/-", func() { + m.Post("/markup", web.Bind(structs.MarkupOption{}), misc.Markup) + if setting.Packages.Enabled { m.Group("/packages", func() { m.Get("", user.ListPackages) diff --git a/templates/org/settings/options.tmpl b/templates/org/settings/options.tmpl index 62debfc0aefac..87c1b6d066fd4 100644 --- a/templates/org/settings/options.tmpl +++ b/templates/org/settings/options.tmpl @@ -22,9 +22,17 @@ -
+
- + {{template "shared/combomarkdowneditor" (dict + "MarkdownPreviewUrl" (printf "%s/-/markup" .Org.HomeLink) + "MarkdownPreviewContext" .Org.HomeLink + "MarkdownPreviewMode" "markdown" + "TextareaName" "description" + "TextareaContent" .Org.Description + "TextareaMaxLength" 255 + "HideRepoButtons" true + )}}
diff --git a/templates/projects/new.tmpl b/templates/projects/new.tmpl index bd173b54bcec9..afb7819a8e6b8 100644 --- a/templates/projects/new.tmpl +++ b/templates/projects/new.tmpl @@ -16,9 +16,17 @@
-
+
- + {{template "shared/combomarkdowneditor" (dict + "MarkdownPreviewUrl" $.ProjectMarkdownPreviewURL + "MarkdownPreviewContext" $.ProjectMarkdownPreviewContext + "MarkdownPreviewMode" $.ProjectMarkdownPreviewMode + "TextareaName" "content" + "TextareaContent" .content + "TextareaPlaceholder" (ctx.Locale.Tr "repo.projects.description_placeholder") + "HideRepoButtons" $.ProjectMarkdownHideRepoButtons + )}}
{{if not .PageIsEditProjects}} diff --git a/templates/repo/release/new.tmpl b/templates/repo/release/new.tmpl index c01f9a421b982..c601f30e97229 100644 --- a/templates/repo/release/new.tmpl +++ b/templates/repo/release/new.tmpl @@ -48,7 +48,7 @@
-
+
{{template "shared/combomarkdowneditor" (dict "MarkdownPreviewUrl" (print .Repository.Link "/markup") "MarkdownPreviewContext" .RepoLink diff --git a/templates/repo/wiki/new.tmpl b/templates/repo/wiki/new.tmpl index 0f10e60c4f8fc..ab74417168166 100644 --- a/templates/repo/wiki/new.tmpl +++ b/templates/repo/wiki/new.tmpl @@ -25,6 +25,7 @@ {{template "shared/combomarkdowneditor" (dict "MarkdownPreviewUrl" (print .Repository.Link "/markup") "MarkdownPreviewContext" .RepoLink + "MarkdownPreviewMode" "gfm" "TextareaName" "content" "TextareaPlaceholder" (ctx.Locale.Tr "repo.wiki.page_content") "TextareaAriaLabel" (ctx.Locale.Tr "repo.wiki.page_content") diff --git a/templates/shared/combomarkdowneditor.tmpl b/templates/shared/combomarkdowneditor.tmpl index a0145ab297b49..569acc72bf014 100644 --- a/templates/shared/combomarkdowneditor.tmpl +++ b/templates/shared/combomarkdowneditor.tmpl @@ -3,19 +3,22 @@ Template Attributes: * ContainerId: id attribute for the container element * ContainerClasses: additional classes for the container element * MarkdownPreviewUrl: preview url for the preview tab +* MarkdownPreviewMode: the preview mode. possible values are markdown, comment, gfm and file. default is comment. * MarkdownPreviewContext: preview context for the preview tab * TextareaName: name attribute for the textarea * TextareaContent: content for the textarea * TextareaPlaceholder: placeholder attribute for the textarea * TextareaAriaLabel: aria-label attribute for the textarea +* TextareaMaxLength: maxlength attribute for the textarea * DropzoneParentContainer: container for file upload (leave it empty if no upload) * DisableAutosize: whether to disable automatic height resizing +* HideRepoButtons: hide buttons that belong to repos (issue references) */}}
{{if .MarkdownPreviewUrl}} {{end}}
@@ -37,7 +40,9 @@ Template Attributes:
{{svg "octicon-mention"}} - {{svg "octicon-cross-reference"}} + {{if not .HideRepoButtons}} + {{svg "octicon-cross-reference"}} + {{end}}
@@ -45,7 +50,7 @@ Template Attributes:
- +