Skip to content

Instantly share code, notes, and snippets.

@jesusbagpuss
jesusbagpuss / z_rewrite_old_urls.pl
Created February 8, 2017 13:54
Example rewrite trigger to map old path to new one
# This is an example of how to use the URL Rewrite trigger.
# In this case, specifically an archive that was initially configured with
# a base path (url) of '/usr/share/eprints3/data' rather than '' (no default path).
#
# This file should be saved to:
# <eprints_root>/archives/<archiveid>/cfg/cfg.d/z_rewrite_old_urls.pl
#
# This trigger will rewrite any requests that match:
# <host>/usr/share/eprints3/data/<something>
# to:
@jesusbagpuss
jesusbagpuss / z_wrro_epscript.pl
Created March 3, 2017 15:52
Additions to EPrints::Script::Compiled for WRRO
# Open block
{
# Write into EPrints::Script::Compiled
package EPrints::Script::Compiled;
use strict;
# Render event dates when used in citation
# This will not affect them when exported/in the database.
@jesusbagpuss
jesusbagpuss / check_plugin
Last active March 22, 2017 15:01
Test whether an EPrints Plugin is OK
#!/usr/bin/perl -w
######################################################################
## 1. save file as <eprints_root>/bin/local/check_plugin
## 2. make it executable
## 3. run it: <eprints_root>/bin/local/check_plugin ARCHIVEID PLUGIN
## PLUGIN should be e.g. Export::OAI_DC or Screen::FirstTool
######################################################################
use FindBin;
use lib "$FindBin::Bin/../../perl_lib";
@jesusbagpuss
jesusbagpuss / LocalDC.pm
Created October 13, 2016 13:24
Add data to OAI-PMH export
# THIS IS UNTESTED
# try it on a test server first!
#
# Save file to: ~/archives/ARCHIVEID/cfg/plugins/EPrints/Plugin/Export/LocalDC.pm
# then run:
# > bin/epadmin test ARCHIVEID
# if there are no errors, add the file below and run it again.
# if there are still no errors, restart apache and test the OAI-PMH interface.
package EPrints::Plugin::Export::LocalDC;
@jesusbagpuss
jesusbagpuss / EPrintsMetaFieldName.pm
Created June 1, 2017 08:37
EPrints 3.3.10 search fixes. Save into [eprints_root]/lib/plugins/EPrints/Plugin/Core/
package EPrints::Plugin::Core::EPrintsMetaFieldName;
use strict;
our @ISA = qw/EPrints::Plugin/;
package EPrints::MetaField::Name;
use strict;
no warnings 'redefine';
@jesusbagpuss
jesusbagpuss / OAI_DC_ORCID.pm
Last active August 14, 2017 22:20
Include ORCIDs (stored in an creator->orcid field) in OAI output format - with info:eu-repo/dai/mx/orcid/ prefix
=head1 NAME
EPrints::Plugin::Export::OAI_DC_ORCID
=cut
package EPrints::Plugin::Export::OAI_DC_ORCID;
use EPrints::Plugin::Export::OAI_DC;
@jesusbagpuss
jesusbagpuss / example.pl
Last active March 6, 2018 14:19
EPrints: render reference test in paragraphs
{
name => 'referencetext',
type => 'longtext',
input_rows => 15,
render_value => sub {
my( $session , $field , $value ) = @_; # see: https://wiki.eprints.org/w/Category:EPrints_Metadata_Fields#Rendering_Properties
my $frag = $session->make_doc_fragment;
# split value on a double-new line (possibly with other whitespace in between
@jesusbagpuss
jesusbagpuss / z_custom_epscript.pl
Created August 6, 2018 10:05
EPrints - render event dates in a human-friendly way (when they are stored in a database in 'YYYY-MM-DD - YYYY-MM-DD' format)
# Render event dates when used in citation
# This will not affect them when exported/in the database.
{
# Write into EPrints::Script::Compiled
package EPrints::Script::Compiled;
use strict;
sub run_custom_human_event_dates
{
@jesusbagpuss
jesusbagpuss / Symplectic_RepoProcess_MergeManager.pm
Created August 15, 2018 11:31
Additiopnal code to deal with document pos when merging EPrints.
# Based on EPrints::DataObj::Document::clone
# NB Code duplication with Symplectic::RepoProcess::MergeManager
#
# Cloning documents can result in:
# - two documents with the same 'pos' field - and therefore sharing the same folder
# - 'spaces' in the document structure (e.g. pos=1 and pos=3, but no pos=2)
# this isn't what is needed. The code below manages these scenarios.
# EPrints' default behaviour is to remove the 'pos' during a clone *only* when the doc is being cloned to the same parent.
sub clone_document
{
@jesusbagpuss
jesusbagpuss / crosswalk_snippet.xsl
Created January 22, 2019 11:36
Symplectic RT1 Exceptions mapping (Elements v5.1 and above)
<!-- ##################### oa-policy-exceptions ##################### -->
<!--
<pubs:oa-policy-exception>
<pubs:type>Access1</pubs:type>
<pubs:type-description>The output depends on the reproduction of
third party content for which open access rights could not be
granted (either within the specified timescales, or at all).</pubs:type-description>
<pubs:comment>This is a test exception</pubs:comment>
</pubs:oa-policy-exception>