diff --git a/packages/@atjson/offset-annotations/src/annotations/cne-event-registration-embed.ts b/packages/@atjson/offset-annotations/src/annotations/cne-event-registration-embed.ts new file mode 100644 index 000000000..461ae0df8 --- /dev/null +++ b/packages/@atjson/offset-annotations/src/annotations/cne-event-registration-embed.ts @@ -0,0 +1,8 @@ +import { BlockAnnotation } from "@atjson/document"; + +export class CneEventRegistrationEmbed extends BlockAnnotation<{ + url: string; +}> { + static vendorPrefix = "offset"; + static type = "cne-event-registration-embed"; +} diff --git a/packages/@atjson/offset-annotations/src/annotations/cne-ticketing-widget-embed.ts b/packages/@atjson/offset-annotations/src/annotations/cne-ticketing-widget-embed.ts deleted file mode 100644 index 7618f8f5b..000000000 --- a/packages/@atjson/offset-annotations/src/annotations/cne-ticketing-widget-embed.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { BlockAnnotation } from "@atjson/document"; - -export class CneTicketingWidgetEmbed extends BlockAnnotation<{ - url: string; -}> { - static vendorPrefix = "offset"; - static type = "cne-ticketing-widget-embed"; -} diff --git a/packages/@atjson/offset-annotations/src/annotations/index.ts b/packages/@atjson/offset-annotations/src/annotations/index.ts index 8a9af8bc5..714daafb7 100644 --- a/packages/@atjson/offset-annotations/src/annotations/index.ts +++ b/packages/@atjson/offset-annotations/src/annotations/index.ts @@ -3,7 +3,7 @@ export * from "./bold"; export * from "./caption-source"; export * from "./ceros-embed"; export * from "./cne-audio-embed"; -export * from "./cne-ticketing-widget-embed"; +export * from "./cne-event-registration-embed"; export * from "./code"; export * from "./code-block"; export * from "./facebook-embed"; diff --git a/packages/@atjson/offset-annotations/src/index.ts b/packages/@atjson/offset-annotations/src/index.ts index 876a634b5..2b707a83a 100644 --- a/packages/@atjson/offset-annotations/src/index.ts +++ b/packages/@atjson/offset-annotations/src/index.ts @@ -4,7 +4,7 @@ import { Bold, CerosEmbed, CneAudioEmbed, - CneTicketingWidgetEmbed, + CneEventRegistrationEmbed, Code, CodeBlock, FacebookEmbed, @@ -49,7 +49,7 @@ export default class OffsetSource extends Document { Bold, CerosEmbed, CneAudioEmbed, - CneTicketingWidgetEmbed, + CneEventRegistrationEmbed, Code, CodeBlock, FacebookEmbed, diff --git a/packages/@atjson/renderer-html/src/index.ts b/packages/@atjson/renderer-html/src/index.ts index c5f18117f..940a28bd2 100644 --- a/packages/@atjson/renderer-html/src/index.ts +++ b/packages/@atjson/renderer-html/src/index.ts @@ -3,7 +3,7 @@ import { Blockquote, CerosEmbed, CneAudioEmbed, - CneTicketingWidgetEmbed, + CneEventRegistrationEmbed, CodeBlock, Heading, Image, @@ -153,9 +153,9 @@ export default class HTMLRenderer extends Renderer { )}>`; } - // CNE Ticketing Widget embed - *CneTicketingWidgetEmbed(embed: Block) { - return yield* this.$("cne-ticketing-widget", { + // CNE Event Registration embed + *CneEventRegistrationEmbed(embed: Block) { + return yield* this.$("cne-event-registration", { url: embed.attributes.url, }); } diff --git a/packages/@atjson/renderer-html/test/renderer.test.ts b/packages/@atjson/renderer-html/test/renderer.test.ts index 39828eaa2..f83f6e47c 100644 --- a/packages/@atjson/renderer-html/test/renderer.test.ts +++ b/packages/@atjson/renderer-html/test/renderer.test.ts @@ -4,7 +4,7 @@ import OffsetSource, { Bold, CerosEmbed, CneAudioEmbed, - CneTicketingWidgetEmbed, + CneEventRegistrationEmbed, Code, CodeBlock, Heading, @@ -614,12 +614,12 @@ describe("renderer-html", () => { ); }); - describe("Cneticketingwidget", () => { - test("only baseurl", () => { + describe("Cne Event Registration", () => { + test("baseurl only", () => { let doc = new OffsetSource({ content: "\uFFFC", annotations: [ - new CneTicketingWidgetEmbed({ + new CneEventRegistrationEmbed({ start: 0, end: 1, attributes: { @@ -633,18 +633,18 @@ describe("renderer-html", () => { expect( Renderer.render(serialize(doc, { withStableIds: true })) ).toMatchInlineSnapshot( - `""` + `""` ); }); test("full param", () => { let doc = new OffsetSource({ content: "\uFFFC", annotations: [ - new CneTicketingWidgetEmbed({ + new CneEventRegistrationEmbed({ start: 0, end: 1, attributes: { - url: "https://baseurl?loggedout=loggedouturlslug&loggedin=loggedinslug&privacy=true", + url: "https://baseurl?loggedout=loggedoutslug&loggedin=loggedinslug&privacy=true", }, }), new ParseAnnotation({ start: 0, end: 1 }), @@ -654,7 +654,7 @@ describe("renderer-html", () => { expect( Renderer.render(serialize(doc, { withStableIds: true })) ).toMatchInlineSnapshot( - `""` + `""` ); }); }); diff --git a/packages/@atjson/source-html/src/annotations/cne-ticketing-widget-embed.ts b/packages/@atjson/source-html/src/annotations/cne-event-registration-embed.ts similarity index 70% rename from packages/@atjson/source-html/src/annotations/cne-ticketing-widget-embed.ts rename to packages/@atjson/source-html/src/annotations/cne-event-registration-embed.ts index 77a8645db..84c5efa09 100644 --- a/packages/@atjson/source-html/src/annotations/cne-ticketing-widget-embed.ts +++ b/packages/@atjson/source-html/src/annotations/cne-event-registration-embed.ts @@ -2,11 +2,11 @@ import { ObjectAnnotation } from "@atjson/document"; import { GlobalAttributes } from "../global-attributes"; -export class CneTicketingWidgetEmbed extends ObjectAnnotation< +export class CneEventRegistrationEmbed extends ObjectAnnotation< GlobalAttributes & { url: string; } > { static vendorPrefix = "html"; - static type = "cne-ticketing-widget"; + static type = "cne-event-registration"; } diff --git a/packages/@atjson/source-html/src/annotations/index.ts b/packages/@atjson/source-html/src/annotations/index.ts index 778a1ea55..c7703e125 100644 --- a/packages/@atjson/source-html/src/annotations/index.ts +++ b/packages/@atjson/source-html/src/annotations/index.ts @@ -17,7 +17,7 @@ export * from "./button"; export * from "./canvas"; export * from "./caption"; export * from "./cite"; -export * from "./cne-ticketing-widget-embed"; +export * from "./cne-event-registration-embed"; export * from "./code"; export * from "./col"; export * from "./colgroup"; diff --git a/packages/@atjson/source-html/src/converter/third-party-embeds.ts b/packages/@atjson/source-html/src/converter/third-party-embeds.ts index daf591f57..ee0b60dee 100644 --- a/packages/@atjson/source-html/src/converter/third-party-embeds.ts +++ b/packages/@atjson/source-html/src/converter/third-party-embeds.ts @@ -3,7 +3,7 @@ import { AudioEnvironments, CerosEmbed, CneAudioEmbed, - CneTicketingWidgetEmbed, + CneEventRegistrationEmbed, FireworkEmbed, } from "@atjson/offset-annotations"; import { Script } from "../annotations"; @@ -216,12 +216,22 @@ export default function convertThirdPartyEmbeds(doc: Document) { ); }); /** - * CNE Ticketing Widget + * CNE Event Registration Embed: + * is used to insert an iframe tag into the HTML page with two different URLs based on the user's status. The parameter passed to the embed is a specific URL, with some specific metadata encoded in the URL + * https://baseurl?loggedout=loggedoutslug&loggedin=loggedinslug&privacy=true + * + * If the user is not logged in to the site, the iframe URL will be https://baseurl/{loggedout} + * If the user is logged in to the site the iframe url will be https://baseurl/{loggedin} + * + * The (optional) privacy parameter will be used to check the user's choices regarding privacy (default value: true) + * if privacy = false --> no control, the iframe with the relative URL is always inserted into the page; + * if privacy = true --> user does not accept privacy (profiling) a warning will be shown on the page instead of the iframe (no iframe shown); + * if privacy = true --> user accepts privacy (profiling) the iframe with the relative URL will be inserted on the page; */ - doc.where({ type: "-html-cne-ticketing-widget" }).update((embed) => { + doc.where({ type: "-html-cne-event-registration" }).update((embed) => { doc.replaceAnnotation( embed, - new CneTicketingWidgetEmbed({ + new CneEventRegistrationEmbed({ id: embed.id, start: embed.start, end: embed.end, diff --git a/packages/@atjson/source-html/test/cne-ticketing-widget-embed.test.ts b/packages/@atjson/source-html/test/cne-event-registration-embed.test.ts similarity index 69% rename from packages/@atjson/source-html/test/cne-ticketing-widget-embed.test.ts rename to packages/@atjson/source-html/test/cne-event-registration-embed.test.ts index c0d80358d..1046a248e 100644 --- a/packages/@atjson/source-html/test/cne-ticketing-widget-embed.test.ts +++ b/packages/@atjson/source-html/test/cne-event-registration-embed.test.ts @@ -2,10 +2,10 @@ import { serialize } from "@atjson/document"; import OffsetSource from "@atjson/offset-annotations"; import HTMLSource from "../src"; -describe("Cne Ticketing Widget embeds", () => { +describe("CNE Event Registration embed", () => { test("only baseurl", () => { let doc = HTMLSource.fromRaw( - `` + `` ).convertTo(OffsetSource); expect(serialize(doc, { withStableIds: true })).toMatchInlineSnapshot(` @@ -18,7 +18,7 @@ describe("Cne Ticketing Widget embeds", () => { "id": "B00000000", "parents": [], "selfClosing": false, - "type": "cne-ticketing-widget-embed", + "type": "cne-event-registration-embed", }, ], "marks": [], @@ -29,7 +29,7 @@ describe("Cne Ticketing Widget embeds", () => { test("full param", () => { let doc = HTMLSource.fromRaw( - `` + `` ).convertTo(OffsetSource); expect(serialize(doc, { withStableIds: true })).toMatchInlineSnapshot(` @@ -37,12 +37,12 @@ describe("Cne Ticketing Widget embeds", () => { "blocks": [ { "attributes": { - "url": "https://baseurl?loggedout=loggedouturlslug&loggedin=loggedinslug&privacy=true", + "url": "https://baseurl?loggedout=loggedoutslug&loggedin=loggedinslug&privacy=true", }, "id": "B00000000", "parents": [], "selfClosing": false, - "type": "cne-ticketing-widget-embed", + "type": "cne-event-registration-embed", }, ], "marks": [],