2024-08-27 21:48:20 -05:00
{
"translatorID" : "214505fc-fa92-4b35-b323-5f12a4b157cb" ,
"translatorType" : 4 ,
"label" : "Queensland State Archives" ,
"creator" : "Tim Sherratt (tim@timsherratt.au)" ,
"target" : "^https?://www\\.archivessearch\\.qld\\.gov\\.au/(items|search)" ,
"minVersion" : "5.0" ,
"maxVersion" : null ,
"priority" : 100 ,
"inRepository" : true ,
"browserSupport" : "gcsibv" ,
2024-09-03 21:01:54 -05:00
"lastUpdated" : "2024-09-03 15:30:00"
2024-08-27 21:48:20 -05:00
}
/ *
* * * * * BEGIN LICENSE BLOCK * * * * *
Copyright © 2024 Tim Sherratt
This file is part of Zotero .
Zotero is free software : you can redistribute it and / or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation , either version 3 of the License , or
( at your option ) any later version .
Zotero is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU Affero General Public License for more details .
You should have received a copy of the GNU Affero General Public License
along with Zotero . If not , see < http : //www.gnu.org/licenses/>.
* * * * * END LICENSE BLOCK * * * * *
* /
async function detectWeb ( doc , url ) {
if ( /\/search\?/ . test ( url ) ) {
if ( getSearchResults ( doc , true ) ) {
return "multiple" ;
}
else {
Zotero . monitorDOMChanges ( doc . body ) ;
return false ;
}
}
else if ( /items\/ITM[0-9]+/ . test ( url ) ) {
return "manuscript" ;
}
return false ;
}
function getSearchResults ( doc , checkOnly ) {
let items = { } ;
let found = false ;
let rows = doc . querySelectorAll ( "div.result-left-pane a" ) ;
for ( let row of rows ) {
let href = row . href ;
href = /\/items\// . test ( href ) ? href : null ;
let title = row . innerText ;
if ( ! href || ! title ) continue ;
if ( checkOnly ) return true ;
found = true ;
items [ href ] = title ;
}
return found ? items : false ;
}
async function doWeb ( doc , url ) {
if ( await detectWeb ( doc , url ) == 'multiple' ) {
let items = await Zotero . selectItems ( getSearchResults ( doc , false ) ) ;
if ( items ) {
for ( let url of Object . keys ( items ) ) {
await scrape ( url ) ;
}
}
}
else {
await scrape ( url ) ;
}
}
async function scrape ( url ) {
let id = url . match ( /items\/(ITM[0-9-]+)/ ) [ 1 ] ;
let apiURL = "https://www.archivessearch.qld.gov.au/api/fetch?qsa_id=" + id + "&type=archival_object" ;
let data = await requestJSON ( apiURL ) ;
let item = new Zotero . Item ( "manuscript" ) ;
item . title = data . title ;
if ( "record_type" in data . subject _terms ) {
2024-09-03 21:01:54 -05:00
let recordTypes = data . subject _terms . record _type . map (
term => term . term
) ;
item . type = recordTypes . join ( "; " ) ;
2024-08-27 21:48:20 -05:00
}
item . archive = "Queensland State Archives" ;
item . archiveLocation = data . qsa _id _prefixed ;
item . url = url ;
item . rights = data . copyright _status ;
let startDate = data . dates [ 0 ] . begin . split ( "-" ) [ 0 ] ;
let endDate = data . dates [ 0 ] . end . split ( "-" ) [ 0 ] ;
// If there's a date range use 'issued', otherwise use 'date'
if ( startDate == endDate ) {
item . date = startDate ;
}
else {
item . extra = ( item . extra ? item . extra + "\n" : "" ) + "Issued: " + startDate + "/" + endDate ;
}
// Include a series reference (archive collection)
item . extra = ( item . extra ? item . extra + "\n" : "" ) + "Archive Collection: " + data . resource . qsa _id _prefixed + ", " + data . resource . display _string ;
// Add creating agencies
let agencies = data . creating _agency || [ ] ;
for ( let i = 0 ; i < agencies . length ; i ++ ) {
item . creators . push ( {
lastName : agencies [ i ] . _resolved . qsa _id _prefixed + ", " + agencies [ i ] . _resolved . display _string ,
creatorType : "contributor" ,
fieldMode : 1
} ) ;
}
// Add digital representation
2024-09-03 21:01:54 -05:00
for ( let image of data . digital _representations ) {
2024-08-27 21:48:20 -05:00
let imageID = image . qsa _id _prefixed ;
let mimeType , imageTitle ;
if ( image . file _type == "JPEG" ) {
mimeType = "image/jpeg" ;
imageTitle = "Image " + imageID ;
}
else if ( image . file _type == "PDF" ) {
mimeType = "application/pdf" ;
imageTitle = "PDF " + imageID ;
}
2024-09-03 21:01:54 -05:00
item . attachments . push ( {
2024-08-27 21:48:20 -05:00
title : imageTitle ,
url : "https://www.archivessearch.qld.gov.au/api/download_file/" + imageID ,
mimeType : mimeType ,
snapshot : true
2024-09-03 21:01:54 -05:00
} ) ;
2024-08-27 21:48:20 -05:00
}
item . complete ( ) ;
}
/** BEGIN TEST CASES **/
var testCases = [
{
"type" : "web" ,
"url" : "https://www.archivessearch.qld.gov.au/items/ITM3872594" ,
"items" : [
{
"itemType" : "manuscript" ,
"title" : "Regina v Thomas Thompson (or Thomas Norman or James Thompson) . Extract from from Briefs, depositions and associated papers in criminal cases heard, No. 15 [WARNING: CONTENT MAY CAUSE DISTRESS]" ,
"creators" : [
{
"lastName" : "A2120, Circuit Court, Rockhampton" ,
"creatorType" : "contributor" ,
"fieldMode" : 1
}
] ,
"date" : "1865" ,
"archive" : "Queensland State Archives" ,
"archiveLocation" : "ITM3872594" ,
"extra" : "Archive Collection: S10976, Briefs, Depositions and Associated Papers in Criminal Cases Heard - Supreme Court, Central District, Rockhampton" ,
"libraryCatalog" : "Queensland State Archives" ,
"rights" : "Copyright State of Queensland" ,
"shortTitle" : "Regina v Thomas Thompson (or Thomas Norman or James Thompson) . Extract from from Briefs, depositions and associated papers in criminal cases heard, No. 15 [WARNING" ,
"url" : "https://www.archivessearch.qld.gov.au/items/ITM3872594" ,
"attachments" : [
{
"title" : "PDF DR173618" ,
"mimeType" : "application/pdf" ,
"snapshot" : true
}
] ,
"tags" : [ ] ,
"notes" : [ ] ,
"seeAlso" : [ ]
}
]
} ,
{
"type" : "web" ,
"url" : "https://www.archivessearch.qld.gov.au/items/ITM3871900" ,
"items" : [
{
"itemType" : "manuscript" ,
"title" : "GABBERT, MARY CARMELIA" ,
"creators" : [
{
"lastName" : "A191, Supreme Court, Southern District, Brisbane" ,
"creatorType" : "contributor" ,
"fieldMode" : 1
}
] ,
"date" : "2018" ,
"archive" : "Queensland State Archives" ,
"archiveLocation" : "ITM3871900" ,
"extra" : "Archive Collection: S6339, Originating Applications - Probate and Letters of Administration (Supreme Court, Brisbane)" ,
"libraryCatalog" : "Queensland State Archives" ,
"manuscriptType" : "Ecclesiastical (will) file" ,
"rights" : "Copyright State of Queensland" ,
"url" : "https://www.archivessearch.qld.gov.au/items/ITM3871900" ,
"attachments" : [ ] ,
"tags" : [ ] ,
"notes" : [ ] ,
"seeAlso" : [ ]
}
]
} ,
{
"type" : "web" ,
"url" : "https://www.archivessearch.qld.gov.au/items/ITM1523915" ,
"items" : [
{
"itemType" : "manuscript" ,
"title" : "Town map - Cheepie" ,
"creators" : [
{
"lastName" : "A18, Lands Department" ,
"creatorType" : "contributor" ,
"fieldMode" : 1
}
] ,
"date" : "1954" ,
"archive" : "Queensland State Archives" ,
"archiveLocation" : "ITM1523915" ,
"extra" : "Archive Collection: S19466, South West Region Maps" ,
"libraryCatalog" : "Queensland State Archives" ,
"manuscriptType" : "Map" ,
"url" : "https://www.archivessearch.qld.gov.au/items/ITM1523915" ,
"attachments" : [
{
"title" : "Image DR173204" ,
"mimeType" : "image/jpeg" ,
"snapshot" : true
}
] ,
"tags" : [ ] ,
"notes" : [ ] ,
"seeAlso" : [ ]
}
]
} ,
{
"type" : "web" ,
"url" : "https://www.archivessearch.qld.gov.au/search?f[]=keywords&has_digital=false&op[]=AND&open=false&q[]=wragge&sort=relevance&type[]=archival_object" ,
2024-09-03 21:01:54 -05:00
"defer" : true ,
2024-08-27 21:48:20 -05:00
"items" : "multiple"
2024-09-03 21:01:54 -05:00
} ,
{
"type" : "web" ,
"url" : "https://www.archivessearch.qld.gov.au/items/ITM276520" ,
"items" : [
{
"itemType" : "manuscript" ,
"title" : "Criminal files - Supreme Court, Northern District, Townsville" ,
"creators" : [
{
"lastName" : "A267, Supreme Court, Northern District, Townsville" ,
"creatorType" : "contributor" ,
"fieldMode" : 1
}
] ,
"archive" : "Queensland State Archives" ,
"archiveLocation" : "ITM276520" ,
"extra" : "Issued: 1875/1876\nArchive Collection: S7833, Criminal Files - Supreme Court, Northern District, Townsville" ,
"libraryCatalog" : "Queensland State Archives" ,
"manuscriptType" : "Depositions and indictments" ,
"rights" : "Copyright State of Queensland" ,
"url" : "https://www.archivessearch.qld.gov.au/items/ITM276520" ,
"attachments" : [
{
"title" : "PDF DR87978" ,
"mimeType" : "application/pdf" ,
"snapshot" : true
} ,
{
"title" : "PDF DR87979" ,
"mimeType" : "application/pdf" ,
"snapshot" : true
} ,
{
"title" : "PDF DR87980" ,
"mimeType" : "application/pdf" ,
"snapshot" : true
} ,
{
"title" : "PDF DR87981" ,
"mimeType" : "application/pdf" ,
"snapshot" : true
} ,
{
"title" : "PDF DR87982" ,
"mimeType" : "application/pdf" ,
"snapshot" : true
}
] ,
"tags" : [ ] ,
"notes" : [ ] ,
"seeAlso" : [ ]
}
]
2024-08-27 21:48:20 -05:00
}
]
/** END TEST CASES **/