From 8617bd1f65ea0576e2384cf7dc7fff483344fcc7 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Thu, 22 May 2014 15:21:51 +0100 Subject: [PATCH] Add new Handlebars helper, mkws-googleurl Use this in the CredoImage template to eliminate redirection --- examples/htdocs/mkws-widget-credo.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/examples/htdocs/mkws-widget-credo.js b/examples/htdocs/mkws-widget-credo.js index c0e6a78..e66559e 100644 --- a/examples/htdocs/mkws-widget-credo.js +++ b/examples/htdocs/mkws-widget-credo.js @@ -1,3 +1,14 @@ +// The Google Images database returns links like: +// http://images.google.com/url?q=http://eofdreams.com/fish.html&sa=U&ei=RAB-U9XNDo2Dqga1o4L4Bw&ved=0CC4Q9QEwAA&usg=AFQjCNFhRtn6GMevHbpITZ6kfx6rsHV2ow +// This Handlebars helper avoids a pointless redirect by transforming +// this to the URL of the underling page, in this case +// http://eofdreams.com/fish.html +// +Handlebars.registerHelper('mkws-googleurl', function(obj) { + return mkws.getParameterByName('q', obj[0]); +}); + + // ### This works inefficiently by having multiple teams all run the // same search against different sets of targets. A much better // approach would be run a single search, with all these panels @@ -9,7 +20,7 @@ mkws.registerWidgetType('Credo', function() { this.team.registerTemplate('CredoImage', '\
\ - \ + \ {{#mkws-first md-thumburl}}\ {{../md-title}}\ {{/mkws-first}}\ -- 1.7.10.4