Skip to content

Instantly share code, notes, and snippets.

langcode: en
status: true
dependencies: { }
id: workbench_user
label: Workbench user
weight: 10
is_admin: null
permissions:
access administration pages
"""
Script to generate tiles for an image viewed using the Mirador Viewer. Also takes a screenshot
of the page for quick QA of results. Input is a file containing a list of node IDs for nodes with
an Islandora Model of Page or Image.
This script should be run on a batch of Page or Image nodes prior to running generate_paged_content_iiif_manifests.py
since IIIF Presentation manifest generation is much more reliable if the constituent images have already been pre-cached.
Note: IIIF Presentation manifests for nodes with a Paged Content model are pre-cached by a different script,
generate_paged_content_iiif_manifests.py.
@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' => []
];