Content plugin

The content plugin allows developers to write DimML applications which redirect content to a specific destination URI. Applications can be built which point to the same URL, while based on different time, external data or other triggers the end user can be pointed to different content. This is extremely useful when wanting to change the content extensively, without wanting IT to change anything in the application. For instance, a website can contain a personalized picture by pointing all users to 1 image. The O2MC I/O platform can redirect each visitor to different pictures accordingly and the logic for personalizing the content can be updated over time.

This content redirection mechanism is native in the sense that a picture is requested and a picture is returned. This is vastly different than a lot of current personalization application which wait for default content to load (a default picture), before loading an own library, executing the logic and replacing the content with the desired one. Performance wise it is a disadvantage that it takes these extra steps to executed. Also this mechanism of replacing the content has a disadvantage in the domain of user experience since end users possibly see this content being changed/replaced. Finally, the owner of the application has no control on replacing the content and any undesired affects it might have. When pointing to an image, no undesired affect can occur and the owner of the application can style the picture (whichever picture that might be) any way he wants

An example of the content plugin can be found at weather.o2mc.io. This URL points to a picture which is linked to a specific DimML application. This application points the browser to one of three possible pictures, based on the current weather conditions in Uden. This logic can be extended with all the DimML flow elements in any order desired.

The 33 lines of code which generate the picture at weather.o2mc.io is

Take a look under the hood …

Click to see the code
@groovy

concept Image {
  match '*.png'
	
  //Location of our office
  val longitude = `'5.6482328'`
  val latitude = `'51.651629899999996'`

  content `uri`

  const ROOT = 'https://api.forecast.io/forecast/XXYYZZ'

  flow
  => code[url = `"${ROOT}/${latitude},${longitude}?units=si".toString()`]
  => http[url = '@url', headers = "Accept: application/json"]
  => addjson['result']
  => code[temperature = `currently.temperature`]
  => filter['temperature']
  => code[uri = `getUri(temperature)`]
  => out
	
  def getUri = { temp => `
    temp = temp.toInteger();
    if (temp<5) { return 'http://documentation.dimml.io/wp-content/uploads/2016/07/weather_l5.png' } else if (temp>15) {
	return 'http://documentation.dimml.io/wp-content/uploads/2016/07/weather_a15.png'
    } else {
	return 'http://documentation.dimml.io/wp-content/uploads/2016/07/weather_515.png'
    }
  `}
}
#mk-accordion-5a1304f0ee8fe .mk-accordion-pane{ background-color: #ffffff; }
iStock_000012107866_XXXLarge-001_1024azure-logo