]> source.dussan.org Git - gitea.git/commitdiff
Add markdown support in organization description (#13549)
authorwULLSnpAXbWZGYDYyhWTKKspEQoaYxXyhoisqHf <61180606+wULLSnpAXbWZGYDYyhWTKKspEQoaYxXyhoisqHf@users.noreply.github.com>
Sun, 15 Nov 2020 16:28:08 +0000 (17:28 +0100)
committerGitHub <noreply@github.com>
Sun, 15 Nov 2020 16:28:08 +0000 (16:28 +0000)
Similarly to how you can write some markdown in user profile description, you can now use the same feature in organization description.
As discussed in discord.
kudos to @mrsdizzie and @zeripath

visualization:
![image](https://user-images.githubusercontent.com/61180606/99115919-8004a200-25f3-11eb-8bbd-ab33de2cabb3.png)

routers/org/home.go
templates/org/home.tmpl

index 9ca0258784549d0f5b37a3cbfcb4f35029e489bb..ff3e1e3e72eb55105b6e5547ed2267e7c22ec7cf 100644 (file)
@@ -10,6 +10,7 @@ import (
        "code.gitea.io/gitea/models"
        "code.gitea.io/gitea/modules/base"
        "code.gitea.io/gitea/modules/context"
+       "code.gitea.io/gitea/modules/markup/markdown"
        "code.gitea.io/gitea/modules/setting"
 )
 
@@ -34,6 +35,9 @@ func Home(ctx *context.Context) {
 
        ctx.Data["PageIsUserProfile"] = true
        ctx.Data["Title"] = org.DisplayName()
+       if len(org.Description) != 0 {
+               ctx.Data["RenderedDescription"] = string(markdown.Render([]byte(org.Description), ctx.Repo.RepoLink, map[string]string{"mode": "document"}))
+       }
 
        var orderBy models.SearchOrderBy
        ctx.Data["SortType"] = ctx.Query("sort")
index fba7de3f1fc38bb7dc2601df9f07c351126cbef5..7f72c61e9224a832ae6b720db96ba8e479071fc0 100644 (file)
@@ -13,7 +13,7 @@
                                </span>
                                {{if .IsOrganizationOwner}}<a class="middle text grey" href="{{.OrgLink}}/settings">{{svg "octicon-gear"}}</a>{{end}}
                        </div>
-                       {{if .Org.Description}}<p class="desc">{{.Org.Description}}</p>{{end}}
+                       {{if $.RenderedDescription}}<p class="render-content markdown">{{$.RenderedDescription|Str2html}}</p>{{end}}
                        <div class="text grey meta">
                                {{if .Org.Location}}<div class="item">{{svg "octicon-location"}} <span>{{.Org.Location}}</span></div>{{end}}
                                {{if .Org.Website}}<div class="item">{{svg "octicon-link"}} <a target="_blank" rel="noopener noreferrer" href="{{.Org.Website}}">{{.Org.Website}}</a></div>{{end}}