Browse Source

updated solr site target and removed some base css

2.x-ebsco
Paul Pound 10 years ago
parent
commit
d0bd7786d0
  1. 4
      css/roblib_search.base.css
  2. 6
      targets/islandscholar/roblib_search_islandscholar.module
  3. 36
      targets/solr_site/js/solr_site_results.js
  4. 29
      targets/solr_site/roblib_search_solr_site.module
  5. 4
      targets/solr_site/theme/roblib-search-solr-site.tpl.php
  6. 4
      targets/solr_site/theme/theme.inc

4
css/roblib_search.base.css

@ -6,9 +6,9 @@
Purpose of the stylesheet follows. Purpose of the stylesheet follows.
*/ */
.panel-pane {background:#f4f4f4 url(../img/bggradientresult.jpg) repeat-x top left;position:relative;overflow:hidden; padding: 5px;padding-left: 10px; /*.panel-pane {background:#f4f4f4 url(../img/bggradientresult.jpg) repeat-x top left;position:relative;overflow:hidden; padding: 5px;padding-left: 10px;
border-left:1px solid #cecfcc; border-right:1px solid #cecfcc; line-height: 1.5em; margin-bottom:10px; border-bottom:1px solid #cecfcc; border-left:1px solid #cecfcc; border-right:1px solid #cecfcc; line-height: 1.5em; margin-bottom:10px; border-bottom:1px solid #cecfcc;
} }*/
.roblib-search-row { .roblib-search-row {
border-bottom:1px #cecfcc dotted; border-bottom:1px #cecfcc dotted;
} }

6
targets/islandscholar/roblib_search_islandscholar.module

