From bf16d55d6885488083c7e654b402eade98358a88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Wed, 5 Jul 2023 17:28:59 +0200 Subject: [PATCH] Add recently-updated macro --- README.md | 9 +++++ pkg/mark/stdlib/stdlib.go | 69 +++++++++++++++++++++++---------------- 2 files changed, 50 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index bd972ca..5925688 100644 --- a/README.md +++ b/README.md @@ -447,6 +447,15 @@ By default, mark provides several built-in templates and macros: - TitleColor: Text color of the title - BorderStyle: Style of the panel's border +* template `ac:recently-updated` to display a list of most recently changed content + - Spaces: List of Spaces to watch (optional, default is current Space) + - ShowProfilePic: Show profile picture of editor + - Max: Maximum number of changes + - Types: Include these content types only (comments, blogposts, pages) + - Theme: Apperance of the macro (concise, social, sidebar) + - HideHeading: Determines whether the macro hides or displays the text 'Recently Updated' as a title above the list of content + - Labels: Filter the results by label. The macro will display only the pages etc which are tagged with the label(s) you specify here. + * 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 fe872e2..af9f95c 100644 --- a/pkg/mark/stdlib/stdlib.go +++ b/pkg/mark/stdlib/stdlib.go @@ -208,20 +208,20 @@ func templates(api *confluence.API) (*template.Template, error) { `ac:children`: text( ``, - `{{ if .Reverse}}{{ or .Reverse }}{{end}}`, - `{{ if .Sort}}{{ .Sort }}{{end}}`, - `{{ if .Style}}{{ .Style }}{{end}}`, - `{{ if .Page}}`, + `{{ if .Reverse }}{{ or .Reverse }}{{ end }}`, + `{{ if .Sort }}{{ .Sort }}{{ end }}`, + `{{ if .Style }}{{ .Style }}{{ end }}`, + `{{ if .Page }}`, /**/ ``, /**/ ``, /**/ ``, /**/ ``, /**/ ``, - `{{end}}`, - `{{ if .Excerpt}}{{ .Excerpt }}{{end}}`, - `{{ if .First}}{{ .First }}{{end}}`, - `{{ if .Depth}}{{ .Depth }}{{end}}`, - `{{ if .All}}{{ .All }}{{end}}`, + `{{ end }}`, + `{{ if .Excerpt }}{{ .Excerpt }}{{ end }}`, + `{{ if .First }}{{ .First }}{{ end }}`, + `{{ if .Depth }}{{ .Depth }}{{ end }}`, + `{{ if .All }}{{ .All }}{{ end }}`, ``, ), @@ -233,12 +233,12 @@ func templates(api *confluence.API) (*template.Template, error) { `ac:image`: text( ``, - `{{ if .Attachment }}{{end}}`, - `{{ if .Url }}{{end}}`, + `{{ if .Width }} ac:width="{{ .Width }}"{{ end }}`, + `{{ if .Height }} ac:height="{{ .Height }}"{{ end }}`, + `{{ if .Title }} ac:title="{{ .Title }}"{{ end }}`, + `{{ if .Alt }} ac:alt="{{ .Alt }}"{{ end }}>`, + `{{ if .Attachment }}{{ end }}`, + `{{ if .Url }}{{ end }}`, ``, ), @@ -259,9 +259,9 @@ func templates(api *confluence.API) (*template.Template, error) { `ac:iframe`: text( ``, ``, - `{{ if .Frameborder }}{{ .Frameborder }}{{end}}`, - `{{ if .Scrolling }}{{ .Scrolling }}{{end}}`, - `{{ if .Align }}{{ .Align }}{{end}}`, + `{{ if .Frameborder }}{{ .Frameborder }}{{ end }}`, + `{{ if .Scrolling }}{{ .Scrolling }}{{ end }}`, + `{{ if .Align }}{{ .Align }}{{ end }}`, `{{ or .Width "640px" }}`, `{{ or .Height "360px" }}`, ``, @@ -271,14 +271,14 @@ func templates(api *confluence.API) (*template.Template, error) { `ac:blog-posts`: text( ``, - `{{ if .Content }}{{ .Content }}{{end}}`, - `{{ if .Spaces }}{{ .Spaces }}{{end}}`, - `{{ if .Author }}{{ .Author }}{{end}}`, - `{{ if .Time }}{{ .Time }}{{end}}`, - `{{ if .Reverse }}{{ .Reverse }}{{end}}`, - `{{ if .Sort }}{{ .Sort }}{{end}}`, - `{{ if .Max }}{{ .Max }}{{end}}`, - `{{ if .Label }}{{ .Label }}{{end}}`, + `{{ if .Content }}{{ .Content }}{{ end }}`, + `{{ if .Spaces }}{{ .Spaces }}{{ end }}`, + `{{ if .Author }}{{ .Author }}{{ end }}`, + `{{ if .Time }}{{ .Time }}{{ end }}`, + `{{ if .Reverse }}{{ .Reverse }}{{ end }}`, + `{{ if .Sort }}{{ .Sort }}{{ end }}`, + `{{ if .Max }}{{ .Max }}{{ end }}`, + `{{ if .Label }}{{ .Label }}{{ end }}`, ``, ), @@ -288,7 +288,7 @@ func templates(api *confluence.API) (*template.Template, error) { ``, ``, ``, - ``, + ``, ``, ``, ``, @@ -380,7 +380,7 @@ func templates(api *confluence.API) (*template.Template, error) { ``, ``, ``, - ``, + ``, ``, ``, `{{ or .Sort "" }}`, @@ -406,6 +406,19 @@ func templates(api *confluence.API) (*template.Template, error) { ``, ), + /* */ + `ac:recently-updated`: text( + ``, + `{{ if .Spaces }}{{ end }}`, + `{{ or .ShowProfilePic "" }}`, + `{{ or .Types "page, comment, blogpost" }}`, + `{{ or .Max "" }}`, + `{{ or .Labels "" }}`, + `{{ or .HideHeading "" }}`, + `{{ or .Theme "" }}`, + ``, + ), + // TODO(seletskiy): more templates here } { templates, err = templates.New(name).Parse(body)