Skip to content

Commit

Permalink
every action block mods
Browse files Browse the repository at this point in the history
  • Loading branch information
kellymears committed Dec 14, 2018
1 parent 117618b commit e0a88ad
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 4 deletions.
2 changes: 1 addition & 1 deletion scripts/blocks/editor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion scripts/blocks/editor.js.map

Large diffs are not rendered by default.

86 changes: 86 additions & 0 deletions src/blocks/action-tag/ActionTagOfflineAction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import Edit from './edit';
import classnames from 'classnames'

/**
* WordPress dependencies
*/
const { __ } = wp.i18n;
const { createBlock, getBlockAttributes, registerBlockType } = wp.blocks;

/**
* Block constants
*/
const name = 'actionTagOffline';
const title = __('Every Action Offline Action Embed');
const keywords = [
__('Advocacy'),
__('ActionTag'),
__('tinypixel'),
];
const blockAttributes = {
url: {
type: 'string',
},
file: {
type: 'string',
},
meta: {
type: 'boolean',
default: false,
},
};

const schema = {
div: {
classes: ['wp-block-every-action-action-tag'],
},
};

registerBlockType('every-action/every-action-offline-embed', {
title: title,
description: __('Embed Every Action Event Forms by adding the form link.'),
icon: {
src: 'megaphone',
},
category: 'common',
keywords: keywords,
attributes: blockAttributes,
supports: {
html: false,
align: ['wide'],
},
edit: Edit,
save({ attributes, className }) {
const { url } = attributes;
let actionTagContent = null;
if(url) {
let match = /(.*)\/\/(.*)\/(.*)/g.exec(url);
if(match) {
actionTagContent = `\
<div class="every-action-embed">\
<div class="oa-page-embed"\
data-page-url="${match[1]}${match[2]}${match[3]}">\
</div>\
</div>`;
}
}

if(actionTagContent) {
return (
<div
className={
classnames(
className,
)}
>
<script type="text/javascript" src="https://d1aqhv4sn5kxtx.cloudfront.net/actiontag/at.js" crossorigin="anonymous"></script>
<div dangerouslySetInnerHTML={{ __html: actionTagContent }} />
<noscript><a href={url}>{__('View this action on Every Action')}</a></noscript>
</div>
);
}

return "there was a problem 🤭";

},
});
3 changes: 2 additions & 1 deletion src/blocks/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ import './editor.scss';

/** blocks */
import './action-tag/ActionTag';
import './action-tag/ActionTagMultiStep';
import './action-tag/ActionTagMultiStep';
// import './action-tag/ActionTagOfflineAction';
2 changes: 1 addition & 1 deletion wpackio.server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
host: '10.0.0.236',
host: 'localhost',
proxy: 'http://bedrock.lndo.site',
port: 3000,
ui: {
Expand Down

0 comments on commit e0a88ad

Please sign in to comment.