1 // The Google Images database returns links like:
2 // http://images.google.com/url?q=http://eofdreams.com/fish.html&sa=U&ei=RAB-U9XNDo2Dqga1o4L4Bw&ved=0CC4Q9QEwAA&usg=AFQjCNFhRtn6GMevHbpITZ6kfx6rsHV2ow
3 // This Handlebars helper avoids a pointless redirect by transforming
4 // this to the URL of the underling page, in this case
5 // http://eofdreams.com/fish.html
7 Handlebars.registerHelper('mkws-googleurl', function(obj) {
9 return "obj undefined";
11 return "obj[0] undefined, JSON=" + $.toJSON(obj);
13 return mkws.getParameterByName('q', obj[0]);
18 // ### This works inefficiently by having multiple teams all run the
19 // same search against different sets of targets. A much better
20 // approach would be run a single search, with all these panels
21 // members of the same team, but picking out only the results relevant
22 // to them. That will be more work.
24 mkws.registerWidgetType('Credo', function() {
27 this.team.registerTemplate('CredoImage', '\
29 <a href="{{mkws-googleurl md-electronic-url}}" target="_blank">\
30 {{#mkws-first md-thumburl}}\
31 <img src="{{this}}" alt="{{../md-title}}"/>\
42 // Main panel: encylopaedia and images on the left, topics on the right
43 s.push('<tr class="front">');
45 s.push('<td class="main">');
46 s.push(section('encyclopaedia', 'Topic Page: ### title',
47 this.subwidget('Reference', { _team: 'ref' })));
48 // The Images widget needs to be in our team so we can set its template
49 s.push(section('image', 'Images',
50 this.subwidget('GoogleImage', { maxrecs: 4, template: 'CredoImage' })));
53 s.push('<td class="side">');
54 s.push(section('mindmap', 'Create a Mind Map for ### title',
55 this.subwidget('Mindmap', { _team: 'main', facet: 'subject' })));
56 s.push(section('topics', 'Related Topics',
57 this.subwidget('Facet', { _team: 'main', facet: 'subject' })));
62 s.push('<tr><td colspan="2"><hr class="divider"/></td></tr>');
64 s.push(sectionRow('entries', 'Credo Entries',
65 this.subwidget('Records', { _team: 'main' })));
66 s.push(sectionRow('articles', 'Articles',
67 this.subwidget('Records', { _team: 'articles', targetfilter: 'categories=articles' })));
68 s.push(sectionRow('books', 'Books',
69 this.subwidget('Records', { _team: 'books', targetfilter: 'categories=books' })));
70 s.push(sectionRow('news', 'News',
71 this.subwidget('Records', { _team: 'news', targetfilter: 'categories=news' })));
72 s.push(sectionRow('resources', 'Suggested Resources',
73 "### Not yet implemented"));
77 this.node.html(s.join(''));
80 function section(xclass, title, content) {
82 s.push('<div class="' + xclass + ' section">');
83 s.push('<div class="title">' + title + '</div>');
84 s.push('<div class="content">' + content + '</div>');
89 function sectionRow(xclass, title, content) {
92 s.push('<td colspan="2">');
93 s.push(section(xclass, title, content));
101 mkws.registerWidgetType('Mindmap', function() {
102 this.node.html("### We do not yet have a Mindmap widget");