diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2021-12-10 10:51:27 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-10 10:51:27 +0800 |
commit | 0a9fcf63a49799ad3b0f146c54879161bac61e10 (patch) | |
tree | e4a6382fc1a2de403f2fec47886348dae5e72d2b /routers/web | |
parent | 719bddcd76610a63dadc8555760072957a11cf30 (diff) | |
download | gitea-0a9fcf63a49799ad3b0f146c54879161bac61e10.tar.gz gitea-0a9fcf63a49799ad3b0f146c54879161bac61e10.zip |
Clean legacy SimpleMDE code (#17926)
Since we are using EasyMDE now, we do not need to keep the SimpleMDE code anymore.
This PR removes all legacy SimpleMDE code, and makes some related changes:
* `createCommentEasyMDE` can accept native DOM element, and it doesn't need `jQuery.data` to store EasyMDE editor object (as discussed about the frontend guideline).
* introduce `getAttachedEasyMDE` to get the attached EasyMDE editor object, it's easier to find all the usage of EasyMDE.
* rename variable names from `$simplemde` to `easyMDE`, the `$` was incorrect because it is a EasyMDE editor, not a jQuery object.
With this PR, it will be easier to do more refactoring or replacing EasyMDE with other editors.
Diffstat (limited to 'routers/web')
-rw-r--r-- | routers/web/repo/commit.go | 2 | ||||
-rw-r--r-- | routers/web/repo/compare.go | 2 | ||||
-rw-r--r-- | routers/web/repo/editor.go | 8 | ||||
-rw-r--r-- | routers/web/repo/issue.go | 6 | ||||
-rw-r--r-- | routers/web/repo/pull.go | 4 | ||||
-rw-r--r-- | routers/web/repo/release.go | 8 | ||||
-rw-r--r-- | routers/web/repo/wiki.go | 8 |
7 files changed, 19 insertions, 19 deletions
diff --git a/routers/web/repo/commit.go b/routers/web/repo/commit.go index ef21017a31..5bc9f9eae9 100644 --- a/routers/web/repo/commit.go +++ b/routers/web/repo/commit.go @@ -253,7 +253,7 @@ func FileHistory(ctx *context.Context) { func Diff(ctx *context.Context) { ctx.Data["PageIsDiff"] = true ctx.Data["RequireHighlightJS"] = true - ctx.Data["RequireSimpleMDE"] = true + ctx.Data["RequireEasyMDE"] = true ctx.Data["RequireTribute"] = true userName := ctx.Repo.Owner.Name diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go index 21311ba97c..c92624df8c 100644 --- a/routers/web/repo/compare.go +++ b/routers/web/repo/compare.go @@ -761,7 +761,7 @@ func CompareDiff(ctx *context.Context) { ctx.Data["IsRepoToolbarCommits"] = true ctx.Data["IsDiffCompare"] = true ctx.Data["RequireTribute"] = true - ctx.Data["RequireSimpleMDE"] = true + ctx.Data["RequireEasyMDE"] = true ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes setTemplateIfExists(ctx, pullRequestTemplateKey, nil, pullRequestTemplateCandidates) ctx.Data["IsAttachmentEnabled"] = setting.Attachment.Enabled diff --git a/routers/web/repo/editor.go b/routers/web/repo/editor.go index d4fc55979c..97f097783a 100644 --- a/routers/web/repo/editor.go +++ b/routers/web/repo/editor.go @@ -69,7 +69,7 @@ func editFile(ctx *context.Context, isNewFile bool) { ctx.Data["PageIsEdit"] = true ctx.Data["IsNewFile"] = isNewFile ctx.Data["RequireHighlightJS"] = true - ctx.Data["RequireSimpleMDE"] = true + ctx.Data["RequireEasyMDE"] = true canCommit := renderCommitRights(ctx) treePath := cleanUploadFileName(ctx.Repo.TreePath) @@ -200,7 +200,7 @@ func editFilePost(ctx *context.Context, form forms.EditRepoFileForm, isNewFile b ctx.Data["PageHasPosted"] = true ctx.Data["IsNewFile"] = isNewFile ctx.Data["RequireHighlightJS"] = true - ctx.Data["RequireSimpleMDE"] = true + ctx.Data["RequireEasyMDE"] = true ctx.Data["TreePath"] = form.TreePath ctx.Data["TreeNames"] = treeNames ctx.Data["TreePaths"] = treePaths @@ -544,7 +544,7 @@ func DeleteFilePost(ctx *context.Context) { func UploadFile(ctx *context.Context) { ctx.Data["PageIsUpload"] = true ctx.Data["RequireTribute"] = true - ctx.Data["RequireSimpleMDE"] = true + ctx.Data["RequireEasyMDE"] = true upload.AddUploadContext(ctx, "repo") canCommit := renderCommitRights(ctx) treePath := cleanUploadFileName(ctx.Repo.TreePath) @@ -580,7 +580,7 @@ func UploadFilePost(ctx *context.Context) { form := web.GetForm(ctx).(*forms.UploadRepoFileForm) ctx.Data["PageIsUpload"] = true ctx.Data["RequireTribute"] = true - ctx.Data["RequireSimpleMDE"] = true + ctx.Data["RequireEasyMDE"] = true upload.AddUploadContext(ctx, "repo") canCommit := renderCommitRights(ctx) diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index df977d2c13..a5eecd0c33 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -786,7 +786,7 @@ func NewIssue(ctx *context.Context) { ctx.Data["PageIsIssueList"] = true ctx.Data["NewIssueChooseTemplate"] = len(ctx.IssueTemplatesFromDefaultBranch()) > 0 ctx.Data["RequireHighlightJS"] = true - ctx.Data["RequireSimpleMDE"] = true + ctx.Data["RequireEasyMDE"] = true ctx.Data["RequireTribute"] = true ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes title := ctx.FormString("title") @@ -959,7 +959,7 @@ func NewIssuePost(ctx *context.Context) { ctx.Data["PageIsIssueList"] = true ctx.Data["NewIssueChooseTemplate"] = len(ctx.IssueTemplatesFromDefaultBranch()) > 0 ctx.Data["RequireHighlightJS"] = true - ctx.Data["RequireSimpleMDE"] = true + ctx.Data["RequireEasyMDE"] = true ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes ctx.Data["IsAttachmentEnabled"] = setting.Attachment.Enabled upload.AddUploadContext(ctx, "comment") @@ -1144,7 +1144,7 @@ func ViewIssue(ctx *context.Context) { ctx.Data["RequireHighlightJS"] = true ctx.Data["RequireTribute"] = true - ctx.Data["RequireSimpleMDE"] = true + ctx.Data["RequireEasyMDE"] = true ctx.Data["IsProjectsEnabled"] = ctx.Repo.CanRead(unit.TypeProjects) ctx.Data["IsAttachmentEnabled"] = setting.Attachment.Enabled upload.AddUploadContext(ctx, "comment") diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go index b08f749cde..3882fdb5b1 100644 --- a/routers/web/repo/pull.go +++ b/routers/web/repo/pull.go @@ -701,7 +701,7 @@ func ViewPullFiles(ctx *context.Context) { setCompareContext(ctx, baseCommit, commit, ctx.Repo.Owner.Name, ctx.Repo.Repository.Name) ctx.Data["RequireHighlightJS"] = true - ctx.Data["RequireSimpleMDE"] = true + ctx.Data["RequireEasyMDE"] = true ctx.Data["RequireTribute"] = true if ctx.Data["Assignees"], err = models.GetRepoAssignees(ctx.Repo.Repository); err != nil { ctx.ServerError("GetAssignees", err) @@ -1045,7 +1045,7 @@ func CompareAndPullRequestPost(ctx *context.Context) { ctx.Data["IsDiffCompare"] = true ctx.Data["IsRepoToolbarCommits"] = true ctx.Data["RequireTribute"] = true - ctx.Data["RequireSimpleMDE"] = true + ctx.Data["RequireEasyMDE"] = true ctx.Data["RequireHighlightJS"] = true ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes ctx.Data["IsAttachmentEnabled"] = setting.Attachment.Enabled diff --git a/routers/web/repo/release.go b/routers/web/repo/release.go index 9bca4e6897..8478cb44ae 100644 --- a/routers/web/repo/release.go +++ b/routers/web/repo/release.go @@ -262,7 +262,7 @@ func LatestRelease(ctx *context.Context) { func NewRelease(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("repo.release.new_release") ctx.Data["PageIsReleaseList"] = true - ctx.Data["RequireSimpleMDE"] = true + ctx.Data["RequireEasyMDE"] = true ctx.Data["RequireTribute"] = true ctx.Data["tag_target"] = ctx.Repo.Repository.DefaultBranch if tagName := ctx.FormString("tag"); len(tagName) > 0 { @@ -296,7 +296,7 @@ func NewReleasePost(ctx *context.Context) { form := web.GetForm(ctx).(*forms.NewReleaseForm) ctx.Data["Title"] = ctx.Tr("repo.release.new_release") ctx.Data["PageIsReleaseList"] = true - ctx.Data["RequireSimpleMDE"] = true + ctx.Data["RequireEasyMDE"] = true ctx.Data["RequireTribute"] = true if ctx.HasError() { @@ -415,7 +415,7 @@ func EditRelease(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("repo.release.edit_release") ctx.Data["PageIsReleaseList"] = true ctx.Data["PageIsEditRelease"] = true - ctx.Data["RequireSimpleMDE"] = true + ctx.Data["RequireEasyMDE"] = true ctx.Data["RequireTribute"] = true ctx.Data["IsAttachmentEnabled"] = setting.Attachment.Enabled upload.AddUploadContext(ctx, "release") @@ -454,7 +454,7 @@ func EditReleasePost(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("repo.release.edit_release") ctx.Data["PageIsReleaseList"] = true ctx.Data["PageIsEditRelease"] = true - ctx.Data["RequireSimpleMDE"] = true + ctx.Data["RequireEasyMDE"] = true ctx.Data["RequireTribute"] = true tagName := ctx.Params("*") diff --git a/routers/web/repo/wiki.go b/routers/web/repo/wiki.go index 7db4394bab..7bce7cf11c 100644 --- a/routers/web/repo/wiki.go +++ b/routers/web/repo/wiki.go @@ -622,7 +622,7 @@ func WikiRaw(ctx *context.Context) { func NewWiki(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("repo.wiki.new_page") ctx.Data["PageIsWiki"] = true - ctx.Data["RequireSimpleMDE"] = true + ctx.Data["RequireEasyMDE"] = true if !ctx.Repo.Repository.HasWiki() { ctx.Data["title"] = "Home" @@ -639,7 +639,7 @@ func NewWikiPost(ctx *context.Context) { form := web.GetForm(ctx).(*forms.NewWikiForm) ctx.Data["Title"] = ctx.Tr("repo.wiki.new_page") ctx.Data["PageIsWiki"] = true - ctx.Data["RequireSimpleMDE"] = true + ctx.Data["RequireEasyMDE"] = true if ctx.HasError() { ctx.HTML(http.StatusOK, tplWikiNew) @@ -677,7 +677,7 @@ func NewWikiPost(ctx *context.Context) { func EditWiki(ctx *context.Context) { ctx.Data["PageIsWiki"] = true ctx.Data["PageIsWikiEdit"] = true - ctx.Data["RequireSimpleMDE"] = true + ctx.Data["RequireEasyMDE"] = true if !ctx.Repo.Repository.HasWiki() { ctx.Redirect(ctx.Repo.RepoLink + "/wiki") @@ -697,7 +697,7 @@ func EditWikiPost(ctx *context.Context) { form := web.GetForm(ctx).(*forms.NewWikiForm) ctx.Data["Title"] = ctx.Tr("repo.wiki.new_page") ctx.Data["PageIsWiki"] = true - ctx.Data["RequireSimpleMDE"] = true + ctx.Data["RequireEasyMDE"] = true if ctx.HasError() { ctx.HTML(http.StatusOK, tplWikiNew) |