Browse Source

updated islandscholar target to work with new islandscholar

2.x-ebsco
Paul Pound 8 years ago
parent
commit
71733af4ed
  1. 81
      targets/islandscholar/js/islandscholar_results.js
  2. 22
      targets/islandscholar/roblib_search_islandscholar.module

81
targets/islandscholar/js/islandscholar_results.js

@ -1,7 +1,7 @@
Drupal.behaviors.roblib_search_islandscholar = {
attach: function(context, settings) {
attach: function (context, settings) {
url = settings.roblib_search_islandscholar.search_url;
jQuery.getJSON(url, function(data) {
jQuery.getJSON(url, function (data) {
var items = [];
var numberOfDocs = 0;
try {
@ -16,87 +16,70 @@ Drupal.behaviors.roblib_search_islandscholar = {
var counter = 0;
var divs = new Array();
var content = new Array();
jQuery.each(data.response.docs, function(key, val) {
jQuery.each(data.response.docs, function (key, val) {
id = 'roblib-search-islandscholar-' + counter;
content[counter] = '';
if(typeof val['mods.abstract'] !== 'undefined' ){
content[counter] = val['mods.abstract'][0];
if (typeof val['mods_abstract_s'] !== 'undefined') {
content[counter] = val['mods_abstract_s'][0];
} else {
content[counter] = 'No abstract available';
}
divs[counter++] = id;
items.push('<div class ="roblib-search-row" id="' + id + '">\n\
<div class="roblib-title islandscholar">\n\
<a href="http://www.islandscholar.ca/fedora/repository/' + val.PID +'">' + val.Title_sorted + '</a></div>');
<a href="http://www.islandscholar.ca/fedora/repository/' + val.PID + '">' + val['dc.title'] + '</a></div>');
try {
items.push('<div class="islandscholar-authors">');
jQuery.each(val["mods.author"], function(key2, val2){
jQuery.each(val["mods_author_lastname_first_ms"], function (key2, val2) {
items.push('<span class="islandscholar-author">' + val2 + ';</span> ')
})
items.push('</div>')
} catch (e){
} catch (e) {
}
try {
items.push('<div class="islandscholar-source">');
try{
if (typeof val["mods.hostTitle"][0] !== 'undefined') {
items.push('<span class="islandscholar-hostTitle">' + val["mods.hostTitle"][0] + '</span> ')
if (typeof val.mods_relatedItem_host_titleInfo_title_s !== 'undefined') {
items.push('<span class="islandscholar-hostTitle">' + val.mods_relatedItem_host_titleInfo_title_s + '</span> ')
}
} catch (err){
if (typeof val.mods_canonical_date_issued_s !== 'undefined') {
items.push('<span class="islandscholar-citation">' + val.mods_canonical_date_issued_s + '</span> ')
}
try{
jQuery.each(val.dateIssued, function(key2, val2){
items.push('<span class="islandscholar-citation">' + val2 + '</span> ')
})
} catch(err){
}
try{
jQuery.each(val["mods.volume"], function(key2, val2){
items.push('<span class="islandscholar-citation">Vol. </span><span class="islandscholar-citation">' + val2 + '</span> ')
})
} catch (err){
if (typeof val.mods_part_detail_volume_number_s !== 'undefined') {
items.push('<span class="islandscholar-citation">Vol. </span><span class="islandscholar-citation">' + val.mods_part_detail_volume_number_s + '</span> ')
}
try{
jQuery.each(val["mods.issue"], function(key2, val2){
items.push('<span class="islandscholar-citation">Issue </span><span class="islandscholar-citation">' + val2 + ',</span> ')
})
} catch (err){
}
try{
jQuery.each(val["mods.pageStart"], function(key2, val2){
items.push('<span class="islandscholar-citation">p</span><span class="islandscholar-citation">' + val2 + '</span>')
})
} catch (err){
if (typeof val.mods_part_detail_issue_number_s !== 'undefined') {
items.push('<span class="islandscholar-citation">Issue </span><span class="islandscholar-citation">' + val.mods_part_detail_issue_number_s + ',</span> ')
}
try{
jQuery.each(val["mods.pageEnd"], function(key2, val2){
items.push('<span class="islandscholar-citation">-</span><span class="islandscholar-citation">' + val2 + ',</span>')
})
} catch (err){
if (typeof val.mods_part_extent_start_s !== 'undefined') {
items.push('<span class="islandscholar-citation">p</span><span class="islandscholar-citation">' + val.mods_part_extent_start_s + '</span>')
}
jQuery.each(val.genre, function(key2, val2){
items.push('<div class="islandscholar-label">' + val2 + '</div> ')
})
try{
if(jQuery.inArray('OBJ',val.hasDatastreams) > 0){
items.push('<div>full text</div>') ;
if (typeof val.mods_part_extent_end_s !== 'undefined') {
items.push('<span class="islandscholar-citation">-</span><span class="islandscholar-citation">' + val.mods_part_extent_end_s + ',</span>')
}
} catch (err){
if (typeof val.mods_genre_s !== 'undefined') {
items.push('<div class="islandscholar-label">' + val.mods_genre_s + '</div> ');
}
items.push('</div>')
} catch (e){
if (jQuery.inArray('PDF', val.fedora_datastreams_ms) > 0) {
items.push('<div>full text</div>');
}
items.push('</div>');
items.push('</div>');
});

22
targets/islandscholar/roblib_search_islandscholar.module

@ -47,6 +47,21 @@ function roblib_search_islandscholar_config_form($form, &$form_state) {
'#description' => t('The number of results to display in the Bento box'),
'#required' => TRUE,
);
$form['roblib_search_islandscholar_fq'] = array(
'#type' => 'textarea',
'#title' => t('Filter Query'),
'#default_value' => variable_get('roblib_search_islandscholar_fq', 'PID:ir* AND (RELS_EXT_hasModel_uri_ms:info\:fedora/ir\:thesisCModel OR RELS_EXT_hasModel_uri_ms:info\:fedora/ir\:citationCModel)'),
'#description' => t('A query used to restrict the results to namespace and content models'),
'#required' => TRUE,
);
$form['roblib_search_islandscholar_qf'] = array(
'#type' => 'textarea',
'#title' => t('Query Field'),
'#default_value' => variable_get('roblib_search_islandscholar_qf', 'dc.title^2.5 dc.creator^5.0 dc.contributor^2.0 dc.description^2.0 dc.identifier^2.0 dc.type^2.0 catch_all_fields_mt^1.0'),
'#description' => t('The fields to query and a weight for each field.'),
'#required' => TRUE,
);
return system_settings_form($form);
}
@ -90,7 +105,7 @@ function roblib_search_islandscholar_block_info() {
$blocks['roblib_islandscholar_results'] = array(
// info: The name of the block.
'info' => t('Islandscholar Solr Search Results block'),
'info' => t('Roblib Islandscholar Solr Search Results block'),
// Block caching options (per role, per user, etc.)
'cache' => DRUPAL_CACHE_PER_ROLE, // default
);
@ -141,9 +156,10 @@ function roblib_search_islandscholar_get_search_url($query){
$data = array(
'wt' => 'json',
'q' => $query ,
'fq' => 'PID:ir* AND (rels.hasModel:info\:fedora/islandora\:thesisCModel OR rels.hasModel:info\:fedora/islandora\:citationCModel)',
'qf' => 'mods.title^3.0 mods.subTitle^2.5 mods.author^5.0 mods.department^2.0 mods.abstract^1.5 dc.title^2.5 mods.subject^1.5 dc.creator^5.0 dc.contributor^2.0 dc.description^2.0 mods.genre^1.0 mods.hostTitle^2.0 mods.issn^1.0 mods.date^2.0 pdf.text^2.0 dsm.PDF^2.0 collection_title^1.0',
'fq' => variable_get('roblib_search_islandscholar_fq','PID:ir* AND (RELS_EXT_hasModel_uri_ms:info\:fedora/ir\:thesisCModel OR RELS_EXT_hasModel_uri_ms:info\:fedora/ir\:citationCModel)'),
'qf' => variable_get('roblib_search_islandscholar_qf','dc.title^2.5 dc.creator^5.0 dc.contributor^2.0 dc.description^2.0 dc.identifier^2.0 dc.type^2.0 catch_all_fields_mt^1.0'),
'rows' => $num_results,
'defType' => 'dismax',
);
$url = url($solr_url . '/select', array('query' => $data));
return $url;

Loading…
Cancel
Save