Browse Source

added toc divs to be moved up to toc using javascript

2.x-ebsco
Paul Pound 7 years ago
parent
commit
9d4bb9913e
  1. 5
      targets/eds/js/eds_results.js
  2. 4
      targets/eds/js/eds_results_article.js
  3. 1
      targets/eds/theme/roblib-search-eds-articles.tpl.php
  4. 1
      targets/eds/theme/roblib-search-eds.tpl.php
  5. 27
      targets/passthru_results/css/roblib_search_islandscholar.css
  6. 99
      targets/passthru_results/js/islandscholar_results.js
  7. 8
      targets/passthru_results/roblib_search_islandscholar.info
  8. 2
      targets/passthru_results/roblib_search_islandscholar.install
  9. 197
      targets/passthru_results/roblib_search_islandscholar.module
  10. 13
      targets/passthru_results/theme/roblib-search-islandscholar.tpl.php
  11. 24
      targets/passthru_results/theme/theme.inc
  12. 3
      targets/solr_site/js/solr_site_results.js
  13. 1
      targets/solr_site/theme/roblib-search-solr-site-results.tpl.php

5
targets/eds/js/eds_results.js

@ -75,8 +75,9 @@ Drupal.behaviors.roblib_search_eds = {
//var host = "http://eds-api.ebscohost.com";
//var get = "/edsapi/rest/Search?query=history&searchmode=all&resultsperpage=20&pagenumber=1&sort=relevance&highlight=y&includefacets=y&facetfilter=1%2cSourceType%3aMagazines%2cSourceType%3aNews%2cSourceType%3aAcademic+Journals%2cSourceType%3aConference+Materials&view=detailed";
var href_str = 'http://search.ebscohost.com/login.aspx?direct=true&site=ehost-live&scope=site&type=1&custid=uprince&groupid=main&profid=' + profile + '&mode=bool&lang=en&bquery=';
jQuery('#roblib-search-eds-more').empty().append('<a href="http://proxy.library.upei.ca/login?url=' + href_str + query_str + '" id="see_all_results">See all results (' + data.recordCount + ')</a>');
jQuery('#roblib-eds-books-more-results').empty().append('<a href="http://proxy.library.upei.ca/login?url=' + href_str + query_str + '" id="see_all_results">See all results (' + data.recordCount + ')</a>');
jQuery('#roblib-search-eds-more').empty().append('<a href="http://proxy.library.upei.ca/login?url=' + href_str + query_str + '" id="eds-see_all_results">See all results (' + data.recordCount + ')</a>');
jQuery('#roblib-eds-books-more-results').empty().append('<a href="http://proxy.library.upei.ca/login?url=' + href_str + query_str + '" id="eds-see_all_results-button">See all results (' + data.recordCount + ')</a>');
jQuery('#roblib-eds-books-toc').empty().append('<a href="http://proxy.library.upei.ca/login?url=' + href_str + query_str + '" id="eds-see_all_results-toc">Books (' + data.recordCount + ')</a>');
});
}

4
targets/eds/js/eds_results_article.js

@ -73,8 +73,8 @@ Drupal.behaviors.roblib_search_eds_articles = {
var query_str = data.queries[0].query;
var href_str = 'http://search.ebscohost.com/login.aspx?direct=true&site=ehost-live&scope=site&type=1&custid=uprince&groupid=main&profid=' + profile + '&mode=bool&lang=en&bquery=';
jQuery('#roblib-search-eds-article-more').empty().append('<a href="http://proxy.library.upei.ca/login?url=' + href_str + query_str + '" id="eds-article-see-all-results">See all results (' + data.recordCount + ')</a>');
jQuery('#roblib-eds-articles-more-results').empty().append('<a href="http://proxy.library.upei.ca/login?url=' + href_str + query_str + '" id="eds-article-see-all-results">See all results (' + data.recordCount + ')</a>');
jQuery('#roblib-eds-articles-more-results').empty().append('<a href="http://proxy.library.upei.ca/login?url=' + href_str + query_str + '" id="eds-article-see-all-results-button">See all results (' + data.recordCount + ')</a>');
jQuery('#roblib-eds-articles-toc').empty().append('<a href="http://proxy.library.upei.ca/login?url=' + href_str + query_str + '" id="eds-article-see-all-results-toc">Articles (' + data.recordCount + ')</a>');
});
}
}

