From cc519c11b8c83b3a60c8a6848fc6b82065d4cccb Mon Sep 17 00:00:00 2001 From: Bruno Meilick Date: Mon, 12 Feb 2018 14:46:53 +0100 Subject: [PATCH] added hash panel-field Signed-off-by: Bruno Meilick --- blueprints/fields/mj-example-hash.yml | 2 ++ blueprints/mj-example.yml | 2 +- example.md | 15 +++++++------- fields/kirbymailjethash/kirbymailjethash.php | 21 ++++++++++++++++++++ package.json | 2 +- 5 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 blueprints/fields/mj-example-hash.yml create mode 100644 fields/kirbymailjethash/kirbymailjethash.php diff --git a/blueprints/fields/mj-example-hash.yml b/blueprints/fields/mj-example-hash.yml new file mode 100644 index 0000000..13175d2 --- /dev/null +++ b/blueprints/fields/mj-example-hash.yml @@ -0,0 +1,2 @@ +label: 'Hash' +type: kirbymailjethash diff --git a/blueprints/mj-example.yml b/blueprints/mj-example.yml index 7892d3f..716275d 100644 --- a/blueprints/mj-example.yml +++ b/blueprints/mj-example.yml @@ -49,6 +49,7 @@ fields: type: headline label: Kirby Mailjet + mjhash: mj-example-hash mjcontactslist: mj-example-contactslists mjsegment: mj-example-segment mjemail: mj-example-email @@ -57,4 +58,3 @@ fields: mjtrans: mj-example-trans mjtest: mj-example-test mjpublish: mj-example-newsletter - diff --git a/example.md b/example.md index 3a2e655..e061dbd 100644 --- a/example.md +++ b/example.md @@ -1,6 +1,6 @@ # Kirby Mailjet (BETA) -Kirby Mailjet makes sending emails with Mailjet simple. +Kirby Mailjet makes sending emails with Mailjet simple. ## Responsive HTML Emails Example @@ -58,7 +58,7 @@ Use Kirby Builder to build html code for a responsive email. Make Kirby Builder - Tim Ötting's [Kirby Builder](https://github.com/TimOetting/kirby-builder), free - Martin Zurowietz's [Kirby Uniform](https://github.com/mzur/kirby-uniform), free -### Install Requirements +### Install Requirements Using [Kirby CLI](https://github.com/getkirby/cli) and [npm for mjml](https://mjml.io/download). @@ -81,9 +81,9 @@ Read [all about it here](https://github.com/bnomei/kirby-mailjet#setupmailjetacc This plugin comes with some example panel fields to get you started. You can find their their [global field definitions](https://getkirby.com/docs/panel/blueprints/global-field-definitions) in the [kirby-mailjet/blueprints/fields](https://github.com/bnomei/kirby-mailjet/blob/master/blueprints/fields/) folder. -Copy **all** of provided global field definitions from the plugin to your `site/blueprints/fields` folder. Create the folder if needed. +Copy **all** of provided global field definitions from the plugin to your `site/blueprints/fields` folder. Create the folder if needed. -Also copy **all** of provided snippets from the plugin to your `site/snippets` folder. +Also copy **all** of provided snippets from the plugin to your `site/snippets` folder. > **Why copy?** The plugin could install these with the example but the examples should be disabled on prodution server. So you have to copy them sooner or later. Furthermore you will probably make adjustments to the button labels and snipepts etc to fit your needs and that should not happen in the plugins folder. Also I do not want to mess up [Kirby Builders snippet root folder](https://github.com/TimOetting/kirby-builder/blob/master/builder.php#L43). @@ -127,7 +127,7 @@ But the Select Fields will not work yet. Lets fix that. Since Kirby does not support relative urls in Select Panel Fields [below v2.4.2](https://github.com/getkirby/panel/issues/1035) you might have to hardcode your routes. But do not worry, that is easy to do. -Visit the *Mailjet Plugin Example Page* in the frontend by clicking on *Open Preview* in the Panel. Find the output called `hash`. If it is not there make sure you are logged into the panel. +Visit the *Mailjet Plugin Example Page* in the panel and find the Kirby-Mailjet-Hash Field. Alternatively in the frontend by clicking on *Open Preview* in the Panel then locate the output called `hash`. If it is not there make sure you are logged into the panel. > **Why use a hash in the routes URL?** The hash is unique for your server and not public unless you tell someone what it is. That way your mailjet data is kept private but can still be accessed from the panel. Please, do not forget to [disable examples on production servers](https://github.com/bnomei/kirby-mailjet#pluginmailjetexamples)! @@ -189,7 +189,7 @@ if($htmlfile = KirbyMailjet::buildMJML($snippet)) { KirbyMailjet::execMJML($htmlfile); } $html = KirbyMailjet::renderMustache( - $snippet, + $snippet, $mustache ); ``` @@ -219,7 +219,6 @@ To create a custom newsletter do the following. Start reusing existing blocks th Take a look at the [mjml code flavoured with mustache](https://github.com/bnomei/kirby-mailjet/blob/master/snippets/mj-example-newsletter.php) or even copy it to the [Online Editor](https://mjml.io/try-it-live). -Check out the [controller](https://github.com/bnomei/kirby-mailjet/blob/master/controllers/mj-example.php) and [template](https://github.com/bnomei/kirby-mailjet/blob/master/templates/mj-example.php) how the example does its magic and weave your own based on that. +Check out the [controller](https://github.com/bnomei/kirby-mailjet/blob/master/controllers/mj-example.php) and [template](https://github.com/bnomei/kirby-mailjet/blob/master/templates/mj-example.php) how the example does its magic and weave your own based on that. If you find any issues, please [create a new issue](https://github.com/bnomei/kirby-mailjet/issues/new) or join the discussions in the [Kirby Forum](https://forum.getkirby.com/search?q=kirby-mailjet). - diff --git a/fields/kirbymailjethash/kirbymailjethash.php b/fields/kirbymailjethash/kirbymailjethash.php new file mode 100644 index 0000000..816bd42 --- /dev/null +++ b/fields/kirbymailjethash/kirbymailjethash.php @@ -0,0 +1,21 @@ +padding) ? $this->padding : '10px'; + $textalign = isset($this->align) ? $this->align : 'center'; + $color = isset($this->color) ? $this->color : '#888'; + $borderwidth = '2px'; + $borderstyle = 'solid'; + $borderradius = '0px'; + $bordercolor = isset($this->bordercolor) ? $this->bordercolor : '#ddd'; + $backgroundcolor = isset($this->backgroundcolor) ? $this->backgroundcolor : 'transparent'; + + $reminder = new Brick('div', KirbyMailjet::hash()); + $reminder->attr('style', "width:100%;text-align:$textalign;font-weight:$fontwidth;font-style:$fontstyle;color:$color;background-color:$backgroundcolor;border:$borderwidth $borderstyle $bordercolor;padding:$padding;border-radius:$borderradius;"); + + return $reminder; + } +} diff --git a/package.json b/package.json index 88ff3ef..ad520cb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "kirby-mailjet", "description": "Kirby Mailjet makes sending emails with Mailjet simple.", - "version": "0.7.4", + "version": "0.7.5", "author": "Bruno Meilick", "type": "kirby-plugin", "license": "Commercial"