Thursday, 28 January 2016

Building a row-based email template in Adestra MessageFocus Email Editor

I had the pleasure of using Adestra's new (still in beta, apparently) email editor this week, and it seemed to do everything we wanted. I inherited an HTML template with 10 different rows, and the brief was to allow the user to create an email using any number of any of these rows, in any order, with editable text, links images etc.

As an overview, if you wish to implement a typical row-based system you probably have the following html structure:

 <table>  
 <!-- row type 1 here -->  
 </table>  
 <table>  
 <!-- row type 2 here -->  
 </table>  
 <table>  
 <!-- row type 3 here -->  
 </table>  
 <table>  
 <!-- row type 4 here -->  
 </table>  

To use this in the Email Editor, where you can place any type of row wherever you want any number of times you need to use alternates and a single overall repeater of the same name, like so:

 <table amf:alternate="row" amf:option="row_1" amf:repeat="row">  
 <!-- row type 1 here -->  
 </table>  
 <table amf:alternate="row" amf:option="row_2">  
 <!-- row type 2 here -->  
 </table>  
 <table amf:alternate="row" amf:option="row_3">  
 <!-- row type 3 here -->  
 </table>  
 <table amf:alternate="row" amf:option="row_4">  
 <!-- row type 4 here -->  
 </table>  

This creates the following type of experience in the Email Editor, allowing you to create/delete rows at will, and selecting which alternative you desire:



The following amf attributes create dynamic (editable) links, images, single text lines and text areas:

 <a href="www.mysite.com" amf:link="my_link">Go here</a>  
 <img src="/img/myimage.png" amf:image="image_1">  
 <span amf:textline="header_line">This is a single line</span>  
 <p amf:textbox="a_paragrpah_of_text">lots of text...</p>  

Monday, 21 December 2015

A way to recover your lost Android keystore and key password

I'm pretty good with passwords - I keep a Keepass file on everything I do, and it's backed up immediately to the cloud. But something went wrong recently, and a password to a keystore and key did not get saved to my Keepass file. After some mild panic I learned that you can probably find your passwords in clear text in one of your gradle logfiles, this one to be precise:
.gradle/X.X.X/taskArtifacts/taskArtifacts.bin
Just search for the word password and if you're lucky like me you'll find the strings, separately recorded as keyPassword and storePassword. Sounds like a security hole to me, but boy it came in handy today.

Friday, 18 December 2015

Rendering transaction data in Adestra MessageFocus

I found myself doing this today, and it didn't go without some problems. I thought I'd document the outcome. Here's the data we're sending to the API: and here's the rendering logic in the email:
[*transaction.customer_first_name*] [*transaction.customer_last_name*]
[*transaction.customer_loyalty_card_number*]

[*transaction.customer_loyalty_card_balance*]

[*transaction.order_reference*]

[*transaction.order_total*]

[*transaction.order_store_address*]

[*transaction.order_collect_date*]

[*transaction.order_collect_time*]

[*transaction.till_type*]

[*transaction.address*]

[*transaction.vat_number*]

[*FOREACH item IN transaction.items*]
Name: [*item.value.Name*]
[*FOREACH subitem IN item.value*]
[*subitem.key*]:[*subitem.value*]
[*END*]
[*END*]

Friday, 4 December 2015

Target iPhone only in Cordova

Just drop this into your config.xml:

<preference name="target-device" value="handset" />

Wednesday, 11 November 2015

A potentially dangerous Request.Form value was detected from the client. MVC

From MVC3 onwards if you see this message

A potentially dangerous Request.Form value was detected from the clien

you can fix it by decorating the model propery with this:

[AllowHtml]

Thursday, 5 November 2015

Xcode bypass App Transport Security

During development it's common that we need to access resources within an iOS app from a non-secure server. To enable this we need to bypass Apple's new App Transport Security. We can do this by adding the following to the info.plist file:

<key>NSAppTransportSecurity</key>
    <dict>
      <key>NSExceptionDomains</key>
      <dict>
        <key>mydomain.co.uk</key>
        <dict>
          <key>NSIncludesSubdomains</key>
          <true/>
          <key>NSExceptionAllowsInsecureHTTPLoads</key>
          <true/>
          <key>NSExceptionRequiresForwardSecrecy</key>
          <true/>
          <key>NSExceptionMinimumTLSVersion</key>
          <string>TLSv1.2</string>
          <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
          <false/>
          <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
          <true/>
          <key>NSThirdPartyExceptionMinimumTLSVersion</key>
          <string>TLSv1.2</string>
          <key>NSRequiresCertificateTransparency</key>
          <false/>
        </dict>
      </dict>
    </dict>