1
targets/eds/theme/roblib-search-eds-articles.tpl.php

@ -17,6 +17,7 @@
</div>
<div id="roblib-eds-articles-more-results" class="roblib-eds-more-button button"></div>
<div id="roblib-eds-articles-toc" class="roblib-bento-toc moveme-please"></div>
<?php
/**
* Alternate way to create link back to ebscohost.

1
targets/eds/theme/roblib-search-eds.tpl.php

@ -11,4 +11,5 @@
</div>
<div id="roblib-eds-books-more-results" class="roblib-eds-more-button button"></div>
<div id="roblib-eds-books-toc" class="roblib-bento-toc moveme-please"></div>

27
targets/passthru_results/css/roblib_search_islandscholar.css

@ -0,0 +1,27 @@
/*
Document : roblib_search_evergreen
Created on : Apr 11, 2013, 2:27:50 PM
Author : ppound
Description:
Purpose of the stylesheet follows.
*/
.islandscholar-citation, .islandscholar-author{
font-size: smaller;
}
.islandscholar-hostTitle{
font-size: smaller;
font-style: italic;
}
.islandscholar-genre, .islandscholar-volume{
padding-left: 10px; font-size: smaller;
}
.islandscholar-authors, .islandscholar-source {
padding-left: 10px;
}
.islandscholar-label {
font-size: smaller; font-weight: bolder;
}

99
targets/passthru_results/js/islandscholar_results.js

@ -0,0 +1,99 @@
Drupal.behaviors.roblib_search_islandscholar = {
attach: function (context, settings) {
url = settings.roblib_search_islandscholar.search_url;
jQuery.getJSON(url, function (data) {
var items = [];
var numberOfDocs = 0;
try {
numberOfDocs = data.response.docs.length;
} catch (err) {
// do nothing leave docLength at 0
}
if (numberOfDocs < 1) {
jQuery('#' + 'roblib-search-content-islandscholar').empty().append('No Results');
jQuery('.' + 'pane-roblib-search-islandscholar-roblib-islandscholar-results').hide();
} else {
var counter = 0;
var divs = new Array();
var content = new Array();
jQuery.each(data.response.docs, function (key, val) {
id = 'roblib-search-islandscholar-' + counter;
content[counter] = '';
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['dc.title'] + '</a></div>');
try {
items.push('<div class="islandscholar-authors">');
jQuery.each(val["mods_author_lastname_first_ms"], function (key2, val2) {
items.push('<span class="islandscholar-author">' + val2 + ';</span> ')
})
items.push('</div>')
} catch (e) {
}
items.push('<div class="islandscholar-source">');
if (typeof val.mods_relatedItem_host_titleInfo_title_s !== 'undefined') {
items.push('<span class="islandscholar-hostTitle">' + val.mods_relatedItem_host_titleInfo_title_s + '</span> ')
}
if (typeof val.mods_canonical_date_issued_s !== 'undefined') {
items.push('<span class="islandscholar-citation">' + val.mods_canonical_date_issued_s + '</span> ')
}
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> ')
}
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> ')
}
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>')
}
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>')
}
if (typeof val.mods_genre_s !== 'undefined') {
items.push('<div class="islandscholar-label">' + val.mods_genre_s + '</div> ');
}
if (jQuery.inArray('PDF', val.fedora_datastreams_ms) > 0) {
items.push('<div>full text</div>');
}
items.push('</div>');
items.push('</div>');
});
jQuery('#roblib-search-content-islandscholar').empty().append(items.join(''));
qtipify(divs, content, 'Abstract');
var number = data.response.numFound;
var query = encodeURIComponent(data.responseHeader.params.q);//.'milk';
jQuery('#roblib-search-islandscholar-more').empty().append('<a id="islandscholar-see-more-result"' +
' href="http://www.islandscholar.ca/islandora/search/' + query + '?type=dismax">see all results</a>');
}
});
}
}

