Skip to content

Instantly share code, notes, and snippets.

'''
Script to generate tiles for an image viewed using the Mirador Viewer. Also takes
a screenshot of the page for quick QA of results.
Usage: python iiif_tile_warmer.py https://digital-ds.lib.sfu.ca/node/235 10 # Where 10 is the number of seconds to wait before closig the window; default is 5.
python iiif_tile_warmer.py tiles.txt 10 # Where tiles.txt is a file containing a list of URLs, one per line.
'''
import sys
@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):
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'
| 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 / 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
@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
@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 / gist:f26ade27b1a9d0d8a9cc5280d4adf759
Last active May 26, 2018 22:12
Testing Checksum Checker

Checking for verification cycle completion

  1. At the very top of function islandora_checksum_checker_send_check_complete_message() , add the line dd("Cycle complete");.
  2. Run checksum checker via either the drupal cron or the drush script enough times that all objects are checked. The number of times you will need to run checksum checker will depend on how many objects are in your repo and how many checksum checker is configured to check per cron run.
  3. Checksum checker will report that the verification cycle has completed. Tail /tmp/drupal_debug.txt to see the message confirmig this.

Checking for a checksum mismatch

  1. In the function islandora_checksum_checker_send_mismatch_notice(), add dd($mismatches, 'Mismatches'); just after the line of code $mismatches = variable_get('islandora_checksum_checker_mismatches', array());.