EPrints Technical Mailing List Archive
See the EPrints wiki for instructions on how to join this mailing list and related information.
Message: #08769
< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First
Re: [EP-tech] Antwort: Re: Citation Style Language (CSL) & EPrints?
- To: eprints-tech@ecs.soton.ac.uk
- Subject: Re: [EP-tech] Antwort: Re: Citation Style Language (CSL) & EPrints?
- From: Yuri <yurj@alfa.it>
- Date: Tue, 12 Oct 2021 15:24:58 +0200
Here the files
I think removing JS files is probably a sensible precaution, as they could possibly be executed through web browsers and possibly do something nasty. Replacing with a .txt extension should allow you to send such attachments to the list, as it will likely load in a text editor and therefore not be executed.
On 12/10/2021 13:36, Martin Braendle via Eprints-tech wrote:
CAUTION: This e-mail originated outside the University of Southampton.Thank you Yuri,
looks interesting. Unfortunately, ep-tech removed the citation.js you sent.
Kind regards,
Martin
"Yuri via Eprints-tech" ---12/10/2021 14:23:11---CAUTION: This e-mail originated outside the University of Southampton. This is what I did. It is not
Von: "Yuri via Eprints-tech" <eprints-tech@ecs.soton.ac.uk>
An: eprints-tech@ecs.soton.ac.uk
Datum: 12/10/2021 14:23
Betreff: Re: [EP-tech] Citation Style Language (CSL) & EPrints?
Gesendet von: <eprints-tech-bounces@ecs.soton.ac.uk>
CAUTION: This e-mail originated outside the University of Southampton.This is what I did. It is not a plugin but a eprint_render part + a _javascript_ which uses https://citation.crosscite.org/ api and need a DOI. The script has been modified from the one in the https://citation.crosscite.org/ page.
Maybe not exacly what asked for...
Il 12/10/21 13:48, Martin Braendle via Eprints-tech ha scritto:
CAUTION: This e-mail originated outside the University of Southampton.
Hi,
warming up a very old question from a former colleague:
https://eprints-tech.ecs.soton.ac.narkive.com/3pmd0NPr/ep-tech-citation-style-language-csl-eprints
Has anyone written a plugin that would allow to choose and render a CSL style when rendering an eprint, e.g. using citeproc.js as renderer?
For example, PKP's Open Journal System has a plugin that does this (it uses citeproc.php).
https://github.com/pkp/citationStyleLanguage
You can see it in action here:
https://ejhc.org/article/view/2584 (under "How To Cite")
Kind regards,
Martin
--
Dr. Martin Brändle
Zentrale Informatik
Universität Zürich
Stampfenbachstr. 73
CH-8006 Zürich
mail: martin.braendle@uzh.ch
phone: +41 44 63 56705
fax: +41 44 63 54505
http://www.zi.uzh.ch
*** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
*** Archive: http://www.eprints.org/tech.php/
*** EPrints community wiki: http://wiki.eprints.org/[attachment "Unsupported File Types Alert.txt" deleted by Martin Brändle/at/UZH] *** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
*** Archive: http://www.eprints.org/tech.php/
*** EPrints community wiki: http://wiki.eprints.org/
*** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech *** Archive: http://www.eprints.org/tech.php/ *** EPrints community wiki: http://wiki.eprints.org/
*** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech *** Archive: http://www.eprints.org/tech.php/ *** EPrints community wiki: http://wiki.eprints.org/
=== insert in eprint_render ===
# Citation block
my $div_citation = $repository->make_element('div', class => "rd_citation_right");
$div_citation->appendChild($repository->make_element('script', src => '//code.jquery.com/jquery-1.12.4.js'));
$div_citation->appendChild($repository->make_element('script', src => '//code.jquery.com/ui/1.12.0/jquery-ui.js'));
$div_citation->appendChild($repository->make_element('script', src => '/javascript/citation.js'));
#my $cittable =
# $repository->make_element(
# "table",
# border => "0",
# cellpadding => "2",
# width => "100%"
# );
my $citfrag = $repository->make_doc_fragment;
my $citheading = $repository->make_element('h2', class => "file_list_heading", style=>"margin-bottom: 1em;");
$citheading->appendChild($repository->make_text("Cite As"));
$citfrag->appendChild($citheading);
#$citfrag->appendChild($cittable );
my $doitocite = $eprint->render_value("doi");
my $citeform = $repository->make_element("form", action=>"",id=>"form", style=>"font-size: small;");
#my $labelcite=$repository->make_element("label", for=>"doi");
#$labelcite->appendChild($repository->make_text("This item DOI:"));
my $inputdoi=$repository->make_element("input", id=>"doi", type=>"hidden", required=>"true", class=>"form-control", value=>$doitocite);
#my $pdoi=$repository->make_element("p", class=>"help-block");
#$pdoi->appendChild($repository->make_text($doitocite));
my $labelformat = $repository->make_element("label", for=>"styles");
$labelformat->appendChild($repository->make_text("Select Formatting Style:"));
my $selectstyle = $repository->make_element("select", id=>"styles", class=>"form-control");
my $phelp = $repository->make_element("p", class=>"help-block");
$phelp->appendChild($repository->make_text("Begin typing (e.g. Chicago or IEEE.) or use the drop down menu."));
my $labellocales = $repository->make_element("label", for=>"locales");
$labellocales->appendChild($repository->make_text("Select Language and Country:"));
my $selectlocales = $repository->make_element("select", id=>"locales", class=>"form-control");
my $phelpselect = $repository->make_element("p", class=>"help-block");
$phelpselect->appendChild($repository->make_text("Begin typing (e.g. en-GB for English, Great Britain) or use the drop down menu."));
my $inputformat = $repository->make_element("input", type=>"submit", value=>"Format", class=>"btn-lg btn-default center-block", style=>"margin-bottom: 1em;");
my $citationdiv = $repository->make_element("div", id=>"citation");
#$citeform->appendChild($labelcite);
$citeform->appendChild($inputdoi);
#$citeform->appendChild($pdoi);
$citeform->appendChild($labelformat);
$citeform->appendChild($selectstyle);
$citeform->appendChild($phelp);
$citeform->appendChild($labellocales);
$citeform->appendChild($selectlocales);
$citeform->appendChild($phelpselect);
$citeform->appendChild($inputformat);
$citfrag->appendChild($citeform);
$citfrag->appendChild($citationdiv);
$div_citation->appendChild($citfrag);
$fragments{citation} = $div_citation;
/*
* This javascript file will be loaded after all the system files.
* (so other javascript functions will already be loaded)
*
* Javascript files are loaded in alphabetic order, hence the "90"
* in the filename to force it to load after the other files!
*
* To totally replace a system js file, create a file of the same
* name in this directory. eg. 50_preview.js
*
*/
var $j = jQuery.noConflict();
function init() {
$j("#form").submit(submit);
$j("#styles").loadSelect("https://citation.crosscite.org/styles/").val("apa");
$j("#locales").loadSelect("https://citation.crosscite.org/locales").val("it-IT");
$j("#styles").combobox();
$j("#locales").combobox();
// (new URL(window.location.href)).searchParams.forEach((x, y) =>
// document.getElementById(y).value = x);
new URL(window.location.href).searchParams.forEach(function (x, y) {
return document.getElementById(y).value = x;
});
// TODO: there is an issue in order to get plain-text right-of-thebox in github https://github.com/zenorocha/clipboard.js/issues/299
//$j("#citation_row").hide();
$j("#copy_citation").hide();
}
$j.fn.loadSelect = function(url) {
var select = $j(this);
$j.getAsync(url, function(data) {
data.sort();
var options = arrayToSelectOptions(data);
select.html(options);
});
return select;
};
$j.getAsync = function(url, success) {
$j.ajax({
url : url,
async : false,
success: success
});
};
function arrayToSelectOptions(array) {
var options = $j.map(array, function(elem) {
return '<option value="' + elem + '">' + elem + '</option>';
});
return options.join("");
}
function submit() {
$j("#citation_row").hide();
var doi = $j("#doi").val().trim();
$j.ajax({
url : "https://citation.crosscite.org/format",
data : {
doi : doi,
style : $j("#styles").val(),
lang : $j("#locales").val()
},
dataType : "text",
success : function(data) {
$j("#citation").text(data);
$j("#citation_row").show();
},
error : function(jqXHR, textStatus, errorThrown) {
$j("#citation_row").hide();
alert(jqXHR.responseText);
}
});
return false;
}
$j( function() {
$j.widget( "custom.combobox", {
_create: function() {
this.wrapper = $j( "<span>" )
.addClass( "custom-combobox" )
.insertAfter( this.element );
this.element.hide();
this._createAutocomplete();
this._createShowAllButton();
},
_createAutocomplete: function() {
var selected = this.element.children( ":selected" ),
value = selected.val() ? selected.text() : "";
this.input = $j( "<input>" )
.appendTo( this.wrapper )
.val( value )
.attr( "title", "" )
.addClass( "custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left" )
.autocomplete({
delay: 0,
minLength: 0,
source: $j.proxy( this, "_source" )
})
.tooltip({
classes: {
"ui-tooltip": "ui-state-highlight"
}
});
this._on( this.input, {
autocompleteselect: function( event, ui ) {
ui.item.option.selected = true;
this._trigger( "select", event, {
item: ui.item.option
});
},
autocompletechange: "_removeIfInvalid"
});
},
_createShowAllButton: function() {
var input = this.input,
wasOpen = false;
$j( "<a>" )
.attr( "tabIndex", -1 )
.attr( "title", "Show All Items" )
.tooltip()
.appendTo( this.wrapper )
.button({
icons: {
primary: "ui-icon-triangle-1-s"
},
text: false
})
.removeClass( "ui-corner-all" )
.addClass( "custom-combobox-toggle ui-corner-right" )
.on( "mousedown", function() {
wasOpen = input.autocomplete( "widget" ).is( ":visible" );
})
.on( "click", function() {
input.trigger( "focus" );
// Close if already visible
if ( wasOpen ) {
return;
}
// Pass empty string as value to search for, displaying all results
input.autocomplete( "search", "" );
});
},
_source: function( request, response ) {
var matcher = new RegExp( $j.ui.autocomplete.escapeRegex(request.term), "i" );
response( this.element.children( "option" ).map(function() {
var text = $j( this ).text();
if ( this.value && ( !request.term || matcher.test(text) ) )
return {
label: text,
value: text,
option: this
};
}) );
},
_removeIfInvalid: function( event, ui ) {
// Selected an item, nothing to do
if ( ui.item ) {
return;
}
// Search for a match (case-insensitive)
var value = this.input.val(),
valueLowerCase = value.toLowerCase(),
valid = false;
this.element.children( "option" ).each(function() {
if ( $j( this ).text().toLowerCase() === valueLowerCase ) {
this.selected = valid = true;
return false;
}
});
// Found a match, nothing to do
if ( valid ) {
return;
}
// Remove invalid value
this.input
.val( "" )
.attr( "title", value + " didn't match any item" )
.tooltip( "open" );
this.element.val( "" );
this._delay(function() {
this.input.tooltip( "close" ).attr( "title", "" );
}, 2500 );
this.input.autocomplete( "instance" ).term = "";
},
_destroy: function() {
this.wrapper.remove();
this.element.show();
}
});
$j( "#combobox" ).combobox();
$j( "#toggle" ).on( "click", function() {
$j( "#combobox" ).toggle();
});
} );
$j(document).ready(init);
- Follow-Ups:
- Re: [EP-tech] Antwort: Re: Citation Style Language (CSL) & EPrints?
- From: Yuri <yurj@alfa.it>
- Re: [EP-tech] Antwort: Re: Citation Style Language (CSL) & EPrints?
- References:
- [EP-tech] Citation Style Language (CSL) & EPrints?
- From: <martin.braendle@uzh.ch>
- Re: [EP-tech] Citation Style Language (CSL) & EPrints?
- From: Yuri <yurj@alfa.it>
- [EP-tech] Antwort: Re: Citation Style Language (CSL) & EPrints?
- From: <martin.braendle@uzh.ch>
- Re: [EP-tech] Antwort: Re: Citation Style Language (CSL) & EPrints?
- From: David R Newman <drn@ecs.soton.ac.uk>
- Re: [EP-tech] Antwort: Re: Citation Style Language (CSL) & EPrints?
- From: Yuri <yurj@alfa.it>
- [EP-tech] Citation Style Language (CSL) & EPrints?
- Prev by Date: Re: [EP-tech] Antwort: Re: Citation Style Language (CSL) & EPrints?
- Next by Date: Re: [EP-tech] Export formats - v3.3.16+
- Previous by thread: [EP-tech] EPrints/CRIS
- Next by thread: [EP-tech] DOI handling in orcid_support_advance
- Index(es):