@ -88,9 +88,9 @@ function roblib_search_islandscholar_theme() {
function roblib_search_islandscholar_block_info() { function roblib_search_islandscholar_block_info() {
$blocks['roblib_search_islandscholar_results'] = array( $blocks['roblib_islandscholar_results'] = array(
// info: The name of the block. // info: The name of the block.
'info' => t('Roblib Islandscholar Solr Search Results block'), 'info' => t('Islandscholar Solr Search Results block'),
// Block caching options (per role, per user, etc.) // Block caching options (per role, per user, etc.)
'cache' => DRUPAL_CACHE_PER_ROLE, // default 'cache' => DRUPAL_CACHE_PER_ROLE, // default
); );
@ -104,7 +104,7 @@ function roblib_search_islandscholar_block_info() {
function roblib_search_islandscholar_block_view($delta = '') { function roblib_search_islandscholar_block_view($delta = '') {
//The $delta parameter tells us which block is being requested. //The $delta parameter tells us which block is being requested.
switch ($delta) { switch ($delta) {
case 'roblib_search_islandscholar_results': case 'roblib_islandscholar_results':
$block['subject'] = t('IslandScholar'); $block['subject'] = t('IslandScholar');
$block['content'] = theme('roblib_search_islandscholar', array('results' => NULL)); $block['content'] = theme('roblib_search_islandscholar', array('results' => NULL));
break; break;

36
targets/solr_site/js/solr_site_results.js

@ -1,6 +1,7 @@
Drupal.behaviors.roblib_search_solr_site = { Drupal.behaviors.roblib_search_solr_site = {
attach: function(context, settings) { attach: function(context, settings) {
url = settings.roblib_search_solr_site.search_url; url = settings.roblib_search_solr_site.search_url;
query = settings.roblib_search_solr_site.search_query;
jQuery.getJSON(url, function(data) { jQuery.getJSON(url, function(data) {
var items = []; var items = [];
var numberOfDocs = 0; var numberOfDocs = 0;
@ -19,36 +20,19 @@ Drupal.behaviors.roblib_search_solr_site = {
items.push('<div class ="roblib-search-row">\n\ items.push('<div class ="roblib-search-row">\n\
<div class="roblib-title solr-site">\n\ <div class="roblib-title solr-site">\n\
<a href="' + val.url + '">' + val.label + '</a></div></div>'); <a href="' + val.url + '">' + val.label + '</a></div></div>');
//items.push('<div class ="roblib-solr-site-teaser">' + val.teaser + '</div>')
}); });
var number = parseInt(data.rows); jQuery('#roblib-search-content-solr-site').empty().append(items.join(''));
jQuery('#' + 'roblib-search-content-solr-site').empty(); var number = data.response.numFound;
items = showMoreItems(items, number); //var query = encodeURIComponent(data.responseHeader.params.q);//.'milk';
} var scholarUrl = "http://www.islandscholar.ca/islandora/solr/search/"
}); jQuery('#' + 'roblib-search-solr-site-more').empty().append('<a id="solr-site-see-more-result"' +
} 'href="search/site/' + query + '">see all ' + number + ' results</a>');
}
function showMoreItems(items, number) {
for (var i = 0; i < number; i++) {
jQuery('#' + 'roblib-search-content-solr-site').append(items.pop());
}
if (items.length > 0) }
{
jQuery('#roblib-search-solr-site-more').empty().append('<a id="see_more_result">see ' + items.length + ' more results</a>');
jQuery('#see_more_result').click(function() {
items = showMoreItems(items, number);
}); });
} }
else
{
jQuery('#roblib-search-solr-site-more').empty().append('no more results');
}
return items;
} }

29
targets/solr_site/roblib_search_solr_site.module

@ -85,7 +85,7 @@ function roblib_search_solr_site_theme() {
'roblib_search_solr_site' => array( 'roblib_search_solr_site' => array(
'path' => $path . '/theme', 'path' => $path . '/theme',
'file' => $file, 'file' => $file,
'template' => 'roblib-search-solr_site', 'template' => 'roblib-search-solr-site',
'variables' => array('results' => NULL), 'variables' => array('results' => NULL),
) )
); );
@ -110,7 +110,7 @@ function roblib_search_solr_site_block_view($delta = '') {
// The subject is displayed at the top of the block. Note that it // The subject is displayed at the top of the block. Note that it
// should be passed through t() for translation. The title configured // should be passed through t() for translation. The title configured
// for the block using Drupal UI supercedes this one. // for the block using Drupal UI supercedes this one.
$block['subject'] = t('Site Results'); $block['subject'] = t('Library Website');
// The content of the block is typically generated by calling a custom // The content of the block is typically generated by calling a custom
// function. // function.
$block['content'] = theme('roblib_search_solr_site', array('results' => NULL)); $block['content'] = theme('roblib_search_solr_site', array('results' => NULL));
@ -132,21 +132,28 @@ function roblib_search_solr_site_ajax($query) {
* json * json
*/ */
function roblib_search_solr_site_get_results($query) { function roblib_search_solr_site_get_results($query) {
$url = roblib_search_solr_site_get_search_url($query);
$results = drupal_http_request($url);
if($results->code != '200'){
return "";
}
return $results->data;
}
/**
* @param $query
* @return string
*/
function roblib_search_solr_site_get_search_url($query){
$solr_url = variable_get('roblib_search_solr_site_url', 'http://localhost:8983/solr'); $solr_url = variable_get('roblib_search_solr_site_url', 'http://localhost:8983/solr');
//$query = $solr_url . '/select?wt=json&q=test page';
$num_results = variable_get('roblib_search_solr_site_num_results', '5'); $num_results = variable_get('roblib_search_solr_site_num_results', '5');
$data = array( $data = array(
'wt' => 'json', 'wt' => 'json',
'q' => $query, 'q' => $query ,
'rows' => $num_results,
); );
$url = url($solr_url . '/select', array('query' => $data)); $url = url($solr_url . '/select', array('query' => $data));
$results = drupal_http_request($url); return $url;
if($results->code != '200'){
return "";
}
$temp = substr($results->data, 1);
//$out = '{"rows":"' . $num_results . '",' . $results->data;
return $results->data;
} }
/** /**

4
targets/solr_site/theme/roblib-search-solr_site.tpl.php → targets/solr_site/theme/roblib-search-solr-site.tpl.php

@ -16,9 +16,7 @@
* @see template_preprocess_roblib_search_wrapper() * @see template_preprocess_roblib_search_wrapper()
*/ */
?> ?>
<div class ="roblib-search-more" id="roblib-search-solr-site-more">Search all Results</div>
<div class ="roblib-search-content solr-site" id="roblib-search-content-solr-site"> <div class ="roblib-search-content solr-site" id="roblib-search-content-solr-site">
<img src="<?php print (empty($spinner_path) ? ' ' : $spinner_path); ?>"/> <img src="<?php print (empty($spinner_path) ? ' ' : $spinner_path); ?>"/>
</div> </div>
<div class ="roblib-search-more" id="roblib-search-solr-site-more">Search all Results</div>

4
targets/solr_site/theme/theme.inc

@ -19,6 +19,8 @@ function roblib_search_solr_site_preprocess_roblib_search_solr_site(&$variables)
$variables['spinner_path'] = $spinner_path; $variables['spinner_path'] = $spinner_path;
$search_url = $base_url .'/roblib_search/solr_site/ajax/'.urlencode($query); $search_url = $base_url .'/roblib_search/solr_site/ajax/'.urlencode($query);
drupal_add_js(drupal_get_path('module', 'roblib_search_solr_site') . '/js/solr_site_results.js'); drupal_add_js(drupal_get_path('module', 'roblib_search_solr_site') . '/js/solr_site_results.js');
drupal_add_js(array('roblib_search_solr_site' => array('search_url' => $search_url)), array('type' => 'setting')); drupal_add_js(array('roblib_search_solr_site' => array('search_url' => $search_url,
'search_query' => urlencode($query))), array('type' => 'setting'));
} }
?> ?>

Loading…
Cancel
Save