Skip to content

Commit

Permalink
Remove RequireHighlightJS field, update plantuml example. (#19615)
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang authored May 5, 2022
1 parent 5a75a54 commit 7b089c4
Show file tree
Hide file tree
Showing 11 changed files with 10 additions and 28 deletions.
17 changes: 10 additions & 7 deletions docs/content/doc/advanced/customizing-gitea.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,18 @@ copy javascript files from https://gitea.com/davidsvantesson/plantuml-code-highl
`$GITEA_CUSTOM/public` folder. Then add the following to `custom/footer.tmpl`:

```html
{{if .RequireHighlightJS}}
<script src="https://your-server.com/deflate.js"></script>
<script src="https://your-server.com/encode.js"></script>
<script src="https://your-server.com/plantuml_codeblock_parse.js"></script>
<script>
<!-- Replace call with address to your plantuml server-->
parsePlantumlCodeBlocks("http://www.plantuml.com/plantuml");
$(async () => {
if (!$('.language-plantuml').length) return;
await Promise.all([
$.getScript('https://your-server.com/deflate.js'),
$.getScript('https://your-server.com/encode.js'),
$.getScript('https://your-server.com/plantuml_codeblock_parse.js'),
]);
// Replace call with address to your plantuml server
parsePlantumlCodeBlocks("https://www.plantuml.com/plantuml");
});
</script>
{{end}}
```

You can then add blocks like the following to your markdown:
Expand Down
1 change: 0 additions & 1 deletion routers/web/explore/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ func Code(ctx *context.Context) {
ctx.Data["queryType"] = queryType
ctx.Data["SearchResults"] = searchResults
ctx.Data["SearchResultLanguages"] = searchResultLanguages
ctx.Data["RequireHighlightJS"] = true
ctx.Data["PageIsViewCode"] = true

pager := context.NewPagination(total, setting.UI.RepoSearchPagingNum, page, 5)
Expand Down
3 changes: 0 additions & 3 deletions routers/web/repo/cherry_pick.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ func CherryPick(ctx *context.Context) {
ctx.Data["commit_message"] = splits[1]
}

ctx.Data["RequireHighlightJS"] = true

canCommit := renderCommitRights(ctx)
ctx.Data["TreePath"] = ""

Expand Down Expand Up @@ -77,7 +75,6 @@ func CherryPickPost(ctx *context.Context) {
ctx.Data["CherryPickType"] = "cherry-pick"
}

ctx.Data["RequireHighlightJS"] = true
canCommit := renderCommitRights(ctx)
branchName := ctx.Repo.BranchName
if form.CommitChoice == frmCommitChoiceNewBranch {
Expand Down
1 change: 0 additions & 1 deletion routers/web/repo/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ func FileHistory(ctx *context.Context) {
// Diff show different from current commit to previous commit
func Diff(ctx *context.Context) {
ctx.Data["PageIsDiff"] = true
ctx.Data["RequireHighlightJS"] = true
ctx.Data["RequireTribute"] = true

userName := ctx.Repo.Owner.Name
Expand Down
2 changes: 0 additions & 2 deletions routers/web/repo/editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ func getParentTreeFields(treePath string) (treeNames, treePaths []string) {
func editFile(ctx *context.Context, isNewFile bool) {
ctx.Data["PageIsEdit"] = true
ctx.Data["IsNewFile"] = isNewFile
ctx.Data["RequireHighlightJS"] = true
canCommit := renderCommitRights(ctx)

treePath := cleanUploadFileName(ctx.Repo.TreePath)
Expand Down Expand Up @@ -197,7 +196,6 @@ func editFilePost(ctx *context.Context, form forms.EditRepoFileForm, isNewFile b
ctx.Data["PageIsEdit"] = true
ctx.Data["PageHasPosted"] = true
ctx.Data["IsNewFile"] = isNewFile
ctx.Data["RequireHighlightJS"] = true
ctx.Data["TreePath"] = form.TreePath
ctx.Data["TreeNames"] = treeNames
ctx.Data["TreePaths"] = treePaths
Expand Down
3 changes: 0 additions & 3 deletions routers/web/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,6 @@ func NewIssue(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.issues.new")
ctx.Data["PageIsIssueList"] = true
ctx.Data["NewIssueChooseTemplate"] = len(ctx.IssueTemplatesFromDefaultBranch()) > 0
ctx.Data["RequireHighlightJS"] = true
ctx.Data["RequireTribute"] = true
ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes
title := ctx.FormString("title")
Expand Down Expand Up @@ -988,7 +987,6 @@ func NewIssuePost(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.issues.new")
ctx.Data["PageIsIssueList"] = true
ctx.Data["NewIssueChooseTemplate"] = len(ctx.IssueTemplatesFromDefaultBranch()) > 0
ctx.Data["RequireHighlightJS"] = true
ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes
ctx.Data["IsAttachmentEnabled"] = setting.Attachment.Enabled
upload.AddUploadContext(ctx, "comment")
Expand Down Expand Up @@ -1177,7 +1175,6 @@ func ViewIssue(ctx *context.Context) {
ctx.Data["IssueType"] = "all"
}

ctx.Data["RequireHighlightJS"] = true
ctx.Data["RequireTribute"] = true
ctx.Data["IsProjectsEnabled"] = ctx.Repo.CanRead(unit.TypeProjects)
ctx.Data["IsAttachmentEnabled"] = setting.Attachment.Enabled
Expand Down
3 changes: 0 additions & 3 deletions routers/web/repo/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ const (

// NewDiffPatch render create patch page
func NewDiffPatch(ctx *context.Context) {
ctx.Data["RequireHighlightJS"] = true

canCommit := renderCommitRights(ctx)

ctx.Data["TreePath"] = ""
Expand Down Expand Up @@ -54,7 +52,6 @@ func NewDiffPatchPost(ctx *context.Context) {
if form.CommitChoice == frmCommitChoiceNewBranch {
branchName = form.NewBranchName
}
ctx.Data["RequireHighlightJS"] = true
ctx.Data["TreePath"] = ""
ctx.Data["BranchLink"] = ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL()
ctx.Data["FileContent"] = form.Content
Expand Down
2 changes: 0 additions & 2 deletions routers/web/repo/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,6 @@ func ViewPullFiles(ctx *context.Context) {

setCompareContext(ctx, baseCommit, commit, ctx.Repo.Owner.Name, ctx.Repo.Repository.Name)

ctx.Data["RequireHighlightJS"] = true
ctx.Data["RequireTribute"] = true
if ctx.Data["Assignees"], err = models.GetRepoAssignees(ctx.Repo.Repository); err != nil {
ctx.ServerError("GetAssignees", err)
Expand Down Expand Up @@ -1050,7 +1049,6 @@ func CompareAndPullRequestPost(ctx *context.Context) {
ctx.Data["IsDiffCompare"] = true
ctx.Data["IsRepoToolbarCommits"] = true
ctx.Data["RequireTribute"] = true
ctx.Data["RequireHighlightJS"] = true
ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes
ctx.Data["IsAttachmentEnabled"] = setting.Attachment.Enabled
upload.AddUploadContext(ctx, "comment")
Expand Down
1 change: 0 additions & 1 deletion routers/web/repo/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ func Search(ctx *context.Context) {
ctx.Data["SourcePath"] = ctx.Repo.Repository.HTMLURL()
ctx.Data["SearchResults"] = searchResults
ctx.Data["SearchResultLanguages"] = searchResultLanguages
ctx.Data["RequireHighlightJS"] = true
ctx.Data["PageIsViewCode"] = true

pager := context.NewPagination(total, setting.UI.RepoSearchPagingNum, page, 5)
Expand Down
2 changes: 0 additions & 2 deletions routers/web/repo/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -735,8 +735,6 @@ func PackagistHooksNewPost(ctx *context.Context) {
}

func checkWebhook(ctx *context.Context) (*orgRepoCtx, *webhook.Webhook) {
ctx.Data["RequireHighlightJS"] = true

orCtx, err := getOrgRepoCtx(ctx)
if err != nil {
ctx.ServerError("getOrgRepoCtx", err)
Expand Down
3 changes: 0 additions & 3 deletions routers/web/repo/wiki.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ func renderViewPage(ctx *context.Context) (*git.Repository, *git.TreeEntry) {
ctx.Data["old_title"] = pageName
ctx.Data["Title"] = pageName
ctx.Data["title"] = pageName
ctx.Data["RequireHighlightJS"] = true

isSideBar := pageName == "_Sidebar"
isFooter := pageName == "_Footer"
Expand Down Expand Up @@ -308,7 +307,6 @@ func renderRevisionPage(ctx *context.Context) (*git.Repository, *git.TreeEntry)
ctx.Data["old_title"] = pageName
ctx.Data["Title"] = pageName
ctx.Data["title"] = pageName
ctx.Data["RequireHighlightJS"] = true
ctx.Data["Username"] = ctx.Repo.Owner.Name
ctx.Data["Reponame"] = ctx.Repo.Repository.Name

Expand Down Expand Up @@ -384,7 +382,6 @@ func renderEditPage(ctx *context.Context) {
ctx.Data["old_title"] = pageName
ctx.Data["Title"] = pageName
ctx.Data["title"] = pageName
ctx.Data["RequireHighlightJS"] = true

// lookup filename in wiki - get filecontent, gitTree entry , real filename
data, entry, _, noEntry := wikiContentsByName(ctx, commit, pageName)
Expand Down

0 comments on commit 7b089c4

Please sign in to comment.