8
targets/passthru_results/roblib_search_islandscholar.info

@ -0,0 +1,8 @@
name = Roblib Search IslandScholar
dependencies[] = roblib_search
configure = admin/roblib_search/islandscholar_search
description = implements the Roblib Search IslandScholar results
package = Roblib Search
version = 7.x-dev
core = 7.x
stylesheets[all][] = css/roblib_search_islandscholar.css

2
targets/passthru_results/roblib_search_islandscholar.install

@ -0,0 +1,2 @@
<?php

197
targets/passthru_results/roblib_search_islandscholar.module

@ -0,0 +1,197 @@
<?php
/**
* @file
* Implementation of Roblib search for searching several targets.
*/
/**
* Implements hook_menu().
*/
function roblib_search_islandscholar_menu() {
$items = array();
$items['admin/roblib_search/islandscholar_search'] = array(
'title' => 'Roblib Islandscholar Search Target configuration',
'description' => 'Configuration for the Roblib Islandscholar site search target',
'page callback' => 'drupal_get_form',
'page arguments' => array('roblib_search_islandscholar_config_form'),
'access arguments' => array('access administration pages'),
'type' => MENU_NORMAL_ITEM,
);
$items['roblib_search/islandscholar/ajax/%'] = array(
'title' => 'islandscholar ajax',
'page callback' => 'roblib_search_islandscholar_ajax',
'page arguments' => array(3),
'type' => MENU_CALLBACK,
'access arguments' => array('search roblib islandscholar'),
);
return $items;
}
function roblib_search_islandscholar_config_form($form, &$form_state) {
$form['roblib_search_islandscholar_url'] = array(
'#type' => 'textfield',
'#title' => t('Islandscholar Solr url'),
'#default_value' => variable_get('roblib_search_islandscholar_url', 'http://www.islandscholar.ca:8080/solr/'),
'#description' => t('The base Islandscholar Solr URL, for example http://www.islandscholar.ca:8080/solr/'),
'#required' => TRUE,
);
$form['roblib_search_islandscholar_num_results'] = array(
'#type' => 'textfield',
'#title' => t('Number of results to return'),
'#default_value' => variable_get('roblib_search_islandscholar_num_results', '5'),
'#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);
}
/**
* Implements hook_permission().
*/
function roblib_search_islandscholar_permission() {
return array(
'search roblib islandscholar' => array(
'title' => t('Search the islandscholar target'),
'description' => t('Search all Roblib islandscholar target. This permission exposes the search blocks and allows you to see search results.'),
),
'administer roblib search_islandscholar' => array(
'title' => t('Administer Roblib Search Evergreen'),
'description' => t('Administer settings for the Roblib islandscholar search client.'),
),
);
}
/**
* Implements hook_theme().
*/
function roblib_search_islandscholar_theme() {
// set path
$path = drupal_get_path('module', 'roblib_search_islandscholar');
$file = 'theme.inc';
return array(
// results page
'roblib_search_islandscholar' => array(
'path' => $path . '/theme',
'file' => $file,
'template' => 'roblib-search-islandscholar',
'variables' => array('results' => NULL),
)
);
}
function roblib_search_islandscholar_block_info() {
$blocks['roblib_islandscholar_results'] = array(
// info: The name of the block.
'info' => t('Roblib Islandscholar Solr Search Results block'),
// Block caching options (per role, per user, etc.)
'cache' => DRUPAL_CACHE_PER_ROLE, // default
);
return $blocks;
}
function roblib_search_islandscholar_preprocess_panels_pane(&$variables, $hook){
if($variables['pane']->subtype == 'roblib_search_islandscholar-roblib_islandscholar_results'){
$variables['title_prefix'] = '<div class="roblib-search-header roblib-search-islandscholar-header">';
$variables['title_suffix'] ='</div>';
}
}
/**
* Implements hook_block_view().
*/
function roblib_search_islandscholar_block_view($delta = '') {
//The $delta parameter tells us which block is being requested.
switch ($delta) {
case 'roblib_islandscholar_results':
$block['subject'] = t('IslandScholar');
$block['content'] = theme('roblib_search_islandscholar', array('results' => NULL));
break;
}
return $block;
}
/**
* An endpoint for the islandscholar ajax call
*
* @param string $query
*
*/
function roblib_search_islandscholar_ajax($query) {
$output = roblib_search_islandscholar_get_results($query);
print $output;
exit();
}
/**
* @param $query
* @return string
*/
function roblib_search_islandscholar_get_search_url($query){
$solr_url = variable_get('roblib_search_islandscholar_url', 'http://localhost:8983/solr');
$num_results = variable_get('roblib_search_islandscholar_num_results', '5');
$data = array(
'wt' => 'json',
'q' => $query ,
'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;
}
/**
*
* @param string $query
*
* @return string
* json
*/
function roblib_search_islandscholar_get_results($query) {
$url = roblib_search_islandscholar_get_search_url($query);
$results = drupal_http_request($url);
if($results->code != '200'){
return "";
}
return $results->data;
}
/**
* Implements hook_help().
*/
function roblib_search_islandscholar_help($path, $arg) {
switch ($path) {
case 'admin/help#roblib_search_islandscholar':
return t(
'<p>
provides an Islandscholar target for the Roblib search module
</p>'
);
}
}

13
targets/passthru_results/theme/roblib-search-islandscholar.tpl.php

@ -0,0 +1,13 @@
<?php
/**
* @file roblib-search-islandscholar.tpl.php
*/
?>
<div class ="roblib-search-more" id="roblib-search-islandscholar-more">Search all Results</div>
<div class ="roblib-search-content solr-site" id="roblib-search-content-islandscholar">
<img src="<?php print (empty($spinner_path) ? ' ' : $spinner_path); ?>"/>
</div>

24
targets/passthru_results/theme/theme.inc

@ -0,0 +1,24 @@
<?php
/*
* all we do here is pass a url to some javascript so results can be loaded
* indepentantly
*/
function roblib_search_islandscholar_preprocess_roblib_search_islandscholar(&$variables) {
global $base_url;
if (!isset($query)) {
if (isset($_GET['roblib_query'])) {
$query = $_GET['roblib_query'];
}
else {
return '';
}
}
$spinner_path = $base_url . '/' . drupal_get_path('module', 'roblib_search') . '/img/'.'spinner.gif';
$variables['spinner_path'] = $spinner_path;
$search_url = $base_url .'/roblib_search/islandscholar/ajax/'.urlencode($query);
drupal_add_js(drupal_get_path('module', 'roblib_search_islandscholar') . '/js/islandscholar_results.js');
drupal_add_js(array('roblib_search_islandscholar' => array('search_url' => $search_url)), array('type' => 'setting'));
}
?>

3
targets/solr_site/js/solr_site_results.js

@ -35,8 +35,11 @@ Drupal.behaviors.roblib_search_solr_site_results = {
if (numberOfDocs > 0) {
results_url = '<a href="' + baseUrl + '/search/' + default_site_type + query + '?f[0]=(-bundle:bestbet)"' + '>see all results ('
+ total_found + ') </a>';
move_me_div_url = '<a href="' + baseUrl + '/search/' + default_site_type + query + '?f[0]=(-bundle:bestbet)"' + '>Website & Guides ('
+ total_found + ') </a>';
jQuery('#' + 'roblib-search-solr-site-results-more').empty().append(results_url);
jQuery('#' + 'roblib-solr-more-results-results').empty().append(results_url);
jQuery('#' + 'roblib-solr-search-toc-results').empty().append(move_me_div_url);
}
});
}

1
targets/solr_site/theme/roblib-search-solr-site-results.tpl.php

@ -21,3 +21,4 @@ if (!isset($type)){
</div>
<div id="roblib-solr-more-results-<?php print($type)?>" class="roblib-solr-more-button button"></div>
<div id="roblib-solr-search-toc-<?php print($type)?>" class="roblib-bento-toc moveme-please"></div>

Loading…
Cancel
Save