mirror of
https://github.com/kovetskiy/mark.git
synced 2025-04-24 05:42:40 +08:00
Add Content-Appearance header
Allows switching between the "full-width" and "fixed" page layouts. The "fixed" layout renders the page in a narrow column. (Confluence default) If not configured, it defaults to "full-width".
This commit is contained in:
parent
4b5e9c23ec
commit
9e656ece15
@ -55,6 +55,13 @@ Also, optional following headers are supported:
|
|||||||
* (default) page: normal Confluence page - defaults to this if omitted
|
* (default) page: normal Confluence page - defaults to this if omitted
|
||||||
* blogpost: [Blog post](https://confluence.atlassian.com/doc/blog-posts-834222533.html) in `Space`. Cannot have `Parent`(s)
|
* blogpost: [Blog post](https://confluence.atlassian.com/doc/blog-posts-834222533.html) in `Space`. Cannot have `Parent`(s)
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
<!-- Content-Appearance: (full-width|fixed) -->
|
||||||
|
```
|
||||||
|
|
||||||
|
* (default) full-width: content will fill the full page width
|
||||||
|
* fixed: content will be rendered in a fixed narrow view
|
||||||
|
|
||||||
```markdown
|
```markdown
|
||||||
<!-- Sidebar: <h2>Test</h2> -->
|
<!-- Sidebar: <h2>Test</h2> -->
|
||||||
```
|
```
|
||||||
|
2
main.go
2
main.go
@ -390,7 +390,7 @@ func processFile(
|
|||||||
html = buffer.String()
|
html = buffer.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
err = api.UpdatePage(target, html, flags.MinorEdit, meta.Labels)
|
err = api.UpdatePage(target, html, flags.MinorEdit, meta.Labels, meta.ContentAppearance)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -514,9 +514,7 @@ func (api *API) CreatePage(
|
|||||||
return request.Response.(*PageInfo), nil
|
return request.Response.(*PageInfo), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *API) UpdatePage(
|
func (api *API) UpdatePage(page *PageInfo, newContent string, minorEdit bool, newLabels []string, appearance string) error {
|
||||||
page *PageInfo, newContent string, minorEdit bool, newLabels []string,
|
|
||||||
) error {
|
|
||||||
nextPageVersion := page.Version.Number + 1
|
nextPageVersion := page.Version.Number + 1
|
||||||
oldAncestors := []map[string]interface{}{}
|
oldAncestors := []map[string]interface{}{}
|
||||||
|
|
||||||
@ -560,7 +558,7 @@ func (api *API) UpdatePage(
|
|||||||
//
|
//
|
||||||
"properties": map[string]interface{}{
|
"properties": map[string]interface{}{
|
||||||
"content-appearance-published": map[string]interface{}{
|
"content-appearance-published": map[string]interface{}{
|
||||||
"value": "full-width",
|
"value": appearance,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// content-appearance-draft should not be set as this is impacted by
|
// content-appearance-draft should not be set as this is impacted by
|
||||||
|
@ -11,28 +11,35 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
HeaderParent = `Parent`
|
HeaderParent = `Parent`
|
||||||
HeaderSpace = `Space`
|
HeaderSpace = `Space`
|
||||||
HeaderType = `Type`
|
HeaderType = `Type`
|
||||||
HeaderTitle = `Title`
|
HeaderTitle = `Title`
|
||||||
HeaderLayout = `Layout`
|
HeaderLayout = `Layout`
|
||||||
HeaderAttachment = `Attachment`
|
HeaderAttachment = `Attachment`
|
||||||
HeaderLabel = `Label`
|
HeaderLabel = `Label`
|
||||||
HeaderInclude = `Include`
|
HeaderInclude = `Include`
|
||||||
HeaderSidebar = `Sidebar`
|
HeaderSidebar = `Sidebar`
|
||||||
|
ContentAppearance = `Content-Appearance`
|
||||||
)
|
)
|
||||||
|
|
||||||
type Meta struct {
|
type Meta struct {
|
||||||
Parents []string
|
Parents []string
|
||||||
Space string
|
Space string
|
||||||
Type string
|
Type string
|
||||||
Title string
|
Title string
|
||||||
Layout string
|
Layout string
|
||||||
Sidebar string
|
Sidebar string
|
||||||
Attachments []string
|
Attachments []string
|
||||||
Labels []string
|
Labels []string
|
||||||
|
ContentAppearance string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
FullWidthContentAppearance = "full-width"
|
||||||
|
FixedContentAppearance = "fixed"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
reHeaderPatternV1 = regexp.MustCompile(`\[\]:\s*#\s*\(([^:]+):\s*(.*)\)`)
|
reHeaderPatternV1 = regexp.MustCompile(`\[\]:\s*#\s*\(([^:]+):\s*(.*)\)`)
|
||||||
reHeaderPatternV2 = regexp.MustCompile(`<!--\s*([^:]+):\s*(.*)\s*-->`)
|
reHeaderPatternV2 = regexp.MustCompile(`<!--\s*([^:]+):\s*(.*)\s*-->`)
|
||||||
@ -78,7 +85,8 @@ func ExtractMeta(data []byte) (*Meta, []byte, error) {
|
|||||||
|
|
||||||
if meta == nil {
|
if meta == nil {
|
||||||
meta = &Meta{}
|
meta = &Meta{}
|
||||||
meta.Type = "page" //Default if not specified
|
meta.Type = "page" // Default if not specified
|
||||||
|
meta.ContentAppearance = FullWidthContentAppearance // Default to full-width for backwards compatibility
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:staticcheck
|
//nolint:staticcheck
|
||||||
@ -119,6 +127,13 @@ func ExtractMeta(data []byte) (*Meta, []byte, error) {
|
|||||||
// Includes are parsed by a different func
|
// Includes are parsed by a different func
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
case ContentAppearance:
|
||||||
|
if strings.TrimSpace(value) == FixedContentAppearance {
|
||||||
|
meta.ContentAppearance = FixedContentAppearance
|
||||||
|
} else {
|
||||||
|
meta.ContentAppearance = FullWidthContentAppearance
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
log.Errorf(
|
log.Errorf(
|
||||||
nil,
|
nil,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user