Skip to content

Commit

Permalink
added json-ld + text version
Browse files Browse the repository at this point in the history
  • Loading branch information
posabsolute committed Jun 4, 2015
1 parent b07af91 commit 30d5aeb
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 59 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"html-to-text": "^1.3.0",
"le_node": "^0.2.1",
"node-slack": "0.0.7",
"nodemailer-html-to-text": "^1.0.1",
"nodemailer-sendgrid-transport": "^0.1.0",
"nodemailer-wellknown": "^0.1.5",
"pushbullet": "^1.4.3"
Expand Down
11 changes: 6 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,14 +362,15 @@ nunjucks: {
Follow the same conventions while creating your localization files, in this case, *locales/en_US.yml*.
## JSON LD
## schema.org, Email Augmented Experience
By adding schema.org markup to the emails you send your users, you can make that information available across their Google experience, and make it easy for users to take quick action. Inbox, Gmail, Google Calendar, Google Search, and Google Now all already use this structured data.
Inker implement 2 types of the for available on gmail, being actions & promotions.
Inker currently only implement actions.
JSON LD components are dynamic data, generally linked directly to the customer you are sending the email to. JSON-LD complete implementation is available using the Inker API or you can customize the components to use your own templating engine.
JSON LD components use dynamic data generally linked directly to the customer you are sending the email. JSON-LD complete implementation is available using the Inker API or you can customize the components to use your own templating engine.
**DKIM/SPF signature is required when using schema.org markup**
### Example:
Expand Down Expand Up @@ -443,7 +444,7 @@ Usage in the template :
### Review Action
Use to declare a review action. Gmail may show a review button next to the email, which will prompt the user for a numeric review value and / or a user comment.
Use to declare a review action. Gmail may show a review button next to the email, which will prompt the user for a numeric review value and or a user comment.
https://developers.google.com/gmail/markup/reference/review-action
Expand Down Expand Up @@ -482,7 +483,7 @@ Usage in the template :
* addressRegion {string} CA
* postalCode {string} 94107
* addressCountry {string} USA
* action.attendance http://schema.org/RsvpAttendance/Yes || http://schema.org/RsvpAttendance/No || http://mysite.com/rsvp?eventId=123&value=maybe
* attendance http://schema.org/RsvpAttendance/Yes || http://schema.org/RsvpAttendance/No || http://mysite.com/rsvp?eventId=123&value=maybe
Expand Down
7 changes: 3 additions & 4 deletions src/server/controllers/controller.emails.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ var emails_controller = {
if(req.headers["x-authorization-token"] !== configs.authToken){
return res.sendStatus(401);
}

console.log("fuck");
// get post data
var data = req.body.data.variables || {},
// Get language used
locale = req.body.data.locale || "en_US",
// render template with nunjucks
tplURL = templates_controller.getTemplate(locale, req.body.data.collection, req.body.data.template),
tplURLText = templates_controller.getTemplate(locale, req.body.data.collection, req.body.data.template, "txt"),
//templateHtml = templates_controller.renderTemplate(tplURL, data, res),
templateHtml = templates_controller.renderTemplate(tplURL, data, res),
templateTxt = "",
// get service from post data
service = req.body.service && req.body.service.name || configs.service || 'smtp',
Expand All @@ -45,14 +45,13 @@ var emails_controller = {
// stop the call use the response set in controller.templates.js
return;
}

console.log("fuck2");
// generate text version
// using custom txt template
if(req.body.options.textVersion && !req.body.options.textVersionFromHTML){
templateTxt = templates_controller.renderTemplate(tplURLText, data, res);
// generating text version from html template
}else if(req.body.options.textVersion && req.body.options.textVersionFromHTML){
console.log("fuck");
templateTxt = htmlToText.fromString(templateHtml);
}
console.log(templateTxt);
Expand Down
3 changes: 1 addition & 2 deletions src/templates/components/_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@
{% from "components/_component.video.html" import video %}
{% from "components/_component.panel.html" import panel %}
{% from "components/_component.alertHeader.html" import alertHeader %}

<!-- JSONLD -->
{% from "components/jsonld/actions/_component.jsonld.goto.html" import jsonldGoto %}
{% from "components/jsonld/actions/_component.jsonld.one-click-action.html" import jsonldOneClick %}
{% from "components/jsonld/actions/_component.jsonld.review.html" import jsonldReview %}
{% from "components/jsonld/actions/_component.jsonld.rsvp.html" import jsonldRSVP %}
{% from "components/jsonld/promotions/_component.jsonld.offer.html" import jsonldOffer %}
</head>
<body>
{% block jsonLD %}{% endblock %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<!--
JSON-LD One Click Action
https://developers.google.com/gmail/markup/reference/one-click-action
@action.type {string} ConfirmAction || SaveAction
@action.name {string} textshown in inbox
@action.url {string} Url action
@type {string} ConfirmAction || SaveAction
@name {string} textshown in inbox
@url {string} Url action
@description {string} Call description
* ---- *
Expand All @@ -26,15 +26,15 @@
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"action": {
"@type": "{{'{{type }} '}}",
"name": "{{'{{ name }}'}}",
"potentialAction": {
"@type": "{{'{{ jsonLD.type }}'}}",
"name": "{{'{{ jsonLD.name }}'}}",
"handler": {
"@type": "HttpActionHandler",
"url": "{{'{{handlerUrl }}'}}"
"url": "{{'{{ jsonLD.url }}'}}"
}
},
"description": "{{'{{description }}'}}"
"description": "{{'{{ jsonLD.description }}'}}"
}
</script>
{% endmacro %}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"review": {
"@type": "Review",
"itemReviewed": {
"@type": "{{ '{{ reviewType }}' }}",
"name": "{{ '{{ reviewName }}' }}"
"@type": "{{ '{{ jsonLD.reviewType }}' }}",
"name": "{{ '{{ jsonLD.reviewName }}' }}"
},
"reviewRating": {
"@type": "Rating",
Expand All @@ -38,7 +38,7 @@
},
"handler": {
"@type": "HttpActionHandler",
"url": "{{ reviewUrl }}' }}",
"url": "{{ jsonLD.reviewUrl }}' }}",
"requiredProperty": {
"@type": "Property",
"name": "review.reviewRating.ratingValue"
Expand All @@ -50,7 +50,7 @@
"method": "http://schema.org/HttpRequestMethod/POST"
}
},
"description": "{{ '{{ reviewDescription }}' }}"
"description": "{{ '{{ jsonLD.reviewDescription }}' }}"
}
</script>
{% endmacro %}
22 changes: 11 additions & 11 deletions src/templates/components/jsonld/actions/_component.jsonld.rsvp.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,28 @@
{
"@context": "http://schema.org",
"@type": "Event",
"name": "{{'{{ name }}'}}",
"startDate": "{{'{{ startdate }}'}}",
"endDate": "{{'{{ enddate }}'}}",
"name": "{{'{{ jsonLD.name }}'}}",
"startDate": "{{'{{ jsonLD.startdate }}'}}",
"endDate": "{{'{{ jsonLD.enddate }}'}}",
"location": {
"@type": "Place",
"address": {
"@type": "PostalAddress",
"name": "{{'{{ addressName }}'}}Google",
"streetAddress": "{{'{{ addressStress }}'}}",
"addressLocality": "{{'{{ addressCity }}'}}",
"addressRegion": "{{'{{ addressRegion }}'}}",
"postalCode": "{{'{{ adressPostal }}'}}",
"addressCountry": "{{'{{ addressCountry }}'}}"
"name": "{{'{{ jsonLD.addressName }}'}}",
"streetAddress": "{{'{{ jsonLD.addressStress }}'}}",
"addressLocality": "{{'{{ jsonLD.addressCity }}'}}",
"addressRegion": "{{'{{ jsonLD.addressRegion }}'}}",
"postalCode": "{{'{{ jsonLD.adressPostal }}'}}",
"addressCountry": "{{'{{ jsonLD.addressCountry }}'}}"
}
},
"action": [
{{ '{% for action in actions %}' }}
{{ '{% for action in jsonLD.actions %}' }}
{
"@type": "RsvpAction",
"handler": {
"@type": "HttpActionHandler",
"url": "{{'{{ action.utl }}'}}"
"url": "{{'{{ action.url }}'}}"
},
"attendance": "{{'{{ action.attendance }}'}}"
},
Expand Down

This file was deleted.

1 change: 1 addition & 0 deletions src/templates/transactional/action.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@

{% endblock %}

{% block jsonLD %} {{ jsonldOneClick() }} {% endblock %}

0 comments on commit 30d5aeb

Please sign in to comment.