Skip to content

Instantly share code, notes, and snippets.

@mjordan
mjordan / test_pids.php
Created July 24, 2017 19:20
Script to test Fedora Repository PIDs
<?php
$pids = array(
'foo:%0F',
'foo-:123',
'.foo.:123',
'foo.:-.~_',
'foo.:-___',
);
<?xml version="1.0"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:doc="http://www.lyncode.com/xoai" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:oreatom="http://www.openarchives.org/ore/atom/" xmlns:ore="http://www.openarchives.org/ore/terms/" schemaLocation="http://www.w3.org/2005/Atom http://www.kbcafe.com/rss/atom.xsd.xml">
<atom:id>http://hdl.handle.net/10294/3386/ore.xml</atom:id>
<atom:link rel="alternate" href="http://hdl.handle.net/10294/3386"/>
<atom:link rel="http://www.openarchives.org/ore/terms/describes" href="http://hdl.handle.net/10294/3386/ore.xml"/>
<atom:link type="application/atom+xml" rel="self" href="http://hdl.handle.net/10294/3386/ore.xml#atom"/>
<atom:published>2011-07-11T02:23:04Z</atom:published>
<atom:updated>2011-07-11T02:23:04Z</atom:updated>
<atom:source>
<atom:generator>oURspace</atom:generator>
<?php
/**
* Script to export entries from the SFU Editorial Cartoons database
* for importing into Islandora.
*/
$db['user'] = '****';
$db['password'] = '****';
$db['name'] = 'Cartoons';
<?php
/**
* Implements hook_islandora_datastream_alter().
*/
function mjtest_islandora_datastream_alter(AbstractObject $object, AbstractDatastream $datastream, array &$context) {
$now = date("Y-m-d H:i:s");
$dc = <<<EOX
<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
<dc:title>Testing at $now</dc:title>
@mjordan
mjordan / islandora_derivative_factory
Last active July 14, 2016 07:22
Writing out derivatives for use in another Islandora
This simple module:
<?php
/**
* Implements hook_islandora_object_ingested().
*/
function islandora_derivative_factory_islandora_object_ingested(AbstractObject $object) {
$base_output_dir = '/tmp/derivativefactoryoutput';
foreach ($object as $ds) {
(function ($) {
$(document).ready(function() {
$("dd").each(function() {
// Value of the <dd> cannot contain only puncutation or be empty.
if ($.trim($(this).text()).match(/^[.,::\-]$/g) || $.trim($(this).html()) == '') {
// Hide the <dd>.
$(this).hide();
// Hide the corresponding <dt>.
$(this).prev().hide();
}
$map = array(
'jpeg' => 'islandora:sp_basic_image',
'jpe' => 'islandora:sp_basic_image',
'jpeg' => 'islandora:sp_basic_image',
'gif' => 'islandora:sp_basic_image',
'png' => 'islandora:sp_basic_image',
'tif' => 'islandora:sp_large_image_cmodel',
'tiff' => 'islandora:sp_large_image_cmodel',
'jp2' => 'islandora:sp_large_image_cmodel',
'pdf' => 'islandora:sp_pdf',
We can make this file beautiful and searchable if this error is corrected: Illegal quoting in line 2.
CartoonID,CartoonKey,Cartoonist,Date,CartoonText,PhysicalDescription,PublicationInfo,DisplayNotes,MsCCode,MD5Checksum,Subjects,Subjects_TGM1,Subjects_LCSH,File
7904,2-1999-08-25,|Harrop, Graham|,1999-08-25,|"Will I be Premier?" "I'm afraid not Mr. Wilson ... not a chance." "Finished with the costume Mr. Dosanjh?"|,|18.9 cm x 17.6 cm|,|Vancouver Sun|,,|MsC 25.HAR.71.7|,cfd527c036e3bd67212921e689a94963,|Dosanjh, Ujjal;Wilson, Gordon F.D., 1948 -;Fortune telling|,|Politics & government -- British Columbia|,|Premiers (Canada)|,2-1999-08-25.tif
8292,3-1988-01-13,|Krieger, Bob|,1988-01-13,|"Watch out! He's got a stone!!!"|,|16.3 cm x 19.1 cm|,|The Province|,,|MsC 25.KRI.14.14|,a2f34dbf981359b3476b7b89a6641e7f,|Stones;Ten commandments;Israel. Army|,,,3-1988-01-13.tif
6971,3-2004-03-29,|Krieger, Bob|,2004-03-29,|Finally acting like a premier|,|20.5 cm x 24.7 cm|,|The Provine|,,|MsC 25.KRI.6.67|,c27fa07e838ec02146e738c9a9478585,|MacPhail, Joy|,Feet;Mouths,|Premiers (Canada)|,3-2004-03-29.tif
6688,5-9115-00-00,|Murphy,
@mjordan
mjordan / gist:9f5813dd99281ddb2ff7
Created January 9, 2016 17:37
Sample MIK metadata manipulator
<?php
namespace mik\metadatamanipulators;
use \Monolog\Logger;
/**
* MJTest - Example metadata manipulator.
*
* The mappings file must contain a row that adds the following
* element to your MODS:
$view = new view();
$view->name = 'test_solr';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'islandora_solr';
$view->human_name = 'test solr';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */