From: Jason Skomorowski Date: Mon, 22 Sep 2014 13:32:46 +0000 (-0400) Subject: Merge branch 'master' into templateallthemarkup X-Git-Tag: 1.0.0~324^2~26 X-Git-Url: http://git.indexdata.com/?p=mkws-moved-to-github.git;a=commitdiff_plain;h=8ecc7b5621fa3f7191205e6ce93a8ef097e873bd;hp=-c Merge branch 'master' into templateallthemarkup --- 8ecc7b5621fa3f7191205e6ce93a8ef097e873bd diff --combined src/mkws-core.js index b44ca58,6b3e00d..718c350 --- a/src/mkws-core.js +++ b/src/mkws-core.js @@@ -20,7 -20,6 +20,7 @@@ window.mkws = // initial value allows jQuery popup to use logging. teams: {}, widgetType2function: {}, + defaultTemplates: {}, locale_lang: { "de": { @@@ -168,13 -167,13 +168,13 @@@ mkws.setMkwsConfig = function(overrides var config_default = { use_service_proxy: true, - pazpar2_url: "//mkws.indexdata.com/service-proxy/", - service_proxy_auth: undefined, // generally rolled from the next three properties - // Was: //mkws.indexdata.com/service-proxy-auth - pp2_hostname: "mkws.indexdata.com", - sp_path: "service-proxy-auth", - sp_auth_query: undefined, // Will be: "command=auth&action=perconfig", - sp_auth_credentials: undefined, + pazpar2_url: undefined, + pp2_hostname: "sp-mkws.indexdata.com", + pp2_path: "service-proxy", + service_proxy_auth: undefined, + sp_auth_path: "service-proxy/", + sp_auth_query: "command=auth&action=perconfig", + sp_auth_credentials: "XXX/XXX", // Should be undefined: see bug MKSP-125. lang: "", sort_options: [["relevance"], ["title:1", "title"], ["date:0", "newest"], ["date:1", "oldest"]], perpage_options: [10, 20, 30, 50], @@@ -189,7 -188,6 +189,7 @@@ facets: ["xtargets", "subject", "author"], /* display facets, in this order, [] for none */ responsive_design_width: undefined, /* a page with less pixel width considered as narrow */ log_level: 1, /* log level for development: 0..2 */ + template_vars: {}, /* values that may be exposed to templates */ dummy: "dummy" }; @@@ -213,6 -211,110 +213,6 @@@ mkws.objectInheritingFrom = function(o } -mkws.defaultTemplate = function(name) { - if (name === 'Record') { - return '\ -\ - \ - \ - \ - \ - {{#if md-date}}\ - \ - \ - \ - \ - {{/if}}\ - {{#if md-author}}\ - \ - \ - \ - \ - {{/if}}\ - {{#if md-electronic-url}}\ - \ - \ - \ - \ - {{/if}}\ - {{#mkws-if-any location having="md-subject"}}\ - \ - \ - \ - \ - {{/mkws-if-any}}\ - \ - \ - \ - \ -
{{mkws-translate "Title"}}\ - {{md-title}}\ - {{#if md-title-remainder}}\ - ({{md-title-remainder}})\ - {{/if}}\ - {{#if md-title-responsibility}}\ - {{md-title-responsibility}}\ - {{/if}}\ -
{{mkws-translate "Date"}}{{md-date}}
{{mkws-translate "Author"}}{{md-author}}
{{mkws-translate "Links"}}\ - {{#each md-electronic-url}}\ - Link{{mkws-index1}}\ - {{/each}}\ -
{{mkws-translate "Subject"}}\ - {{#mkws-first location having="md-subject"}}\ - {{#if md-subject}}\ - {{#mkws-commaList md-subject}}\ - {{this}}{{/mkws-commaList}}\ - {{/if}}\ - {{/mkws-first}}\ -
{{mkws-translate "Locations"}}\ - {{#mkws-commaList location}}\ - {{mkws-attr "@name"}}{{/mkws-commaList}}\ -
\ -'; - } else if (name === "Summary") { - return '\ -\ - {{md-title}}\ -\ -{{#if md-title-remainder}}\ - {{md-title-remainder}}\ -{{/if}}\ -{{#if md-title-responsibility}}\ - {{md-title-responsibility}}\ -{{/if}}\ -{{#if md-date}}, {{md-date}}\ -{{#if location}}\ -, {{#mkws-first location}}{{mkws-attr "@name"}}{{/mkws-first}}\ -{{/if}}\ -{{#if md-medium}}\ -, {{md-medium}}\ -{{/if}}\ -{{/if}}\ -'; - } else if (name === "Image") { - return '\ - \ - {{#mkws-first md-thumburl}}\ - {{../md-title}}\ - {{/mkws-first}}\ -
\ -
\ -'; - } else if (name === 'Facet') { - return '\ -{{term}}\ -{{count}}\ -'; - } - - return null; -}; - - // The following functions are dispatchers for team methods that // are called from the UI using a team-name rather than implicit // context. @@@ -257,6 -359,18 +257,18 @@@ mkws.pagerNext = function(tname) }; + mkws.pazpar2_url = function() { + if (mkws.config.pazpar2_url) { + mkws.log("using pre-baked pazpar2_url '" + mkws.config.pazpar2_url + "'"); + return mkws.config.pazpar2_url; + } else { + var s = document.location.protocol + "//" + mkws.config.pp2_hostname + "/" + mkws.config.pp2_path + "/"; + mkws.log("generated pazpar2_url '" + s + "'"); + return s; + } + }; + + // wrapper to provide local copy of the jQuery object. (function($) { var log = mkws.log; @@@ -533,9 -647,9 +545,9 @@@ } // protocol independent link for pazpar2: "//mkws/sp" -> "https://mkws/sp" - if (mkws.config.pazpar2_url.match(/^\/\//)) { + if (mkws.pazpar2_url().match(/^\/\//)) { mkws.config.pazpar2_url = document.location.protocol + mkws.config.pazpar2_url; - log("adjusted protocol independent link to " + mkws.config.pazpar2_url); + log("adjusted protocol independent link to " + mkws.pazpar2_url()); } if (mkws.config.responsive_design_width) { @@@ -574,7 -688,7 +586,7 @@@ } else { var s = '//'; s += config.auth_hostname ? config.auth_hostname : config.pp2_hostname; - s += '/' + config.sp_path; + s += '/' + config.sp_auth_path; var q = config.sp_auth_query; if (q) { s += '?' + q; @@@ -592,7 -706,7 +604,7 @@@ if (mkws.config.use_service_proxy && !mkws.authenticated && !mkws.authenticating) { authenticateSession(sp_auth_url(mkws.config), mkws.config.service_proxy_auth_domain, - mkws.config.pazpar2_url); + mkws.pazpar2_url()); } else if (!mkws.authenticating) { // raw pp2 or we have a session already open runAutoSearches(); diff --combined src/mkws-team.js index c2d7fca,011d643..92536f1 --- a/src/mkws-team.js +++ b/src/mkws-team.js @@@ -41,13 -41,11 +41,13 @@@ function team($, teamName) that.submitted = function() { return m_submitted; }; that.sortOrder = function() { return m_sortOrder; }; that.perpage = function() { return m_perpage; }; + that.query = function() { return m_query; }; that.totalRecordCount = function() { return m_totalRecordCount; }; that.currentPage = function() { return m_currentPage; }; that.currentRecordId = function() { return m_currentRecordId; }; that.currentRecordData = function() { return m_currentRecordData; }; that.filters = function() { return m_filterSet; }; + that.gotRecords = function() { return m_gotRecords; }; // Accessor methods for individual widgets: writers that.set_sortOrder = function(val) { m_sortOrder = val }; @@@ -96,7 -94,7 +96,7 @@@ // then register the form submit event with the pz2.search function // autoInit is set to true on default m_paz = new pz2({ "windowid": teamName, - "pazpar2path": config.pazpar2_url, + "pazpar2path": mkws.pazpar2_url(), "usesessions" : config.use_service_proxy ? false : true, "oninit": onInit, "onbytarget": onBytarget, @@@ -151,7 -149,6 +151,7 @@@ log("record"); // FIXME: record is async!! clearTimeout(m_paz.recordTimer); + queue("record").publish(data); var detRecordDiv = findnode(recordDetailsId(data.recid[0])); if (detRecordDiv.length) { // in case on_show was faster to redraw element @@@ -306,12 -303,6 +306,12 @@@ m_paz.search(m_query, m_perpage, m_sortOrder, pp2filter, undefined, params); } + // fetch record details to be retrieved from the record queue + that.fetchDetails = function(recId) { + log("fetchDetails() requesting record '" + recId + "'"); + m_paz.record(recId); + }; + // switching view between targets and records function switchView(view) { @@@ -398,34 -389,38 +398,34 @@@ function loadTemplate(name, fallbackString) { var template = m_template[name]; - - if (template === undefined) { - // Fall back to generic template if there is no team-specific one + if (template === undefined && Handlebars.compile) { var source; var node = $(".mkwsTemplate_" + name + " .mkwsTeam_" + that.name()); if (node && node.length < 1) { node = $(".mkwsTemplate_" + name); } - if (node) { - source = node.html(); - } - - // If the template is not defined in HTML, check the following - // in order: template registered in the team by a widget; - // fallback string provided on this invocation; global default. - if (!source) { - source = m_templateText[name]; - } - if (!source) { - source = fallbackString; + if (node) source = node.html(); + if (!source) source = m_templateText[name]; + if (source) { + template = Handlebars.compile(source); + log("compiled template '" + name + "'"); } - if (!source) { - source = mkws.defaultTemplate(name); - } - - if (!source) return null; - template = Handlebars.compile(source); - log("compiled template '" + name + "'"); + } + //if (template === undefined) template = mkws_templatesbyteam[m_teamName][name]; + if (template === undefined && Handlebars.templates) { + template = Handlebars.templates[name]; + } + if (template === undefined && mkws.defaultTemplates) { + template = mkws.defaultTemplates[name]; + } + if (template) { m_template[name] = template; + return template; } - - return template; + else { + mkws.log("No MKWS template for " + name); + return null; + } } that.loadTemplate = loadTemplate;