Skip to content

Commit

Permalink
configurable view for eds
Browse files Browse the repository at this point in the history
  • Loading branch information
ThoWagen committed Jan 21, 2025
1 parent 41b5a3c commit 7793706
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 29 deletions.
28 changes: 19 additions & 9 deletions config/vufind/EDS.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ common_limiters = FC,FT,RV
; values. Order of values here controls display order in the form.
;advanced_limiters = RV,FC,FT
common_expanders = fulltext
default_view = brief
; This setting controls the default view for search results; the selected option
; should be one of the options present in the [Views] section below.
default_view = list_brief

; These are the default recommendations modules to use when no specific setting
; are found in the [TopRecommendations], [SideRecommendations] or
Expand Down Expand Up @@ -267,6 +269,14 @@ SU = Subject
; through the current result set from within the record view.
next_prev_navigation = false

; This section defines the view options available on standard search results.
; If only one view is required, set default_view under [General] above, and
; leave this section commented out.
[Views]
list_title = "Title View"
list_brief = "Brief View"
list_detailed = "Detailed View"

; This section represents the EBSCO EDS API Account credentials.
; If using IP Authentication, then the user_name and password should remain blank
; and ip_auth should be set to true.
Expand All @@ -281,10 +291,10 @@ profile = "PROFILE"
organization_id = "VuFind from MyUniversity"

; If you have been provided with an EDS API Key, please provide these below.
; API keys are used to monitor access to EDS API, isolating traffic by customer and use-case.
; This isolation allows EBSCO to manage performance for specific keys (use cases). Should a request be throttled,
; the gateway will respond with an HTTP 429. Existing implementations may start using API keys at any time.
; EBSCO will require API keys for all customers at one point, but deadlines have not been established.
; API keys are used to monitor access to EDS API, isolating traffic by customer and use-case.
; This isolation allows EBSCO to manage performance for specific keys (use cases). Should a request be throttled,
; the gateway will respond with an HTTP 429. Existing implementations may start using API keys at any time.
; EBSCO will require API keys for all customers at one point, but deadlines have not been established.
; Customers may have more than one API key for separate client applications or use-cases accessing EDS API.
; Note: API keys do not replace EDS API’s authentication or session tokens.

Expand Down Expand Up @@ -445,11 +455,11 @@ DetailPageFormat = 'Long'
;ShortAuthorLimit = 3

[AdditionalHeaders]
; Due to the nature of EDS API integrations EBSCO's web application firewall (WAF) does not have sufficient
; data to distinguish bots from users. By sending some end-user data to EDS API, EBSCO's WAF can make more
; informed decisions regarding bots.
; Due to the nature of EDS API integrations EBSCO's web application firewall (WAF) does not have sufficient
; data to distinguish bots from users. By sending some end-user data to EDS API, EBSCO's WAF can make more
; informed decisions regarding bots.
; This is important to guarantee accurate COUNTER 5 usage reports. The Counter Code of Practice 5.1 stipulates:
; "Activity generated by internet robots and crawlers MUST be excluded from all COUNTER usage reports."
; "Activity generated by internet robots and crawlers MUST be excluded from all COUNTER usage reports."
; See https://cop5.countermetrics.org/en/5.1/07-processing/08-internet-robots-and-crawlers.html

; If you are already protecting your site from bots, e.g. through your own WAF, you might not wish to enable this
Expand Down
27 changes: 27 additions & 0 deletions module/VuFind/src/VuFind/Config/Upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ public function run()
$this->upgradeSearches();
$this->upgradeSitemap();
$this->upgradeSms();
$this->upgradeEDS();
$this->upgradeSummon();
$this->upgradePrimo();

Expand Down Expand Up @@ -1039,6 +1040,32 @@ protected function upgradeReserves()
$this->saveModifiedConfig('reserves.ini');
}

/**
* Upgrade EDS.ini.
*
* @throws FileAccessException
* @return void
*/
protected function upgradeEDS()
{
// we want to retain the old installation's search and facet settings
// exactly as-is
$groups = [
'Facets', 'FacetsTop', 'Basic_Searches', 'Advanced_Searches', 'Sorting',
];
$this->applyOldSettings('EDS.ini', $groups);

// Fix autocomplete settings in case they use the old style:
$newConfig = & $this->newConfigs['EDS.ini']['General'];

if (!str_contains($newConfig['default_view'], '_')) {
$newConfig['default_view'] = 'list_' . $newConfig['default_view'];
}

// save the file
$this->saveModifiedConfig('EDS.ini');
}

