X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=tools%2Fhtdocs%2Fmkws.js;h=124b3115fb9723bcf7227d31e86b8337e09fd45a;hb=588dc0fed2bd1f9240418e05a87514796679223a;hp=98b9ff83dc76c08c2df3c1d2d03d785c935c5459;hpb=ba0d56aad3966dab761111933116579ae133b615;p=mkws-moved-to-github.git
diff --git a/tools/htdocs/mkws.js b/tools/htdocs/mkws.js
index 98b9ff8..124b311 100644
--- a/tools/htdocs/mkws.js
+++ b/tools/htdocs/mkws.js
@@ -6,7 +6,6 @@
// Set up namespace and some state.
var mkws = {
filters: [],
- pp2filter: null,
};
/*
@@ -101,6 +100,42 @@ mkws.debug_function = function (string) {
}
var debug = mkws.debug_function; // local alias
+
+Handlebars.registerHelper('link', function(a) {
+ var result = "";
+ for (var i in a) {
+ if (i > 0) result += "
";
+ var text = Handlebars.Utils.escapeExpression(a[i]);
+ result += '' + text + '';
+ }
+
+ return new Handlebars.SafeString(result);
+});
+
+
+Handlebars.registerHelper('json', function(obj) {
+ return JSON.stringify(obj);
+});
+
+
+// We need {{attr name}} because Handlebars can't parse {{@@name}}
+Handlebars.registerHelper('attr', function(attrName) {
+ return this['@' + attrName];
+});
+
+
+Handlebars.registerHelper('first', function(items, options) {
+ var having = options.hash.having;
+ for (var i in items) {
+ var item = items[i]
+ if (!having || item[having]) {
+ return options.fn(item);
+ }
+ }
+ return "";
+});
+
+
{
/* default mkws config */
var config_default = {
@@ -259,9 +294,9 @@ function my_onterm(data) {
if (facets[i] == "sources") {
add_single_facet(acc, "Sources", data.xtargets, SourceMax, null);
} else if (facets[i] == "subjects") {
- add_single_facet(acc, "Subjects", data.subject, SubjectMax, "su");
+ add_single_facet(acc, "Subjects", data.subject, SubjectMax, "subject");
} else if (facets[i] == "authors") {
- add_single_facet(acc, "Authors", data.author, AuthorMax, "au");
+ add_single_facet(acc, "Authors", data.author, AuthorMax, "author");
} else {
alert("bad facet configuration: '" + facets[i] + "'");
}
@@ -271,19 +306,19 @@ function my_onterm(data) {
replaceHtml(termlist, acc.join(''));
}
-function add_single_facet(acc, caption, data, max, cclIndex) {
+function add_single_facet(acc, caption, data, max, pzIndex) {
acc.push('