Skip to content

Instantly share code, notes, and snippets.

@mjordan
mjordan / gist:92148a8523a7c2c7dad6d220eebd3251
Created February 15, 2024 17:22
View to create a collection-level map in Islandora
uuid: 71067709-d9ee-4c56-9d83-632911e4e5b2
langcode: en
status: true
dependencies:
config:
- core.entity_view_mode.node.teaser
- field.storage.node.field_coordinates
- filter.format.plain_text
- node.type.islandora_object
module:
import sys
import re
date = sys.argv[1].strip()
# nnnX?
if re.match('^[1-2[1-9]{1,2}X\?', date):
print(f"OK - {date} matches /nnnX?/.")
# nXXX?
elif re.match('^[1-2]XXX\?', date):
<?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>
import time
def validate_date(date):
"""
Validates a yyyy-mm-dd date string.
- **date**: the date string to validate.
"""
try:
is_valid = time.strptime(date, '%Y-%m-%d')
except ValueError:
@mjordan
mjordan / merge_csvs.py
Last active September 30, 2021 20:53
Marge CSVs
# Script to merge a secondary CSV file into a main CSV file. Columns not in a file are
# added to the merged file as empty CSV cells. Records are joined on a required 'Nid' column.
# Column headers should be unique in both files (other than 'Nid'); if they are present
# in both files, both instances will be added to the merged file.
import csv
main_filename = 'input/main.csv'
secondary_filename = 'input/secondary.csv'
output_filename = 'input/test_output.csv'
@mjordan
mjordan / get_all_mods_fields_in_solr.sh
Created January 16, 2020 00:50
Shell script to get all the Solr fields indexed from MODS elements
#!/bin/bash
SOLR_HOST='http://192.168.50.111:8080'
SOLR_URL="$SOLR_HOST/solr/select?q=*:*&wt=csv&rows=0&facet&fl=mods_*"
curl -s -o mods_elements.txt "$SOLR_URL"
sed 's/,/\n/g' mods_elements.txt > mods_elements_one_per_line.txt
sed 's/_mlt$// ; s/_ms$// ; s/_mt$// ; s/_s$// ; s/_ss$// ; s/_t$// ; s/_all$// ; s/_dt$// ; s/_mdt$//' mods_elements_one_per_line.txt > mods_elements_one_per_line.txt.pruned
sort mods_elements_one_per_line.txt.pruned > mods_elements_one_per_line.txt.pruned.sorted
uniq mods_elements_one_per_line.txt.pruned.sorted > mods_elements.txt
| Title (Goal) | Render complex objects that are not paged or images |
| --- | --- |
| Primary Actor | Site Builder |
| Scope | Islandora Site Architecture |
| Level | Medium? |
| Story | As a site builder, I want to ... |
@mjordan
mjordan / gist:8672407
Created January 28, 2014 17:41
PREMIS with FITS in <objectCharacteristicsExtension>
<?xml version="1.0" encoding="utf-8"?>
<premis xmlns="info:lc/xmlns/premis-v2" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="info:lc/xmlns/premis-v2 http://www.loc.gov/standards/premis/v2/premis.xsd" version="2.2">
<!--PREMIS data for Islandora object islandora:220. Contains object entries for each datastream
in an Islandora object, and event entries documenting all fixity checks performed on
versions of those datastreams. Note that a datastream version that has never had a fixity
check performed on it will not be linked to any fixity check events.-->
<!--'Internal' eventIdentifierType values are comprised of Fedora datasteam ID plus ':' plus Fedora Audit Record ID.-->
<object xsi:type="file">
<objectIdentifier>
<objectIdentifierType>Fedora Commons datastreamVersion ID</objectIdentifierType>
@mjordan
mjordan / gist:6368d0d07047528d85b2b1dd7a997b10
Created November 22, 2018 16:44
Using JWT for internal REST calls in Drupal 8.
// Construct Authorization header using jwt token.
$container = \Drupal::getContainer();
$jwt = $container->get('jwt.authentication.jwt');
$auth = 'Bearer ' . $jwt->generateToken();
$client = \Drupal::httpClient();
$options = [
'auth' => [],
'headers' => ['Authorization' => $auth],
'form_params' => []
];
@mjordan
mjordan / AppFixtures.php
Created January 25, 2019 15:02
Symfony 4 fixtures generator for Riprap
<?php
// src/DataFixtures/AppFixtures.php
namespace App\DataFixtures;
use App\Entity\FixityCheckEvent;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\Persistence\ObjectManager;
use Ramsey\Uuid\Uuid;
class AppFixtures extends Fixture