From c774a256dddbe0d95bf7e31be026f01ababd2fda Mon Sep 17 00:00:00 2001 From: Hector Castro Date: Mon, 11 Apr 2016 15:49:29 -0600 Subject: [PATCH] [ISGNED-OFF] Bug 16243: Add reference manager software (Mendeley and EasyBib) to OPAC Mendeley provides a mechanism for export bib records to a personal account in a free reference manager and academic social network (similar to Zotero) EasyBib Generate citations in MLA, APA & Chicago formats for bibliographies To test: - Apply patches - Run perl installer/data/mysql/updatedatabase.pl - On master, search for the syspref OpacReferenceManager - Enable the two options - Do a search for books - Notice about the new option 'Export to Reference Manager' in search results - Create an account in Mendeley (Is free) - Click in new option and notice that you can save bib references in Mendeley - Click in new option Cite on EasyBib, you will see the records selected in EasyBib - Repeat for items saved in cart and patron list. - Go to record detail page test in Normal view, Marc view and ISBD view NOTE: Fixed according with QA comment Patch rebase due JS translation mistake Sponsored-by: Universidad de El Salvador Signed-off-by: Bernardo Gonzalez Kriegel Works following test plan. No errors --- .../bug_16243-add_reference_managers.sql | 1 + installer/data/mysql/sysprefs.sql | 3 +- .../prog/en/modules/admin/preferences/opac.pref | 6 ++ .../bootstrap/en/includes/opac-bottom.inc | 3 + .../bootstrap/en/includes/opac-detail-sidebar.inc | 13 +++ .../en/includes/opac-reference-manager.inc | 106 +++++++++++++++++++ .../bootstrap/en/modules/opac-ISBDdetail.tt | 6 +- .../bootstrap/en/modules/opac-MARCdetail.tt | 3 + .../opac-tmpl/bootstrap/en/modules/opac-basket.tt | 12 ++- .../opac-tmpl/bootstrap/en/modules/opac-detail.tt | 3 + .../opac-tmpl/bootstrap/en/modules/opac-results.tt | 11 +- .../opac-tmpl/bootstrap/en/modules/opac-shelves.tt | 10 ++ koha-tmpl/opac-tmpl/bootstrap/images/easybib.png | Bin 0 -> 415 bytes koha-tmpl/opac-tmpl/bootstrap/images/mendeley.png | Bin 0 -> 572 bytes .../opac-tmpl/bootstrap/js/reference_manager.js | 114 +++++++++++++++++++++ koha-tmpl/opac-tmpl/bootstrap/less/opac.less | 32 +++++- opac/opac-downloadcart.pl | 1 + 17 files changed, 317 insertions(+), 7 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_16243-add_reference_managers.sql create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-reference-manager.inc create mode 100644 koha-tmpl/opac-tmpl/bootstrap/images/easybib.png create mode 100644 koha-tmpl/opac-tmpl/bootstrap/images/mendeley.png create mode 100644 koha-tmpl/opac-tmpl/bootstrap/js/reference_manager.js diff --git a/installer/data/mysql/atomicupdate/bug_16243-add_reference_managers.sql b/installer/data/mysql/atomicupdate/bug_16243-add_reference_managers.sql new file mode 100644 index 0000000..1cc7be8 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_16243-add_reference_managers.sql @@ -0,0 +1 @@ +INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('OpacReferenceManager','mendeley,easybib','Select reference manager software options that should be available from OPAC detail, basket and list pages.','','multiple'); diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index e0fddea..8185c30 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -537,5 +537,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('XSLTDetailsDisplay','default','','Enable XSL stylesheet control over details page display on intranet','Free'), ('XSLTResultsDisplay','default','','Enable XSL stylesheet control over results page display on intranet','Free'), ('z3950AuthorAuthFields','701,702,700',NULL,'Define the MARC biblio fields for Personal Name Authorities to fill biblio.author','free'), -('z3950NormalizeAuthor','0','','If ON, Personal Name Authorities will replace authors in biblio.author','YesNo') +('z3950NormalizeAuthor','0','','If ON, Personal Name Authorities will replace authors in biblio.author','YesNo'), +('OpacReferenceManager','mendeley,easybib','','Select reference manager software options that should be available from OPAC detail, basket and list pages.','multiple') ; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index e1c72f0..3366e89 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -252,6 +252,12 @@ OPAC: type: htmlarea class: code - + - 'Select reference manager software options that should be available from OPAC detail, basket and list pages:' + - pref: OpacReferenceManager + multiple: + mendeley: Mendeley (Reference Manager Software) + easybib: EasyBib (Free Bibliography Generator) + - - pref: OpacAddMastheadLibraryPulldown choices: yes: Add diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc index 9d9af2c..516160d 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc @@ -149,6 +149,9 @@ $.widget.bridge('uitooltip', $.ui.tooltip); verify_images(); }); [% END %] + [% IF Koha.Preference( 'OpacReferenceManager' ) %] + var MSG_NO_EASYBIB_TITLE_SELECTED = _("Please select at least one title to cite on EasyBib"); + [% END %] //]]> diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc index d02b4c2..e4b6410 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-detail-sidebar.inc @@ -64,6 +64,11 @@ [% END %] +[% IF Koha.Preference( 'OpacReferenceManager' ) %] + [% PROCESS 'opac-reference-manager.inc' %] + [% INCLUDE menu_side_bar %] +[% END %] + [% IF ( OPACSearchForTitleIn ) %]
  • @@ -107,3 +112,11 @@
    + +[% IF Koha.Preference( 'OpacReferenceManager' ) %] + +
    + + +
    +[% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-reference-manager.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-reference-manager.inc new file mode 100644 index 0000000..d95df62 --- /dev/null +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-reference-manager.inc @@ -0,0 +1,106 @@ +[% BLOCK modal_main %] + + + +[% END %] + +[% BLOCK menu_basket %] + + [% SET reference_manager_options = Koha.Preference('OpacReferenceManager').split(',') %] + [% IF reference_manager_options.size %] + | +
  • + [% END %] + +[% END %] + +[% BLOCK menu_list_results %] + + [% SET reference_manager_options = Koha.Preference('OpacReferenceManager').split(',') %] + [% IF reference_manager_options.size %] + | + + [% END %] +[% END %] + +[% BLOCK menu_side_bar %] + [% SET reference_manager_options = Koha.Preference('OpacReferenceManager').split(',') %] + [% IF reference_manager_options.size %] +
  • +
    +
    +
  • + [% END %] +[% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-ISBDdetail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-ISBDdetail.tt index 108b9bf..32cafac 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-ISBDdetail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-ISBDdetail.tt @@ -35,4 +35,8 @@ [% INCLUDE 'opac-bottom.inc' %] -[% BLOCK jsinclude %][% END %] +[% BLOCK jsinclude %] +[% IF Koha.Preference( 'OpacReferenceManager' ) %] + +[% END %] +[% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-MARCdetail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-MARCdetail.tt index 1f0680e..1954783 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-MARCdetail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-MARCdetail.tt @@ -207,4 +207,7 @@ $(document).ready(function(){ [% END %] //]]> +[% IF Koha.Preference( 'OpacReferenceManager' ) %] + +[% END %] [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt index fa7e496..b6d68bd 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-basket.tt @@ -29,6 +29,12 @@ Print Empty and close Hide window + +[% IF Koha.Preference( 'OpacReferenceManager' ) %] + [% PROCESS 'opac-reference-manager.inc' %] + [% INCLUDE menu_basket %] +[% END %] +
    @@ -263,7 +269,7 @@ [% END %] - [% BIBLIO_RESULT.title |html %][% IF ( BIBLIO_RESULT.subtitle ) %] [% FOREACH subtitl IN BIBLIO_RESULT.subtitle %][% subtitl.subfield |html %][% END %][% END %] + [% BIBLIO_RESULT.title |html %][% IF ( BIBLIO_RESULT.subtitle ) %] [% FOREACH subtitl IN BIBLIO_RESULT.subtitle %][% subtitl.subfield |html %][% END %][% END %] [% IF ( TagsInputEnabled && loggedinusername ) %] @@ -426,4 +432,8 @@ //]]> [% END # / IF print_basket %] +[% IF Koha.Preference( 'OpacReferenceManager' ) %] + [% INCLUDE modal_main %] +[% END %] + [% END # / BLOCK jsinclude %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt index fe72d01..6d1ac99 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -1865,4 +1865,7 @@ //]]> [% END # / IF OPACPopupAuthorsSearch %] +[% IF Koha.Preference( 'OpacReferenceManager' ) %] + +[% END %] [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt index 7021638..afbd90e 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt @@ -160,7 +160,6 @@ [% END %] - [% IF ( TagsInputEnabled && loggedinusername ) %] @@ -176,6 +175,12 @@
    [% END %] + +[% IF Koha.Preference( 'OpacReferenceManager' ) %] + [% PROCESS 'opac-reference-manager.inc' %] + [% INCLUDE menu_list_results %] +[% END %] + @@ -970,4 +975,8 @@ $("input.newtag").on('keydown', function(e){ }); //]]> +[% IF Koha.Preference( 'OpacReferenceManager' ) %] + [% PROCESS 'opac-reference-manager.inc' %] + [% INCLUDE modal_main %] +[% END %] [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt index ab704ab..d994e6f 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt @@ -278,6 +278,12 @@ [% END %] + +[% IF Koha.Preference( 'OpacReferenceManager' ) %] + [% PROCESS 'opac-reference-manager.inc' %] + [% INCLUDE menu_list_results %] +[% END %] +
    @@ -962,4 +968,8 @@ function Check(f) { } //]]> +[% IF Koha.Preference( 'OpacReferenceManager' ) %] + [% PROCESS 'opac-reference-manager.inc' %] + [% INCLUDE modal_main %] +[% END %] [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/images/easybib.png b/koha-tmpl/opac-tmpl/bootstrap/images/easybib.png new file mode 100644 index 0000000000000000000000000000000000000000..c77e18b07259d60321c0b829e8fc7bc0ca49529b GIT binary patch literal 415 zcmV;Q0bu@#P)@!zhCVG|-DOr;p6&@lK0wqm*jv`M8FDf0s9EPaawT_GV5d;$Bk zb~1L8O%MVTBp8Fj&R&~Yka3oo0~fyg9XOo-y`4NxRTZFub zvh;7a#yD)*;{B`!bGSyoA>a%jJ9SPTCj)%Y>*>8-5hj7jgrZk}@P)p5OFM((w zQKKXff0ArkT7rWGp}1tVlbayA3NCKCw38w@iEY5aA%U)4N`}&{DU<1jRRxrw^ zyf+qYL&8vD9mqR#$ZPjtEc$v<-Ps*Vw6f`*p_n8+swJ>PYBkElyTaR_U#36rzxi77 z1bb1+SH*3T2^^X)sK~tFFg&WlirGpjoE_7Z*|p=A)9lYr>FcfImWQV(C(6w$C7QY( zt@DF2Wqxl!T1p8xG4M)5#+KdG>VKD4jh&Aq#OG%E^DlKkRWx_hOJ+VR6v>VItYBq+ ziK1uLRx)eL#PfwhgmhZL^wL6Ke$qZ_{C8YY3?%r~Bk<$KYeqW|0Cs;;lPu~iHZ zk|Y&fn-_mR`BR)yAQ2~jk=&T1z##mCag#bXj}iSEy@>$=JOxkKJvr-n(f4Ehy?t^< ztea}xN++Gu-?b0BEytw?Y1u9js+(IkN55dNYXnRyOsjZK+Fsj;nFVeu;?tfYNFm`d z-7vVX)K)codfrSZeBc=OT7`OAQN>3?Lp_(EneEa|1fIb=0R{jzbsz2X(L5pm0000< KMNUMnLSTZ|qXJg| literal 0 HcmV?d00001 diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/reference_manager.js b/koha-tmpl/opac-tmpl/bootstrap/js/reference_manager.js new file mode 100644 index 0000000..4cd6f68 --- /dev/null +++ b/koha-tmpl/opac-tmpl/bootstrap/js/reference_manager.js @@ -0,0 +1,114 @@ +//Invoke for Mendeley Reference Manager + +function getMendeleyModal(){ + document.getElementsByTagName('body')[0].appendChild(document.createElement('script')).setAttribute('src','https://www.mendeley.com/minified/bookmarklet.js'); +} + +$(document).ready(function(){ + $( "#mendeley_modal" ).click(function( event ){ + event.preventDefault(); + getMendeleyModal(); + return false; + }); +}); + +//EasyBib for opac results and patron lists + +$(document).ready(function(){ + + $("#CheckAllEasy").click(function(){ + $( ".easycheck" ).prop( "checked", true ); + }); + + $("#CheckNoneEasy").click(function(){ + $( ".easycheck" ).prop( "checked", false ); + }); + + $("#closeEasyBibModal, #cancelEasyBibModal").click(function(){ + $( ".easycheck" ).remove(); + $( ".label_reference_manager" ).remove(); + $( ".crRecord" ).remove(); + $( ".recordSeparator" ).remove(); + }); + + $("#easybib_modal").click(function(){ + $( ".cb" ).each(function( index ) { + var value = $( this ).val(); + var id = "biblionumber" + value; + var checkbox = ""; + $( checkbox ).appendTo( "#content" ); + $( ".title" ).each(function( i ) { + var title = $( this ).text(); + var href = $( this ).attr("href"); + var url = "/cgi-bin/koha/opac-detail.pl?biblionumber=" + value + "&query_desc="; + var urlShelves = "/cgi-bin/koha/opac-detail.pl?biblionumber=" + value; + if ( href == url || href == urlShelves ){ + var label = ""; + $( label ).appendTo( "#content" ); + $( "
    " ).appendTo( "#content" ); + $( "
    " ).appendTo( "#content" ); + } + }); + }); + }); + +//EasyBib for basket + + $("#easybib_modal_basket").click(function(){ + $( ".title" ).each(function( index ) { + var data_bibnum = $( this ).data( "bibnumber" ); + var id = "biblionumber" + data_bibnum; + var checkbox = ""; + $( checkbox ).appendTo( "#content" ); + var title = $( this ).text(); + var label = ""; + $( label ).appendTo( "#content" ); + $( "
    " ).appendTo( "#content" ); + $( "
    " ).appendTo( "#content" ); + }); + }); +}); + +$( "#easybib_form" ).submit(function( event ) { + event.preventDefault(); + var recordSelected = []; + var totalSeleceted; + $.each($(".easycheck:checked"), function(){ + recordSelected.push($(this).val()); + }); + if ( recordSelected.length > 0 ) { + totalSelected = recordSelected.join( "/" ); + $.ajax({ + url: "/cgi-bin/koha/opac-downloadcart.pl", + contentType: "application/x-www-form-urlencoded; charset=UTF-8", + type: "post", + data: { format: "ris", bib_list: totalSelected }, + success: function( data ){ + $( "#easybibTextArea" ).html(data); + $( "#ris_form" ).submit(); + $( "#closeEasyBibModal" ).click(); + } + }); + } else { + alert ( MSG_NO_EASYBIB_TITLE_SELECTED ); + } +}); + +//EasyBib for opac detail record and populate data +$(document).ready(function(){ + $( "#easybib_menu" ).click(function( event ){ + event.preventDefault(); + var bibNumber = $( this ).data( "bibnum" ); + $.ajax({ + url: "/cgi-bin/koha/opac-export.pl", + contentType: "application/x-www-form-urlencoded; charset=UTF-8", + type: "get", + data: { op: "export", bib: bibNumber, format: "ris" }, + success: function( data ){ + $( "#easybibTextArea" ).html(data); + $( "#ris_form" ).submit(); + } + }); + return false; + }); +}); diff --git a/koha-tmpl/opac-tmpl/bootstrap/less/opac.less b/koha-tmpl/opac-tmpl/bootstrap/less/opac.less index 6d20cd0..cc0823d 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/less/opac.less +++ b/koha-tmpl/opac-tmpl/bootstrap/less/opac.less @@ -1298,6 +1298,7 @@ div.rows { } #export, +#exportORM_menu, #moresearches_menu { li { padding : 0; @@ -1312,7 +1313,8 @@ div.rows { } #format, -#furthersearches { +#furthersearches, +#export_reference_manager { padding-left : 35px; } .highlight_controls { @@ -2487,18 +2489,42 @@ a.reviewlink:visited { font-size: 90%; } -#dc_fieldset { +#dc_fieldset, +#reference_manager_fieldset { border: 1px solid #dddddd; border-width: 1px; padding: 5px; border-radius: 10px } -.label_dc{ +.label_dc, +.label_reference_manager { display: inline; padding: 0px; margin: 0px; cursor: pointer; } +#mendeley_modal { + background-image: url("../images/mendeley.png"); + background-repeat: no-repeat; + text-decoration: none; + padding-left: 35px; + margin-left: 5px; +} + +#easybib_menu, +#easybib_modal, +#easybib_modal_basket { + background-image: url("../images/easybib.png"); + background-repeat: no-repeat; + text-decoration : none; + padding-left: 35px; + margin-left: 5px; +} + +#ris_form { + display: none; +} + @import "responsive.less"; diff --git a/opac/opac-downloadcart.pl b/opac/opac-downloadcart.pl index c5574e3..78ed9c1 100755 --- a/opac/opac-downloadcart.pl +++ b/opac/opac-downloadcart.pl @@ -90,6 +90,7 @@ if ($bib_list && $format) { print $query->header( -type => ($type) ? $type : 'application/octet-stream', -'Content-Transfer-Encoding' => 'binary', + -charset => 'utf-8', -attachment => ($extension) ? "cart.$format.$extension" : "cart.$format" ); print $output; -- 1.9.1