From 6a63913a1e5040aa28d01d1f68731bf400802054 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Mon, 22 May 2023 20:50:26 +0200 Subject: [PATCH] Add user profile macro --- README.md | 5 ++++- pkg/mark/stdlib/stdlib.go | 22 +++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fe41f30..a12f559 100644 --- a/README.md +++ b/README.md @@ -172,7 +172,7 @@ The key's value must be a string which defines the template's content. If you set the Layout to plain, the page layout can be customized using HTML comments inside the markdown: -``` +```markdown @@ -421,6 +421,9 @@ By default, mark provides several built-in templates and macros: - Title: Defines the text next to the expand/collapse icon. - Body: The Text that it is expanded to. +* template: `ac:profile` to display a short summary of a given Confluence user's profile. + - Name: The username of the Confluence user whose profile summary you wish to show. + * macro `@{...}` to mention user by name specified in the braces. ## Template & Macros Usecases diff --git a/pkg/mark/stdlib/stdlib.go b/pkg/mark/stdlib/stdlib.go index 3a1cb2a..2025492 100644 --- a/pkg/mark/stdlib/stdlib.go +++ b/pkg/mark/stdlib/stdlib.go @@ -136,7 +136,11 @@ func templates(api *confluence.API) (*template.Template, error) { `ac:link:user`: text( `{{ with .Name | user }}`, /**/ ``, - /**/ ``, + /**/ `{{ with .AccountID }}`, + /****/ ``, + /**/ `{{ else }}`, + /****/ ``, + /**/ `{{ end }}`, /**/ ``, `{{ else }}`, /**/ `{{ .Name }}`, @@ -319,6 +323,22 @@ func templates(api *confluence.API) (*template.Template, error) { ``, ), + /* https://confluence.atlassian.com/conf59/user-profile-macro-792499223.html */ + + `ac:profile`: text( + `{{ with .Name | user }}`, + `{{printf "\n"}}`, + `{{printf "\n"}}`, + `{{ with .AccountID }}`, + /**/ `{{printf "\n"}}`, + `{{ else }}`, + /**/ ``, + `{{ end }}`, + `{{printf "\n"}}`, + `{{printf "\n"}}`, + `{{ end }}`, + ), + // TODO(seletskiy): more templates here } { templates, err = templates.New(name).Parse(body)