/**
* Upgrade Summon.ini.
*
Expand Down
2 changes: 1 addition & 1 deletion module/VuFind/src/VuFind/Search/EDS/AbstractEDSParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ protected function filterRequiresFacetOperator($field)
*/
public function getView()
{
$viewArr = explode('|', $this->view ?? '');
$viewArr = explode('_', $this->view ?? '');
return $viewArr[0];
}

Expand Down
19 changes: 5 additions & 14 deletions module/VuFind/src/VuFind/Search/EDS/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
class Options extends \VuFind\Search\Base\Options
{
use \VuFind\Config\Feature\ExplodeSettingTrait;
use \VuFind\Search\Options\ViewOptionsTrait;

/**
* Default limit option
Expand Down Expand Up @@ -168,13 +169,6 @@ public function __construct(
$this->searchIni = $this->facetsIni = 'EDS';
$this->searchSettings = $configLoader->get($this->searchIni);
parent::__construct($configLoader);
// 2015-06-30 RF - Changed to unlimited
//$this->resultLimit = 100;
$this->viewOptions = [
'list|title' => 'Title View',
'list|brief' => 'Brief View',
'list|detailed' => 'Detailed View',
];
// If we get the API info as a callback, defer until it's actually needed to
// avoid calling the API:
if (is_callable($apiInfo)) {
Expand Down Expand Up @@ -318,7 +312,7 @@ public function getDefaultMode()
*/
public function getEdsView()
{
$viewArr = explode('|', $this->getApiProperty('defaultView'));
$viewArr = explode('_', $this->getApiProperty('defaultView'));
return (1 < count($viewArr)) ? $viewArr[1] : $this->defaultView;
}

Expand Down Expand Up @@ -492,10 +486,7 @@ protected function setOptionsFromConfig()
}

// View preferences
if (isset($this->searchSettings->General->default_view)) {
$this->defaultView
= 'list|' . $this->searchSettings->General->default_view;
}
$this->initViewOptions($this->searchSettings);

// Load list view for result (controls AJAX embedding vs. linking)
if (isset($this->searchSettings->List->view)) {
Expand Down Expand Up @@ -724,7 +715,7 @@ protected function populateViewSettings()
$this->defaultLimit ??= $settings['ResultsPerPage'] ?? 20;

// default view
$this->defaultView ??= 'list|' . ($settings['ResultListView'] ?? 'brief');
$this->defaultView ??= 'list_' . ($settings['ResultListView'] ?? 'brief');
}

/**
Expand Down Expand Up @@ -796,7 +787,7 @@ public function getSearchScreenExpanders()
*/
public function getDefaultView()
{
$viewArr = explode('|', $this->getApiProperty('defaultView'));
$viewArr = explode('_', $this->getApiProperty('defaultView'));
return $viewArr[0];
}

Expand Down
2 changes: 1 addition & 1 deletion module/VuFind/src/VuFind/Search/EDS/Params.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public function getBackendParameters()
*/
public function getEdsView()
{
$viewArr = explode('|', $this->view ?? '');
$viewArr = explode('_', $this->view ?? '');
return (1 < count($viewArr)) ? $viewArr[1] : $this->options->getEdsView();
}

Expand Down
10 changes: 6 additions & 4 deletions module/VuFind/src/VuFind/Search/Options/ViewOptionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ public function initViewOptions(?Config $searchSettings)
$this->defaultView = $searchSettings->General->default_view;
}
// Load view preferences (or defaults if none in .ini file):
if (isset($searchSettings->Views)) {
foreach ($searchSettings->Views as $key => $value) {
$this->viewOptions[$key] = $value;
}
$viewOptions = [];
foreach ($searchSettings->Views ?? [] as $key => $value) {
$viewOptions[$key] = $value;
}
if (!empty($viewOptions)) {
$this->viewOptions = $viewOptions;
} elseif (isset($searchSettings->General->default_view)) {
$this->viewOptions = [$this->defaultView => $this->defaultView];
} else {
Expand Down

0 comments on commit 7793706

Please sign in to comment.