mirror of
				https://github.com/kovetskiy/mark.git
				synced 2025-11-04 14:27:36 +08:00 
			
		
		
		
	Add recently-updated macro
This commit is contained in:
		
							parent
							
								
									ac982f3077
								
							
						
					
					
						commit
						bf16d55d68
					
				@ -447,6 +447,15 @@ By default, mark provides several built-in templates and macros:
 | 
				
			|||||||
  - TitleColor: Text color of the title
 | 
					  - TitleColor: Text color of the title
 | 
				
			||||||
  - BorderStyle: Style of the panel's border
 | 
					  - 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.
 | 
					* macro `@{...}` to mention user by name specified in the braces.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Template & Macros Usecases
 | 
					## Template & Macros Usecases
 | 
				
			||||||
 | 
				
			|||||||
@ -208,20 +208,20 @@ func templates(api *confluence.API) (*template.Template, error) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		`ac:children`: text(
 | 
							`ac:children`: text(
 | 
				
			||||||
			`<ac:structured-macro ac:name="children">`,
 | 
								`<ac:structured-macro ac:name="children">`,
 | 
				
			||||||
			`{{ if .Reverse}}<ac:parameter ac:name="reverse">{{ or .Reverse }}</ac:parameter>{{end}}`,
 | 
								`{{ if .Reverse }}<ac:parameter ac:name="reverse">{{ or .Reverse }}</ac:parameter>{{ end }}`,
 | 
				
			||||||
			`{{ if .Sort}}<ac:parameter ac:name="sort">{{ .Sort }}</ac:parameter>{{end}}`,
 | 
								`{{ if .Sort }}<ac:parameter ac:name="sort">{{ .Sort }}</ac:parameter>{{ end }}`,
 | 
				
			||||||
			`{{ if .Style}}<ac:parameter ac:name="style">{{ .Style }}</ac:parameter>{{end}}`,
 | 
								`{{ if .Style }}<ac:parameter ac:name="style">{{ .Style }}</ac:parameter>{{ end }}`,
 | 
				
			||||||
			`{{ if .Page}}`,
 | 
								`{{ if .Page }}`,
 | 
				
			||||||
			/**/ `<ac:parameter ac:name="page">`,
 | 
								/**/ `<ac:parameter ac:name="page">`,
 | 
				
			||||||
			/**/ `<ac:link>`,
 | 
								/**/ `<ac:link>`,
 | 
				
			||||||
			/**/ `<ri:page ri:content-title="{{ .Page }}"/>`,
 | 
								/**/ `<ri:page ri:content-title="{{ .Page }}"/>`,
 | 
				
			||||||
			/**/ `</ac:link>`,
 | 
								/**/ `</ac:link>`,
 | 
				
			||||||
			/**/ `</ac:parameter>`,
 | 
								/**/ `</ac:parameter>`,
 | 
				
			||||||
			`{{end}}`,
 | 
								`{{ end }}`,
 | 
				
			||||||
			`{{ if .Excerpt}}<ac:parameter ac:name="excerptType">{{ .Excerpt }}</ac:parameter>{{end}}`,
 | 
								`{{ if .Excerpt }}<ac:parameter ac:name="excerptType">{{ .Excerpt }}</ac:parameter>{{ end }}`,
 | 
				
			||||||
			`{{ if .First}}<ac:parameter ac:name="first">{{ .First }}</ac:parameter>{{end}}`,
 | 
								`{{ if .First }}<ac:parameter ac:name="first">{{ .First }}</ac:parameter>{{ end }}`,
 | 
				
			||||||
			`{{ if .Depth}}<ac:parameter ac:name="depth">{{ .Depth }}</ac:parameter>{{end}}`,
 | 
								`{{ if .Depth }}<ac:parameter ac:name="depth">{{ .Depth }}</ac:parameter>{{ end }}`,
 | 
				
			||||||
			`{{ if .All}}<ac:parameter ac:name="all">{{ .All }}</ac:parameter>{{end}}`,
 | 
								`{{ if .All }}<ac:parameter ac:name="all">{{ .All }}</ac:parameter>{{ end }}`,
 | 
				
			||||||
			`</ac:structured-macro>`,
 | 
								`</ac:structured-macro>`,
 | 
				
			||||||
		),
 | 
							),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -233,12 +233,12 @@ func templates(api *confluence.API) (*template.Template, error) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		`ac:image`: text(
 | 
							`ac:image`: text(
 | 
				
			||||||
			`<ac:image`,
 | 
								`<ac:image`,
 | 
				
			||||||
			`{{ if .Width }} ac:width="{{ .Width }}"{{end}}`,
 | 
								`{{ if .Width }} ac:width="{{ .Width }}"{{ end }}`,
 | 
				
			||||||
			`{{ if .Height }} ac:height="{{ .Height }}"{{end}}`,
 | 
								`{{ if .Height }} ac:height="{{ .Height }}"{{ end }}`,
 | 
				
			||||||
			`{{ if .Title }} ac:title="{{ .Title }}"{{end}}`,
 | 
								`{{ if .Title }} ac:title="{{ .Title }}"{{ end }}`,
 | 
				
			||||||
			`{{ if .Alt }} ac:alt="{{ .Alt }}"{{end}}>`,
 | 
								`{{ if .Alt }} ac:alt="{{ .Alt }}"{{ end }}>`,
 | 
				
			||||||
			`{{ if .Attachment }}<ri:attachment ri:filename="{{ .Attachment | convertAttachment }}"/>{{end}}`,
 | 
								`{{ if .Attachment }}<ri:attachment ri:filename="{{ .Attachment | convertAttachment }}"/>{{ end }}`,
 | 
				
			||||||
			`{{ if .Url }}<ri:url ri:value="{{ .Url }}"/>{{end}}`,
 | 
								`{{ if .Url }}<ri:url ri:value="{{ .Url }}"/>{{ end }}`,
 | 
				
			||||||
			`</ac:image>`,
 | 
								`</ac:image>`,
 | 
				
			||||||
		),
 | 
							),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -259,9 +259,9 @@ func templates(api *confluence.API) (*template.Template, error) {
 | 
				
			|||||||
		`ac:iframe`: text(
 | 
							`ac:iframe`: text(
 | 
				
			||||||
			`<ac:structured-macro ac:name="iframe">`,
 | 
								`<ac:structured-macro ac:name="iframe">`,
 | 
				
			||||||
			`<ac:parameter ac:name="src"><ri:url ri:value="{{ .URL }}" /></ac:parameter>`,
 | 
								`<ac:parameter ac:name="src"><ri:url ri:value="{{ .URL }}" /></ac:parameter>`,
 | 
				
			||||||
			`{{ if .Frameborder }}<ac:parameter ac:name="frameborder">{{ .Frameborder }}</ac:parameter>{{end}}`,
 | 
								`{{ if .Frameborder }}<ac:parameter ac:name="frameborder">{{ .Frameborder }}</ac:parameter>{{ end }}`,
 | 
				
			||||||
			`{{ if .Scrolling }}<ac:parameter ac:name="id">{{ .Scrolling }}</ac:parameter>{{end}}`,
 | 
								`{{ if .Scrolling }}<ac:parameter ac:name="id">{{ .Scrolling }}</ac:parameter>{{ end }}`,
 | 
				
			||||||
			`{{ if .Align }}<ac:parameter ac:name="align">{{ .Align }}</ac:parameter>{{end}}`,
 | 
								`{{ if .Align }}<ac:parameter ac:name="align">{{ .Align }}</ac:parameter>{{ end }}`,
 | 
				
			||||||
			`<ac:parameter ac:name="width">{{ or .Width "640px" }}</ac:parameter>`,
 | 
								`<ac:parameter ac:name="width">{{ or .Width "640px" }}</ac:parameter>`,
 | 
				
			||||||
			`<ac:parameter ac:name="height">{{ or .Height "360px" }}</ac:parameter>`,
 | 
								`<ac:parameter ac:name="height">{{ or .Height "360px" }}</ac:parameter>`,
 | 
				
			||||||
			`</ac:structured-macro>`,
 | 
								`</ac:structured-macro>`,
 | 
				
			||||||
@ -271,14 +271,14 @@ func templates(api *confluence.API) (*template.Template, error) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		`ac:blog-posts`: text(
 | 
							`ac:blog-posts`: text(
 | 
				
			||||||
			`<ac:structured-macro ac:name="blog-posts">`,
 | 
								`<ac:structured-macro ac:name="blog-posts">`,
 | 
				
			||||||
			`{{ if .Content }}<ac:parameter ac:name="content">{{ .Content }}</ac:parameter>{{end}}`,
 | 
								`{{ if .Content }}<ac:parameter ac:name="content">{{ .Content }}</ac:parameter>{{ end }}`,
 | 
				
			||||||
			`{{ if .Spaces }}<ac:parameter ac:name="spaces">{{ .Spaces }}</ac:parameter>{{end}}`,
 | 
								`{{ if .Spaces }}<ac:parameter ac:name="spaces">{{ .Spaces }}</ac:parameter>{{ end }}`,
 | 
				
			||||||
			`{{ if .Author }}<ac:parameter ac:name="author">{{ .Author }}</ac:parameter>{{end}}`,
 | 
								`{{ if .Author }}<ac:parameter ac:name="author">{{ .Author }}</ac:parameter>{{ end }}`,
 | 
				
			||||||
			`{{ if .Time }}<ac:parameter ac:name="time">{{ .Time }}</ac:parameter>{{end}}`,
 | 
								`{{ if .Time }}<ac:parameter ac:name="time">{{ .Time }}</ac:parameter>{{ end }}`,
 | 
				
			||||||
			`{{ if .Reverse }}<ac:parameter ac:name="reverse">{{ .Reverse }}</ac:parameter>{{end}}`,
 | 
								`{{ if .Reverse }}<ac:parameter ac:name="reverse">{{ .Reverse }}</ac:parameter>{{ end }}`,
 | 
				
			||||||
			`{{ if .Sort }}<ac:parameter ac:name="sort">{{ .Sort }}</ac:parameter>{{end}}`,
 | 
								`{{ if .Sort }}<ac:parameter ac:name="sort">{{ .Sort }}</ac:parameter>{{ end }}`,
 | 
				
			||||||
			`{{ if .Max }}<ac:parameter ac:name="max">{{ .Max }}</ac:parameter>{{end}}`,
 | 
								`{{ if .Max }}<ac:parameter ac:name="max">{{ .Max }}</ac:parameter>{{ end }}`,
 | 
				
			||||||
			`{{ if .Label }}<ac:parameter ac:name="label">{{ .Label }}</ac:parameter>{{end}}`,
 | 
								`{{ if .Label }}<ac:parameter ac:name="label">{{ .Label }}</ac:parameter>{{ end }}`,
 | 
				
			||||||
			`</ac:structured-macro>`,
 | 
								`</ac:structured-macro>`,
 | 
				
			||||||
		),
 | 
							),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -288,7 +288,7 @@ func templates(api *confluence.API) (*template.Template, error) {
 | 
				
			|||||||
			`<ac:structured-macro ac:name="include">`,
 | 
								`<ac:structured-macro ac:name="include">`,
 | 
				
			||||||
			`<ac:parameter ac:name="">`,
 | 
								`<ac:parameter ac:name="">`,
 | 
				
			||||||
			`<ac:link>`,
 | 
								`<ac:link>`,
 | 
				
			||||||
			`<ri:page ri:content-title="{{ .Page }}" {{if .Space }}ri:space-key="{{ .Space }}"{{end}}/>`,
 | 
								`<ri:page ri:content-title="{{ .Page }}" {{if .Space }}ri:space-key="{{ .Space }}"{{ end }}/>`,
 | 
				
			||||||
			`</ac:link>`,
 | 
								`</ac:link>`,
 | 
				
			||||||
			`</ac:parameter>`,
 | 
								`</ac:parameter>`,
 | 
				
			||||||
			`</ac:structured-macro>`,
 | 
								`</ac:structured-macro>`,
 | 
				
			||||||
@ -380,7 +380,7 @@ func templates(api *confluence.API) (*template.Template, error) {
 | 
				
			|||||||
			`<ac:structured-macro ac:name="pagetree" ac:schema-version="1">`,
 | 
								`<ac:structured-macro ac:name="pagetree" ac:schema-version="1">`,
 | 
				
			||||||
			`<ac:parameter ac:name="root">`,
 | 
								`<ac:parameter ac:name="root">`,
 | 
				
			||||||
			`<ac:link>`,
 | 
								`<ac:link>`,
 | 
				
			||||||
			`<ri:page ri:content-title="@self"{{or .Title "" }}/>`,
 | 
								`<ri:page ri:content-title="@self"{{ or .Title "" }}/>`,
 | 
				
			||||||
			`</ac:link>`,
 | 
								`</ac:link>`,
 | 
				
			||||||
			`</ac:parameter>`,
 | 
								`</ac:parameter>`,
 | 
				
			||||||
			`<ac:parameter ac:name="sort">{{ or .Sort "" }}</ac:parameter>`,
 | 
								`<ac:parameter ac:name="sort">{{ or .Sort "" }}</ac:parameter>`,
 | 
				
			||||||
@ -406,6 +406,19 @@ func templates(api *confluence.API) (*template.Template, error) {
 | 
				
			|||||||
			`</ac:structured-macro>`,
 | 
								`</ac:structured-macro>`,
 | 
				
			||||||
		),
 | 
							),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							/* */
 | 
				
			||||||
 | 
							`ac:recently-updated`: text(
 | 
				
			||||||
 | 
								`<ac:structured-macro ac:name="recently-updated">`,
 | 
				
			||||||
 | 
								`{{ if .Spaces }}<ac:parameter ac:name="spaces"><ri:space ri:space-key={{ .Spaces }}/></ac:parameter>{{ end }}`,
 | 
				
			||||||
 | 
								`<ac:parameter ac:name="showProfilePic">{{ or .ShowProfilePic "" }}</ac:parameter>`,
 | 
				
			||||||
 | 
								`<ac:parameter ac:name="types">{{ or .Types "page, comment, blogpost" }}</ac:parameter>`,
 | 
				
			||||||
 | 
								`<ac:parameter ac:name="max">{{ or .Max "" }}</ac:parameter>`,
 | 
				
			||||||
 | 
								`<ac:parameter ac:name="labels">{{ or .Labels "" }}</ac:parameter>`,
 | 
				
			||||||
 | 
								`<ac:parameter ac:name="hideHeading">{{ or .HideHeading "" }}</ac:parameter>`,
 | 
				
			||||||
 | 
								`<ac:parameter ac:name="theme">{{ or .Theme "" }}</ac:parameter>`,
 | 
				
			||||||
 | 
								`</ac:structured-macro>`,
 | 
				
			||||||
 | 
							),
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// TODO(seletskiy): more templates here
 | 
							// TODO(seletskiy): more templates here
 | 
				
			||||||
	} {
 | 
						} {
 | 
				
			||||||
		templates, err = templates.New(name).Parse(body)
 | 
							templates, err = templates.New(name).Parse(body)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user