From 9d4bb9913e2e68f457fc98605199df5d7264ba79 Mon Sep 17 00:00:00 2001 From: Paul Pound Date: Wed, 19 Jul 2017 10:18:24 -0300 Subject: [PATCH] added toc divs to be moved up to toc using javascript --- targets/eds/js/eds_results.js | 5 +- targets/eds/js/eds_results_article.js | 4 +- .../theme/roblib-search-eds-articles.tpl.php | 1 + targets/eds/theme/roblib-search-eds.tpl.php | 1 + .../css/roblib_search_islandscholar.css | 27 +++ .../js/islandscholar_results.js | 99 +++++++++ .../roblib_search_islandscholar.info | 8 + .../roblib_search_islandscholar.install | 2 + .../roblib_search_islandscholar.module | 197 ++++++++++++++++++ .../theme/roblib-search-islandscholar.tpl.php | 13 ++ targets/passthru_results/theme/theme.inc | 24 +++ targets/solr_site/js/solr_site_results.js | 3 + .../roblib-search-solr-site-results.tpl.php | 1 + 13 files changed, 381 insertions(+), 4 deletions(-) create mode 100644 targets/passthru_results/css/roblib_search_islandscholar.css create mode 100644 targets/passthru_results/js/islandscholar_results.js create mode 100644 targets/passthru_results/roblib_search_islandscholar.info create mode 100644 targets/passthru_results/roblib_search_islandscholar.install create mode 100644 targets/passthru_results/roblib_search_islandscholar.module create mode 100644 targets/passthru_results/theme/roblib-search-islandscholar.tpl.php create mode 100644 targets/passthru_results/theme/theme.inc diff --git a/targets/eds/js/eds_results.js b/targets/eds/js/eds_results.js index f3e9f76..befdaa1 100644 --- a/targets/eds/js/eds_results.js +++ b/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('See all results (' + data.recordCount + ')'); - jQuery('#roblib-eds-books-more-results').empty().append('See all results (' + data.recordCount + ')'); + jQuery('#roblib-search-eds-more').empty().append('See all results (' + data.recordCount + ')'); + jQuery('#roblib-eds-books-more-results').empty().append('See all results (' + data.recordCount + ')'); + jQuery('#roblib-eds-books-toc').empty().append('Books (' + data.recordCount + ')'); }); } diff --git a/targets/eds/js/eds_results_article.js b/targets/eds/js/eds_results_article.js index 83add91..fd28ac6 100644 --- a/targets/eds/js/eds_results_article.js +++ b/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('See all results (' + data.recordCount + ')'); - jQuery('#roblib-eds-articles-more-results').empty().append('See all results (' + data.recordCount + ')'); - + jQuery('#roblib-eds-articles-more-results').empty().append('See all results (' + data.recordCount + ')'); + jQuery('#roblib-eds-articles-toc').empty().append('Articles (' + data.recordCount + ')'); }); } } diff --git a/targets/eds/theme/roblib-search-eds-articles.tpl.php b/targets/eds/theme/roblib-search-eds-articles.tpl.php index 6b09c1c..0670c65 100644 --- a/targets/eds/theme/roblib-search-eds-articles.tpl.php +++ b/targets/eds/theme/roblib-search-eds-articles.tpl.php @@ -17,6 +17,7 @@
+
+
diff --git a/targets/passthru_results/css/roblib_search_islandscholar.css b/targets/passthru_results/css/roblib_search_islandscholar.css new file mode 100644 index 0000000..97e358e --- /dev/null +++ b/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; +} + diff --git a/targets/passthru_results/js/islandscholar_results.js b/targets/passthru_results/js/islandscholar_results.js new file mode 100644 index 0000000..e90a2c0 --- /dev/null +++ b/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('
\n\ + '); + try { + items.push('
'); + jQuery.each(val["mods_author_lastname_first_ms"], function (key2, val2) { + items.push('' + val2 + '; ') + }) + items.push('
') + } catch (e) { + + } + + items.push('
'); + + + if (typeof val.mods_relatedItem_host_titleInfo_title_s !== 'undefined') { + items.push('' + val.mods_relatedItem_host_titleInfo_title_s + ' ') + } + + + if (typeof val.mods_canonical_date_issued_s !== 'undefined') { + items.push('' + val.mods_canonical_date_issued_s + ' ') + } + + + if (typeof val.mods_part_detail_volume_number_s !== 'undefined') { + items.push('Vol. ' + val.mods_part_detail_volume_number_s + ' ') + } + + + if (typeof val.mods_part_detail_issue_number_s !== 'undefined') { + items.push('Issue ' + val.mods_part_detail_issue_number_s + ', ') + } + + + if (typeof val.mods_part_extent_start_s !== 'undefined') { + items.push('p' + val.mods_part_extent_start_s + '') + } + + + if (typeof val.mods_part_extent_end_s !== 'undefined') { + items.push('-' + val.mods_part_extent_end_s + ',') + } + + if (typeof val.mods_genre_s !== 'undefined') { + items.push('
' + val.mods_genre_s + '
'); + } + + if (jQuery.inArray('PDF', val.fedora_datastreams_ms) > 0) { + items.push('
full text
'); + } + + items.push('
'); + + items.push('
'); + }); + + + 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('see all results'); + + } + }); + } + +} + diff --git a/targets/passthru_results/roblib_search_islandscholar.info b/targets/passthru_results/roblib_search_islandscholar.info new file mode 100644 index 0000000..ce23845 --- /dev/null +++ b/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 \ No newline at end of file diff --git a/targets/passthru_results/roblib_search_islandscholar.install b/targets/passthru_results/roblib_search_islandscholar.install new file mode 100644 index 0000000..a4abe2d --- /dev/null +++ b/targets/passthru_results/roblib_search_islandscholar.install @@ -0,0 +1,2 @@ + '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'] = '
'; + $variables['title_suffix'] ='
'; + } +} + +/** + * 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( + '

+provides an Islandscholar target for the Roblib search module +

' + ); + } +} + diff --git a/targets/passthru_results/theme/roblib-search-islandscholar.tpl.php b/targets/passthru_results/theme/roblib-search-islandscholar.tpl.php new file mode 100644 index 0000000..208a523 --- /dev/null +++ b/targets/passthru_results/theme/roblib-search-islandscholar.tpl.php @@ -0,0 +1,13 @@ + +
Search all Results
+
+ +
+ + diff --git a/targets/passthru_results/theme/theme.inc b/targets/passthru_results/theme/theme.inc new file mode 100644 index 0000000..18ed5d0 --- /dev/null +++ b/targets/passthru_results/theme/theme.inc @@ -0,0 +1,24 @@ + array('search_url' => $search_url)), array('type' => 'setting')); +} +?> diff --git a/targets/solr_site/js/solr_site_results.js b/targets/solr_site/js/solr_site_results.js index eef3da9..05334df 100644 --- a/targets/solr_site/js/solr_site_results.js +++ b/targets/solr_site/js/solr_site_results.js @@ -35,8 +35,11 @@ Drupal.behaviors.roblib_search_solr_site_results = { if (numberOfDocs > 0) { results_url = 'see all results (' + total_found + ') '; + move_me_div_url = 'Website & Guides (' + + total_found + ') '; 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); } }); } diff --git a/targets/solr_site/theme/roblib-search-solr-site-results.tpl.php b/targets/solr_site/theme/roblib-search-solr-site-results.tpl.php index d6b30b3..433ffee 100644 --- a/targets/solr_site/theme/roblib-search-solr-site-results.tpl.php +++ b/targets/solr_site/theme/roblib-search-solr-site-results.tpl.php @@ -21,3 +21,4 @@ if (!isset($type)){
+