Skip to content

Commit 75b97ab

Browse files
committed
add support for Ergo theme
1 parent f7fa95b commit 75b97ab

File tree

3 files changed

+113
-0
lines changed

3 files changed

+113
-0
lines changed

src/Ergo/quote.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
CMS.registerEditorComponent({
2+
id: "quote",
3+
label: "Quote",
4+
fields: [
5+
{
6+
name: "body",
7+
label: "the body text",
8+
widget: "text"
9+
},
10+
{
11+
name: "author",
12+
label: "ahuthor name",
13+
widget: "string"
14+
},
15+
],
16+
pattern: /^{% quote\((author="([^\n]*)\")?\) %}\n(.*?)\n^{% end %}$/ms,
17+
fromBlock: function(match) {
18+
return {
19+
author: match[2],
20+
body: match[3],
21+
};
22+
},
23+
toBlock: function(obj) {
24+
const a = `author="${obj.author || ''}"`;
25+
const body = obj.body || '';
26+
return `
27+
{% quote(${a}) %}
28+
${body}
29+
{% end %}
30+
`;
31+
},
32+
toPreview: function(obj) {
33+
const author = obj.author || undefined;
34+
const body = obj.body || '';
35+
return `
36+
{% quote(${a}) %}
37+
${body}
38+
{% end %}
39+
`;
40+
},
41+
});

src/Ergo/vm.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
CMS.registerEditorComponent({
2+
id: "vm",
3+
label: "vm (Vimeo)",
4+
fields: [
5+
{
6+
name: "id",
7+
label: "the video id (mandatory)",
8+
widget: "string"
9+
},
10+
{
11+
name: "class",
12+
label: "a class to add to the <div> surrounding the iframe (optional)",
13+
widget: "string"
14+
},
15+
],
16+
pattern: /{{ vm\(id="([-a-zA-Z0-9]+)"(, class="([a-zA-Z][-_.:a-zA-Z0-9 ]*)")?\) }}/,
17+
fromBlock: function(match) {
18+
return {
19+
id: match[1],
20+
class: match[3],
21+
};
22+
},
23+
toBlock: function(obj) {
24+
const id = obj.id || '';
25+
const c = !!obj.class ? `, class="${obj.class}"` : '';
26+
return `{{ vm(id="${id}"${c}) }}`;
27+
},
28+
toPreview: function(obj) {
29+
const id = obj.id || '';
30+
const c = !!obj.class ? `, class="${obj.class}"` : '';
31+
return `{{ vm(id="${id}"${c}) }}`;
32+
},
33+
});

src/Ergo/yt.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
CMS.registerEditorComponent({
2+
id: "yt",
3+
label: "yt (YouTube)",
4+
fields: [
5+
{
6+
name: "id",
7+
label: "the video id (mandatory)",
8+
widget: "string"
9+
},
10+
{
11+
name: "autoplay",
12+
label: "when set to \"true\", the video autoplays on load (optional)",
13+
widget: "boolean"
14+
},
15+
{
16+
name: "class",
17+
label: "a class to add to the <div> surrounding the iframe (optional)",
18+
widget: "string"
19+
},
20+
],
21+
pattern: /{{ youtube\(id="([-_a-zA-Z0-9]+)"(, autoplay=(true|false))?(, class="([a-zA-Z][-_.:a-zA-Z0-9 ]*)")?\) }}/,
22+
fromBlock: function(match) {
23+
return {
24+
id: match[1],
25+
autoplay: match[3],
26+
class: match[5],
27+
};
28+
},
29+
toBlock: function(obj) {
30+
const id = obj.id || '';
31+
const a = !!obj.autoplay ? `, autoplay=${obj.autoplay}` : '';
32+
const c = !!obj.class ? `, class="${obj.class}"` : '';
33+
return `{{ youtube(id="${id}"${a}${c}) }}`;
34+
},
35+
toPreview: function(obj) {
36+
const id = obj.id || '';
37+
return `<img src="http://img.youtube.com/vi/${id}/mqdefault.jpg" alt="Youtube Video"/>`;
38+
},
39+
});

0 commit comments

Comments
 (0)