Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ type StoryBlock =
| Video
| YoutubeVideo
| VimeoVideo
| AcastPodcast
| Timeline
| ImagePair
| InNumbers
Expand Down Expand Up @@ -527,7 +528,7 @@ interface Tweet extends Node {
}
```

**Tweet** represents a tweet.
**Tweet** represents a tweet. Rather than embedding the tweet directly in an article, we typically fetch and cache the HTML server-side to avoid the client-side dependencies.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a little bit to the docs to clarify why tweets have external html and the others don't (it confused me!)


### `Flourish`

Expand Down Expand Up @@ -600,6 +601,20 @@ interface VimeoVideo extends Node {

_Note: this is currently only used by Specialist Titles_

### `AcastPodcast`

```ts
interface AcastPodcast extends Node {
type: "acast-podcast"
/** Acast Podcast embed url e.g. https://embed.acast.com/* */
url: string
}
```

**AcastPodcast** represents an audio embed from Acast referenced by an Acast embed URL.

_Note: this is currently only used by Specialist Titles_

### `ClipSet`
```ts
interface ClipSet extends Node {
Expand Down
28 changes: 24 additions & 4 deletions content-tree.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export declare namespace ContentTree {
type: "blockquote";
children: (Paragraph | Phrasing)[];
}
type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | ClipSet | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | VimeoVideo | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair;
type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | ClipSet | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | VimeoVideo | AcastPodcast | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair;
interface Pullquote extends Node {
type: "pullquote";
text: string;
Expand Down Expand Up @@ -206,6 +206,11 @@ export declare namespace ContentTree {
/** Vimeo embed URL e.g. https://player.vimeo.com/player/<id> or https://vimeo.com/<id>*/
url: string;
}
interface AcastPodcast extends Node {
type: "acast-podcast";
/** Acast Podcast embed url e.g. https://embed.acast.com/* */
url: string;
}
interface ClipSet extends Node {
type: "clip-set";
id: string;
Expand Down Expand Up @@ -512,7 +517,7 @@ export declare namespace ContentTree {
type: "blockquote";
children: (Paragraph | Phrasing)[];
}
type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | ClipSet | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | VimeoVideo | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair;
type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | ClipSet | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | VimeoVideo | AcastPodcast | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair;
interface Pullquote extends Node {
type: "pullquote";
text: string;
Expand Down Expand Up @@ -630,6 +635,11 @@ export declare namespace ContentTree {
/** Vimeo embed URL e.g. https://player.vimeo.com/player/<id> or https://vimeo.com/<id>*/
url: string;
}
interface AcastPodcast extends Node {
type: "acast-podcast";
/** Acast Podcast embed url e.g. https://embed.acast.com/* */
url: string;
}
interface ClipSet extends Node {
type: "clip-set";
id: string;
Expand Down Expand Up @@ -937,7 +947,7 @@ export declare namespace ContentTree {
type: "blockquote";
children: (Paragraph | Phrasing)[];
}
type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | ClipSet | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | VimeoVideo | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair;
type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | ClipSet | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | VimeoVideo | AcastPodcast | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair;
interface Pullquote extends Node {
type: "pullquote";
text: string;
Expand Down Expand Up @@ -1050,6 +1060,11 @@ export declare namespace ContentTree {
/** Vimeo embed URL e.g. https://player.vimeo.com/player/<id> or https://vimeo.com/<id>*/
url: string;
}
interface AcastPodcast extends Node {
type: "acast-podcast";
/** Acast Podcast embed url e.g. https://embed.acast.com/* */
url: string;
}
interface ClipSet extends Node {
type: "clip-set";
id: string;
Expand Down Expand Up @@ -1335,7 +1350,7 @@ export declare namespace ContentTree {
type: "blockquote";
children: (Paragraph | Phrasing)[];
}
type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | ClipSet | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | VimeoVideo | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair;
type StoryBlock = ImageSet | Flourish | BigNumber | CustomCodeComponent | Layout | Pullquote | ScrollyBlock | ClipSet | Table | Recommended | RecommendedList | Tweet | Video | YoutubeVideo | VimeoVideo | AcastPodcast | Timeline | ImagePair | InNumbers | Definition | InfoBox | InfoPair;
interface Pullquote extends Node {
type: "pullquote";
text: string;
Expand Down Expand Up @@ -1453,6 +1468,11 @@ export declare namespace ContentTree {
/** Vimeo embed URL e.g. https://player.vimeo.com/player/<id> or https://vimeo.com/<id>*/
url: string;
}
interface AcastPodcast extends Node {
type: "acast-podcast";
/** Acast Podcast embed url e.g. https://embed.acast.com/* */
url: string;
}
interface ClipSet extends Node {
type: "clip-set";
id: string;
Expand Down
37 changes: 37 additions & 0 deletions content_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const (
VideoType = "video"
YoutubeVideoType = "youtube-video"
VimeoVideoType = "vimeo-video"
AcastPodcastType = "acast-podcast"
ScrollyBlockType = "scrolly-block"
ScrollySectionType = "scrolly-section"
ScrollyImageType = "scrolly-image"
Expand Down Expand Up @@ -428,6 +429,7 @@ type BodyBlock struct {
*Video
*YoutubeVideo
*VimeoVideo
*AcastPodcast
*CustomCodeComponent
*ClipSet
*Timeline
Expand Down Expand Up @@ -499,6 +501,9 @@ func (n *BodyBlock) GetEmbedded() Node {
if n.VimeoVideo != nil {
return n.VimeoVideo
}
if n.AcastPodcast != nil {
return n.AcastPodcast
}
if n.CustomCodeComponent != nil {
return n.CustomCodeComponent
}
Expand Down Expand Up @@ -581,6 +586,9 @@ func (n *BodyBlock) GetChildren() []Node {
if n.VimeoVideo != nil {
return n.VimeoVideo.GetChildren()
}
if n.AcastPodcast != nil {
return n.AcastPodcast.GetChildren()
}
if n.CustomCodeComponent != nil {
return n.CustomCodeComponent.GetChildren()
}
Expand Down Expand Up @@ -728,6 +736,12 @@ func (n *BodyBlock) UnmarshalJSON(data []byte) error {
return err
}
n.VimeoVideo = &v
case AcastPodcastType:
var v AcastPodcast
if err := json.Unmarshal(data, &v); err != nil {
return err
}
n.AcastPodcast = &v
case CustomCodeComponentType:
var v CustomCodeComponent
if err := json.Unmarshal(data, &v); err != nil {
Expand Down Expand Up @@ -816,6 +830,8 @@ func (n *BodyBlock) MarshalJSON() ([]byte, error) {
return json.Marshal(n.YoutubeVideo)
case n.VimeoVideo != nil:
return json.Marshal(n.VimeoVideo)
case n.AcastPodcast != nil:
return json.Marshal(n.AcastPodcast)
case n.CustomCodeComponent != nil:
return json.Marshal(n.CustomCodeComponent)
case n.ClipSet != nil:
Expand Down Expand Up @@ -876,6 +892,8 @@ func makeBodyBlock(n Node) (*BodyBlock, error) {
return &BodyBlock{YoutubeVideo: n.(*YoutubeVideo)}, nil
case VimeoVideoType:
return &BodyBlock{VimeoVideo: n.(*VimeoVideo)}, nil
case AcastPodcastType:
return &BodyBlock{AcastPodcast: n.(*AcastPodcast)}, nil
case CustomCodeComponentType:
return &BodyBlock{CustomCodeComponent: n.(*CustomCodeComponent)}, nil
case ClipSetType:
Expand Down Expand Up @@ -2731,6 +2749,25 @@ func (n *VimeoVideo) GetChildren() []Node {

func (n *VimeoVideo) AppendChild(_ Node) error { return ErrCannotHaveChildren }

type AcastPodcast struct {
Type string `json:"type"`
URL string `json:"url,omitempty"`
}

func (n *AcastPodcast) GetType() string {
return n.Type
}

func (n *AcastPodcast) GetEmbedded() Node {
return nil
}

func (n *AcastPodcast) GetChildren() []Node {
return nil
}

func (n *AcastPodcast) AppendChild(_ Node) error { return ErrCannotHaveChildren }

type CustomCodeComponent struct {
Type string `json:"type"`
ID string `json:"id"`
Expand Down
8 changes: 8 additions & 0 deletions libraries/from-bodyxml/go/html_transformers.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ var defaultTransformers = map[string]transformer{
Type: contenttree.TweetType,
ID: url,
}
} else if attr(a, "data-asset-type") == "podcast" {
url := attr(a, "href")
if(strings.Contains(url, "acast.com")) {
return &contenttree.AcastPodcast{
Type: contenttree.AcastPodcastType,
URL: url,
}
}
}
if attr(a, "data-anchor-style") == "onward-journey" {
return &contenttree.FindOutMoreLink{
Expand Down
3 changes: 3 additions & 0 deletions libraries/to-external-bodyxml/go/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ func transformNode(n contenttree.Node) (string, error) {
case *contenttree.VimeoVideo:
return fmt.Sprintf("<a data-asset-type=\"video\" data-embedded=\"true\" href=\"%s\"></a>", node.URL), nil

case *contenttree.AcastPodcast:
return fmt.Sprintf("<a data-asset-type=\"podcast\" data-embedded=\"true\" href=\"%s\"></a>", node.URL), nil

case *contenttree.Tweet:
return fmt.Sprintf("<a data-asset-type=\"tweet\" data-embedded=\"true\" href=\"%[1]s\">%[1]s</a>", node.ID), nil

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@financial-times/content-tree",
"description": "content tree format",
"version": "0.5.0",
"version": "0.6.0",
"publishConfig": {
"access": "public"
},
Expand Down
22 changes: 22 additions & 0 deletions schemas/body-tree.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"definitions": {
"ContentTree.transit.AcastPodcast": {
"additionalProperties": false,
"properties": {
"data": {},
"type": {
"const": "acast-podcast",
"type": "string"
},
"url": {
"description": "Acast Podcast embed url e.g. https://embed.acast.com/*",
"type": "string"
}
},
"required": [
"type",
"url"
],
"type": "object"
},
"ContentTree.transit.BigNumber": {
"additionalProperties": false,
"properties": {
Expand Down Expand Up @@ -135,6 +154,9 @@
{
"$ref": "#/definitions/ContentTree.transit.VimeoVideo"
},
{
"$ref": "#/definitions/ContentTree.transit.AcastPodcast"
},
{
"$ref": "#/definitions/ContentTree.transit.Timeline"
},
Expand Down
22 changes: 22 additions & 0 deletions schemas/content-tree.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"definitions": {
"ContentTree.full.AcastPodcast": {
"additionalProperties": false,
"properties": {
"data": {},
"type": {
"const": "acast-podcast",
"type": "string"
},
"url": {
"description": "Acast Podcast embed url e.g. https://embed.acast.com/*",
"type": "string"
}
},
"required": [
"type",
"url"
],
"type": "object"
},
"ContentTree.full.AssetFormat": {
"enum": [
"desktop",
Expand Down Expand Up @@ -172,6 +191,9 @@
{
"$ref": "#/definitions/ContentTree.full.VimeoVideo"
},
{
"$ref": "#/definitions/ContentTree.full.AcastPodcast"
},
{
"$ref": "#/definitions/ContentTree.full.Timeline"
},
Expand Down
22 changes: 22 additions & 0 deletions schemas/transit-tree.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"definitions": {
"ContentTree.transit.AcastPodcast": {
"additionalProperties": false,
"properties": {
"data": {},
"type": {
"const": "acast-podcast",
"type": "string"
},
"url": {
"description": "Acast Podcast embed url e.g. https://embed.acast.com/*",
"type": "string"
}
},
"required": [
"type",
"url"
],
"type": "object"
},
"ContentTree.transit.BigNumber": {
"additionalProperties": false,
"properties": {
Expand Down Expand Up @@ -160,6 +179,9 @@
{
"$ref": "#/definitions/ContentTree.transit.VimeoVideo"
},
{
"$ref": "#/definitions/ContentTree.transit.AcastPodcast"
},
{
"$ref": "#/definitions/ContentTree.transit.Timeline"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@
{
"type": "vimeo-video",
"url": "https://vimeo.com/943439035"
},
{
"type": "acast-podcast",
"url": "https://embed.acast.com/74715c1d-098c-441c-a141-5599d9dd67ae/65fdb75d8d6ad800165fc561"
}
],
"version": 1
Expand Down
Loading
Loading