diff --git a/README.md b/README.md
index 534b1b0..d999cf4 100644
--- a/README.md
+++ b/README.md
@@ -29,6 +29,7 @@ File in the extended format should follow the specification:
+
@@ -977,6 +978,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
 recrtl 💻 |
 Stanislav Seletskiy 💻 |
+  Joris Conijn 💻 |
diff --git a/confluence/api.go b/confluence/api.go
index 903df00..8eda159 100644
--- a/confluence/api.go
+++ b/confluence/api.go
@@ -9,6 +9,7 @@ import (
"mime/multipart"
"net/http"
"strings"
+ "unicode/utf8"
"github.com/kovetskiy/gopencils"
"github.com/kovetskiy/lorg"
@@ -48,7 +49,7 @@ type PageInfo struct {
Type string `json:"type"`
Version struct {
- Number int64 `json:"number"`
+ Number int64 `json:"number"`
Message string `json:"message"`
} `json:"version"`
@@ -513,7 +514,7 @@ func (api *API) CreatePage(
return request.Response.(*PageInfo), nil
}
-func (api *API) UpdatePage(page *PageInfo, newContent string, minorEdit bool, versionMessage string, newLabels []string, appearance string) error {
+func (api *API) UpdatePage(page *PageInfo, newContent string, minorEdit bool, versionMessage string, newLabels []string, appearance string, emojiString string) error {
nextPageVersion := page.Version.Number + 1
oldAncestors := []map[string]interface{}{}
@@ -524,6 +525,29 @@ func (api *API) UpdatePage(page *PageInfo, newContent string, minorEdit bool, ve
}
}
+ properties := map[string]interface{}{
+ // Fix to set full-width as has changed on Confluence APIs again.
+ // https://jira.atlassian.com/browse/CONFCLOUD-65447
+ //
+ "content-appearance-published": map[string]interface{}{
+ "value": appearance,
+ },
+ // content-appearance-draft should not be set as this is impacted by
+ // the user editor default configurations - which caused the sporadic published widths.
+ }
+
+ if emojiString != "" {
+ r, _ := utf8.DecodeRuneInString(emojiString)
+ unicodeHex := fmt.Sprintf("%x", r)
+
+ properties["emoji-title-draft"] = map[string]interface{}{
+ "value": unicodeHex,
+ }
+ properties["emoji-title-published"] = map[string]interface{}{
+ "value": unicodeHex,
+ }
+ }
+
payload := map[string]interface{}{
"id": page.ID,
"type": page.Type,
@@ -541,16 +565,7 @@ func (api *API) UpdatePage(page *PageInfo, newContent string, minorEdit bool, ve
},
},
"metadata": map[string]interface{}{
- // Fix to set full-width as has changed on Confluence APIs again.
- // https://jira.atlassian.com/browse/CONFCLOUD-65447
- //
- "properties": map[string]interface{}{
- "content-appearance-published": map[string]interface{}{
- "value": appearance,
- },
- },
- // content-appearance-draft should not be set as this is impacted by
- // the user editor default configurations - which caused the sporadic published widths.
+ "properties": properties,
},
}
@@ -601,7 +616,7 @@ func (api *API) DeletePageLabel(page *PageInfo, label string) (*LabelInfo, error
request, err := api.rest.Res(
"content/"+page.ID+"/label", &LabelInfo{},
- ).SetQuery(map[string]string{"name": label}).Delete()
+ ).SetQuery(map[string]string{"name": label}).Delete()
if err != nil {
return nil, err
}
diff --git a/main.go b/main.go
index 0a1f0e5..f532e41 100644
--- a/main.go
+++ b/main.go
@@ -537,7 +537,7 @@ func processFile(
)
versionPattern := `\[v([a-f0-9]{40})]$`
- re := regexp.MustCompile(versionPattern)
+ re := regexp.MustCompile(versionPattern)
matches := re.FindStringSubmatch(target.Version.Message)
@@ -563,9 +563,8 @@ func processFile(
finalVersionMessage = cCtx.String("version-message")
}
-
if shouldUpdatePage {
- err = api.UpdatePage(target, html, cCtx.Bool("minor-edit"), finalVersionMessage, meta.Labels, meta.ContentAppearance)
+ err = api.UpdatePage(target, html, cCtx.Bool("minor-edit"), finalVersionMessage, meta.Labels, meta.ContentAppearance, meta.Emoji)
if err != nil {
log.Fatal(err)
}
diff --git a/metadata/metadata.go b/metadata/metadata.go
index 280a074..5079608 100644
--- a/metadata/metadata.go
+++ b/metadata/metadata.go
@@ -17,6 +17,7 @@ const (
HeaderType = `Type`
HeaderTitle = `Title`
HeaderLayout = `Layout`
+ HeaderEmoji = `Emoji`
HeaderAttachment = `Attachment`
HeaderLabel = `Label`
HeaderInclude = `Include`
@@ -31,6 +32,7 @@ type Meta struct {
Title string
Layout string
Sidebar string
+ Emoji string
Attachments []string
Labels []string
ContentAppearance string
@@ -107,6 +109,9 @@ func ExtractMeta(data []byte, spaceFromCli string, titleFromH1 bool, parents []s
meta.Layout = "article"
meta.Sidebar = strings.TrimSpace(value)
+ case HeaderEmoji:
+ meta.Emoji = strings.TrimSpace(value)
+
case HeaderAttachment:
meta.Attachments = append(meta.Attachments, value)