A client side convenience library for PRIMO v4.6 and better. This is a work in progress. This might not work for you at all but if more people use it the better it will get. If you want a feature, have a comment, found a bug or just want to talk ping me.
See the releases for downloads and release notes
You can inject the script into your results page, for testing. This works best using Firefox. Open the JavaScript console and paste the next line. You will not be able to use the more advanced functions but it should give you an idea of what it can be used for.
$.getScript('https://raw.githubusercontent.com/mehmetc/jQuery.PRIMO/master/dist/jqprimo/jquery.PRIMO.js')
Browsers are getting stricter with every release. If you get strange errors just copy the complete source into your console.
- Copy the contents of the dist/* directory to fe_web
scp dist/* primo@my_primo.example.com:/exlibris/primo/p4_1/ng/primo/home/system/tomcat/search/webapps/primo_library?libweb
- Add jquery.PRIMO.min.js to static_htmls/footer.html or to a custom tile and add the snippet below to it
<script type='text/javascript' src='/primo_library/libweb/jqprimo/jquery.PRIMO.min.js'></script>
If you do not have shell access to your server you can use "File Uploader"(Primo Home > Primo Utilities > File Uploader) on the backend but you will not be able to upload the helper files. I have no solution for this besides asking ExLibris to upload these.
The helper files will add extra functionality to the library like looking up records id in a deduped record, get the original record, ...
If you would want to compile jquery.PRIMO.js then follow these steps
#Examples
jQuery.PRIMO.version;
jQuery.PRIMO.reload();
jQuery.PRIMO.session.sessionId;
jQuery.PRIMO.session.reload();
jQuery.PRIMO.session.user.id;
jQuery.PRIMO.session.user.name;
jQuery.PRIMO.session.user.email;
jQuery.PRIMO.session.user.isLoggedIn();
jQuery.PRIMO.session.user.isOnCampus();
jQuery.PRIMO.session.user.ranking.categories;
jQuery.PRIMO.session.user.ranking.prefer_new;
jQuery.PRIMO.session.view.code;
jQuery.PRIMO.session.view.institution.name;
jQuery.PRIMO.session.view.institution.code;
jQuery.PRIMO.session.view.interfaceLanguage;
jQuery.PRIMO.session.view.isFullDisplay();
The file:
jqprimo/helpers/frontend_id
should contain a marker for the frontend where jQuery.PRIMO is installed. For example: staging or test or 1 or ...
Then you can get the frontend id this can be handy when you are debugging
jQuery.PRIMO.session.view.frontEndID;
####Get IP address as seen on PRIMO
jQuery.PRIMO.session.ip.address;
####Get institution name by IP
jQuery.PRIMO.session.ip.institution.name;
####Get institution code by IP
jQuery.PRIMO.session.ip.institution.code;
If you want this to work you need to add the borrower info url to the helper file. Please look at jqprimo/helpers/remote_session_date_helper.jsp for the instructions.
jQuery.PRIMO.session.pds.url;
jQuery.PRIMO.session.pds.handle;
This uses General Configuration -> Installation -> PDS_URL to build the PDS access url and it returns /bor/bor-info.
jQuery.PRIMO.session.pds.borInfo;
jQuery.PRIMO.records.length;
jQuery.PRIMO.records[5].id;
jQuery.PRIMO.records[5].index;
jQuery.PRIMO.records[5].title;
jQuery.PRIMO.records[5].openUrl;
jQuery.PRIMO.records[5].materialType();
jQuery.PRIMO.records[5].getIt1();
jQuery.PRIMO.records[5].isRemoteRecord();
jQuery.PRIMO.records[5].isOnEShelf();
jQuery.PRIMO.records[5].getPNX('text');
jQuery.PRIMO.records[5].getPNX('json');
jQuery.PRIMO.records[5].getPNX();
jQuery.PRIMO.records[0].getData().display.type;
jQuery.PRIMO.records[5].isDedupedRecord();
jQuery.PRIMO.records[2].getDedupedRecordIds();
jQuery.PRIMO.records.each(
function(){
if (this.getData().display.type === 'journal') {
this.css('background-color', 'yellow')
}
}
);
jQuery.PRIMO.records.each(
function(index, record){
var view_online = record.tabs.getByName('ViewOnline');
try{
view_online.find('a').attr('target', '_blank').attr('href', record.getIt1);
} catch (e) {
console.log('Error setting url');
}
}
);
jQuery.PRIMO.records.each(
function(index, record){
record.tabs.addTab('Hello World',{
state:'enabled',
click:function(event, tab, record, options){
if (tab.isOpen()){
tab.close();
} else {
tab.open('Hello from tab', {reload:true});
}
}
});
}
);
jQuery.PRIMO.records.each(
function(index, record){
record.tabs.addTab('Share', {tooltip:'Share', state:'enabled', click:function (event, tab, record, options) {
if (tab.isOpen()) {
tab.close();
} else {
var tab_content = "";
var details_url = $(record.tabs).filter('.EXLDetailsTab').find('a').attr('href');
tab_content += "<div style='overflow:auto;height:100%;padding:20px;'>";
tab_content += ' <div class="share_options_import"></div>';
tab_content += '</div>';
$.get(details_url,
function(data){
var html = $($.parseHTML(data)).find('.EXLTabHeaderButtonSendToList li');
var permalink = html.filter('.EXLButtonSendToPermalink').length == 0 ? false : true;
var citation = html.filter('.EXLButtonSendToCitation').length == 0 ? false : true;
if (permalink) {
html.filter('.EXLButtonSendToPermalink').find('a').attr('onclick', html.filter('.EXLButtonSendToPermalink').find('a').attr('onclick').replace(/-1/g, record.index));
}
if (citation){
html.filter('.EXLButtonSendToCitation').find('a').attr('onclick', html.filter('.EXLButtonSendToCitation').find('a').attr('onclick').replace(/-1/g, record.index));
}
$('.share_options_import').empty().append(html);
eshelfUpdate(record.children(), record.isOnEShelf());
}, 'html'
);
details_url = 'http://' + location.hostname + location.pathname.substr(0, location.pathname.lastIndexOf('/')) + '/display.do?tabs=detailsTab&ct=display&fn=search&doc=' + record.id + "&recIds=" + record.id;
tab.open(tab_content, {reload:false, url:details_url});
}
}
});
}
);
jQuery.PRIMO.records[0].tabs.addTab('KULeuven', {state:'enabled',
url:'http://www.kuleuven.be',
click:function(event, tab, record, options) {
if (tab.isOpen()) {
tab.close();
} else {
tab.open('<iframe src="'+options.url+'"/>', {reload: true});
}
}
});
jQuery.PRIMO.records[1].tabs.addTab('url', {state:'enabled',
url:'http://www.kuleuven.be', url_target: '_blank',
click: null
});
jQuery.PRIMO.records[5].tabs.getNames();
jQuery.PRIMO.records[5].tabs.getEnabled();
jQuery.PRIMO.records[5].tabs.getByName('Details');
jQuery.PRIMO.records[0].tabs.getByName('Details').find('a').click();
jQuery.PRIMO.records[5].tabs.getByName('Details').find('a').attr('href');
jQuery.PRIMO.records[5].tabs[0].name;
jQuery.PRIMO.records[5].tabs[0].index;
jQuery.PRIMO.records[5].tabs[1].container;
jQuery.PRIMO.records[5].tabs[4].isOpen();
This wraps the default XServices API this means that 'WS and XS IP' restrictions apply TODO: move to server
var result = jQuery.PRIMO.search.by_query('any,contains,water');
jQuery.PRIMO.query.count;
jQuery.PRIMO.query.page;
jQuery.PRIMO.query.step;
should be equal to
jQuery.PRIMO.records.length;
jQuery.PRIMO.query.type;
jQuery.PRIMO.query.tab;
jQuery.PRIMO.query.sorted_by;
This will return an Object or an Array depending on the query.type
jQuery.PRIMO.query.query;
jQuery.PRIMO.query.scope;
jQuery.PRIMO.query.facets;
jQuery.PRIMO.query.isDeeplinkSearch();
- Fork the project.
- Create a new branch to implement your bugfixes or features
- Commit and push until you are happy with your contribution.
- Send a pull request.
MIT (c) 2015 KULeuven/LIBIS written by Mehmet Celik