From d49efa654dce0e94693d56f76af5ca8160a8132c Mon Sep 17 00:00:00 2001 From: sharonhoward Date: Mon, 8 Oct 2018 16:29:21 +0100 Subject: [PATCH 1/8] Update Old Bailey Online.js Fixed function --- Old Bailey Online.js | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/Old Bailey Online.js b/Old Bailey Online.js index 105955f90cb..9ad3d086c0f 100644 --- a/Old Bailey Online.js +++ b/Old Bailey Online.js @@ -9,7 +9,7 @@ "inRepository": true, "translatorType": 4, "browserSupport": "gcsibv", - "lastUpdated": "2018-10-08 14:06:13" + "lastUpdated": "2018-10-08 14:15:17" } /* @@ -86,17 +86,18 @@ if (url.includes('browse.jsp') && ( url.includes('div=OA') || url.includes('nam var trialTitle = ZU.xpathText(doc, '//div[@class="sessionsPaper"]/div[@class="sessions-paper-main-title"]'); // updated @class name + newItem.url = url; var sessDate = ZU.xpathText(doc, '//div[@class="sessionsPaper"]/div[@class="sessions-paper-date"]'); // add session date, as the date is now in a gettable node newItem.date = ZU.strToISO(sessDate); - if (newItem.itemType == "case" && newItem.title && newItem.title == newItem.title.toUpperCase()) { + if (newItem.itemType == "case" && trialTitle ) { newItem.title = ZU.capitalizeTitle(trialTitle, true); // todo tidying this up - sometimes no name, messy punctuation } else if (newItem.itemType == "book") { newItem.title = trialTitle + " " + sessDate; - } + } var referenceNo = ZU.xpathText(doc, '//div[@class="ob-panel"][1]/table[@class="ob-info-table"][1]/tbody/tr[th[contains(text(),"Reference")]]/td').trim(); // changed fetching Reference number @@ -296,6 +297,40 @@ var testCases = [ "seeAlso": [] } ] + }, + { + "type": "web", + "url": "https://www.oldbaileyonline.org/browse.jsp?id=t16780828-12&div=t16780828-12&terms=hog#highlight", + "items": [ + { + "itemType": "case", + "caseName": ".", + "creators": [], + "dateDecided": "1678-08-28", + "docketNumber": "t16780828-12", + "extra": "Reference Number: t16780828-12", + "url": "https://www.oldbaileyonline.org/browse.jsp?id=t16780828-12&div=t16780828-12&terms=hog#highlight", + "attachments": [ + { + "title": "OBO Snapshot", + "mimeType": "text/html" + } + ], + "tags": [ + { + "tag": "Guilty" + }, + { + "tag": "Theft" + }, + { + "tag": "animal theft" + } + ], + "notes": [], + "seeAlso": [] + } + ] } ] /** END TEST CASES **/ From 04c34406088b300094847e67f3cb7e6000ce287c Mon Sep 17 00:00:00 2001 From: Sebastian Karcher Date: Mon, 8 Oct 2018 12:20:55 -0400 Subject: [PATCH 2/8] tweak The reason for that last bit in the conditional is to not impose title case where the title is already properly cased, i.e. not in all caps --- Old Bailey Online.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Old Bailey Online.js b/Old Bailey Online.js index 9ad3d086c0f..9c205100e3c 100644 --- a/Old Bailey Online.js +++ b/Old Bailey Online.js @@ -93,11 +93,11 @@ if (url.includes('browse.jsp') && ( url.includes('div=OA') || url.includes('nam newItem.date = ZU.strToISO(sessDate); - if (newItem.itemType == "case" && trialTitle ) { + if (newItem.itemType == "case" && trialTitle && trialTitle == trialTitle.toUpperCase()) { newItem.title = ZU.capitalizeTitle(trialTitle, true); // todo tidying this up - sometimes no name, messy punctuation } else if (newItem.itemType == "book") { newItem.title = trialTitle + " " + sessDate; - } + } var referenceNo = ZU.xpathText(doc, '//div[@class="ob-panel"][1]/table[@class="ob-info-table"][1]/tbody/tr[th[contains(text(),"Reference")]]/td').trim(); // changed fetching Reference number From 83a0da2eb338c522ba96e3791f0768b886560857 Mon Sep 17 00:00:00 2001 From: Sebastian Karcher Date: Fri, 12 Oct 2018 19:39:25 -0400 Subject: [PATCH 3/8] Clean up case titles --- Old Bailey Online.js | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/Old Bailey Online.js b/Old Bailey Online.js index 9c205100e3c..8549fd111ef 100644 --- a/Old Bailey Online.js +++ b/Old Bailey Online.js @@ -9,7 +9,7 @@ "inRepository": true, "translatorType": 4, "browserSupport": "gcsibv", - "lastUpdated": "2018-10-08 14:15:17" + "lastUpdated": "2018-10-12 23:37:03" } /* @@ -32,7 +32,7 @@ along with Zotero. If not, see . ***** END LICENSE BLOCK ***** -*/ +*/ // URLs // trial: div=t18000115-12 // session: name=16900430 @@ -46,7 +46,7 @@ function detectWeb(doc, url) { return "case"; } else if ( url.includes("search.jsp") && getSearchResults(doc, true)) { return "multiple"; - } + } } // to do: not trials... @@ -91,20 +91,25 @@ if (url.includes('browse.jsp') && ( url.includes('div=OA') || url.includes('nam var sessDate = ZU.xpathText(doc, '//div[@class="sessionsPaper"]/div[@class="sessions-paper-date"]'); // add session date, as the date is now in a gettable node - newItem.date = ZU.strToISO(sessDate); + newItem.date = ZU.strToISO(sessDate); if (newItem.itemType == "case" && trialTitle && trialTitle == trialTitle.toUpperCase()) { newItem.title = ZU.capitalizeTitle(trialTitle, true); // todo tidying this up - sometimes no name, messy punctuation } else if (newItem.itemType == "book") { newItem.title = trialTitle + " " + sessDate; } + + newItem.title = newItem.title.trim().replace(/[,.]+$/, ""); + if (!newItem.title) { + newItem.title = "[no title]"; + } var referenceNo = ZU.xpathText(doc, '//div[@class="ob-panel"][1]/table[@class="ob-info-table"][1]/tbody/tr[th[contains(text(),"Reference")]]/td').trim(); // changed fetching Reference number newItem.extra = "Reference Number: " + referenceNo; // putting the ref number in the Extra field had a particular function, was it for Voyant? or the defunct DMCI plugin? retain it at least for now (non trials will want it anyway) if (newItem.itemType == "case") { - newItem.docketNumber = referenceNo; + newItem.docketNumber = referenceNo; } if (newItem.itemType == "book") { @@ -144,7 +149,7 @@ if (newItem.itemType == "case") { // use print-friendly URLs for snapshots - var attachmentUrl = "https://www.oldbaileyonline.org/print.jsp?div=" + referenceNo; + var attachmentUrl = "https://www.oldbaileyonline.org/print.jsp?div=" + referenceNo; newItem.attachments.push({ url : attachmentUrl, title : "OBO Snapshot", mimeType : "text/html" }); newItem.complete(); @@ -166,7 +171,7 @@ function doWeb(doc, url) { } ZU.processDocuments(articles, scrape); }); - } else if (url.includes('browse.jsp') && ( url.includes('div=') || url.includes('name=') ) ) { + } else if (url.includes('browse.jsp') && ( url.includes('div=') || url.includes('name=') ) ) { scrape(doc, url); } } @@ -186,7 +191,7 @@ var testCases = [ "items": [ { "itemType": "case", - "caseName": "Peter Asterbawd, Andrew Forsman.", + "caseName": "Peter Asterbawd, Andrew Forsman", "creators": [], "dateDecided": "1800-01-15", "docketNumber": "t18000115-12", @@ -233,7 +238,7 @@ var testCases = [ "creators": [], "date": "1711-04-21", "extra": "Reference Number: OA17110421", - "libraryCatalog": "Old Bailey Online 201809", + "libraryCatalog": "Old Bailey Online", "place": "London", "url": "https://www.oldbaileyonline.org/browse.jsp?div=OA17110421", "attachments": [ @@ -258,7 +263,7 @@ var testCases = [ "creators": [], "date": "1711-04-21", "extra": "Reference Number: OA17110421", - "libraryCatalog": "Old Bailey Online 201809", + "libraryCatalog": "Old Bailey Online", "place": "London", "url": "https://www.oldbaileyonline.org/browse.jsp?name=OA17110421", "attachments": [ @@ -283,7 +288,7 @@ var testCases = [ "creators": [], "date": "1710-04-18", "extra": "Reference Number: 17100418", - "libraryCatalog": "Old Bailey Online 201809", + "libraryCatalog": "Old Bailey Online", "place": "London", "url": "https://www.oldbaileyonline.org/browse.jsp?name=17100418", "attachments": [ @@ -304,7 +309,7 @@ var testCases = [ "items": [ { "itemType": "case", - "caseName": ".", + "caseName": "[no title]", "creators": [], "dateDecided": "1678-08-28", "docketNumber": "t16780828-12", From 1966d9b1923da247f4812968e4c1df840ff82728 Mon Sep 17 00:00:00 2001 From: Sebastian Karcher Date: Sun, 11 Nov 2018 22:13:21 -0500 Subject: [PATCH 4/8] fix per review --- Old Bailey Online.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Old Bailey Online.js b/Old Bailey Online.js index 8549fd111ef..b2653b13812 100644 --- a/Old Bailey Online.js +++ b/Old Bailey Online.js @@ -93,8 +93,12 @@ if (url.includes('browse.jsp') && ( url.includes('div=OA') || url.includes('nam newItem.date = ZU.strToISO(sessDate); - if (newItem.itemType == "case" && trialTitle && trialTitle == trialTitle.toUpperCase()) { - newItem.title = ZU.capitalizeTitle(trialTitle, true); // todo tidying this up - sometimes no name, messy punctuation + if (newItem.itemType == "case" && trialTitle) { + if (trialTitle == trialTitle.toUpperCase()) { + newItem.title = ZU.capitalizeTitle(trialTitle, true); + } else { + newItem.title = trialTitle; + } } else if (newItem.itemType == "book") { newItem.title = trialTitle + " " + sessDate; } From 0931f9932539da92d680bc49c05b3cdb6f4dff0f Mon Sep 17 00:00:00 2001 From: sharonhoward Date: Sat, 31 Aug 2024 13:02:02 +0100 Subject: [PATCH 5/8] update Old Bailey Online translator to use new API --- Old Bailey Online.js | 335 ++++++++++++++----------------------------- 1 file changed, 109 insertions(+), 226 deletions(-) diff --git a/Old Bailey Online.js b/Old Bailey Online.js index b2653b13812..7fffffb75d9 100644 --- a/Old Bailey Online.js +++ b/Old Bailey Online.js @@ -1,7 +1,7 @@ { "translatorID": "b10bf941-12e9-4188-be04-f6357fa594a0", "label": "Old Bailey Online", - "creator": "Adam Crymble & Sharon Howard", + "creator": "Sharon Howard and Adam Crymble", "target": "^https?://www\\.oldbaileyonline\\.org/", "minVersion": "3.0", "maxVersion": "", @@ -9,13 +9,14 @@ "inRepository": true, "translatorType": 4, "browserSupport": "gcsibv", - "lastUpdated": "2018-10-12 23:37:03" + "lastUpdated": "2024-08-31 11:49:02" } /* ***** BEGIN LICENSE BLOCK ***** - Copyright © 2018 Sharon Howard + Copyright © 2024 Sharon Howard + This file is part of Zotero. Zotero is free software: you can redistribute it and/or modify @@ -33,225 +34,126 @@ ***** END LICENSE BLOCK ***** */ -// URLs -// trial: div=t18000115-12 -// session: name=16900430 -// OA: can use either name= or div= ! -// div/name excludes dir= pages in browse.jsp + +/* new URLs +// trial: /record/t18000115-12 +// OA: /record/OA16760705 +// api: https://www.dhi.ac.uk/api/data/oldbailey_record_single?idkey=t17210419-18 +*/ function detectWeb(doc, url) { - if (url.includes('browse.jsp') && ( url.includes('div=OA') || url.includes('name=') ) ) { - return "book"; - } else if (url.includes('browse.jsp') && ( url.includes('div=') ) ) { + if (url.includes('/record/t') ) { return "case"; - } else if ( url.includes("search.jsp") && getSearchResults(doc, true)) { - return "multiple"; + } else if (url.includes('record/OA') ) { + return "book"; +// } else if (url.includes('/search/') && getSearchResults(doc, true)) { +// return 'multiple'; +// } + // multiples skipped as search isn't working right now...? } + return false; } -// to do: not trials... -// div=f16740429-1 - front matter -// div=a16860520-1 - advertisements -// div=s16740717-1 - punishment summary -// div=o16751208-1 - supplementary material - - - +/* TODO function getSearchResults(doc, checkOnly) { - var items = {}; - var found = false; - var rows = ZU.xpath(doc, '//li/p[@class="srchtitle"]/a'); - for (var i=0; i Burglary, 15th January 1800", "creators": [], - "dateDecided": "1678-08-28", - "docketNumber": "t16780828-12", - "extra": "Reference Number: t16780828-12", - "url": "https://www.oldbaileyonline.org/browse.jsp?id=t16780828-12&div=t16780828-12&terms=hog#highlight", - "attachments": [ - { - "title": "OBO Snapshot", - "mimeType": "text/html" - } - ], + "dateDecided": "1800-01-15", + "docketNumber": "t18000115-12", + "extra": "Reference Number: t18000115-12", + "shortTitle": "Trial of Peter Asterbawd, Andrew Forsman", + "attachments": [], "tags": [ + { + "tag": "Burglary" + }, + { + "tag": "Fine" + }, { "tag": "Guilty" }, { - "tag": "Theft" + "tag": "House of correction" + }, + { + "tag": "Imprisonment" }, { - "tag": "animal theft" + "tag": "Lesser offence" + }, + { + "tag": "Miscellaneous Punishment" + }, + { + "tag": "Not guilty" + }, + { + "tag": "Theft" } ], "notes": [], From 1aa07745a6a5a7f0fefdee59d22d6274cde4a616 Mon Sep 17 00:00:00 2001 From: sharonhoward Date: Sat, 31 Aug 2024 14:33:20 +0100 Subject: [PATCH 6/8] Update Old Bailey Online.js linter issues. one remaining so this will presumably still fail but I don't understand why it's a problem. --- Old Bailey Online.js | 63 ++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/Old Bailey Online.js b/Old Bailey Online.js index 7fffffb75d9..a7d03984837 100644 --- a/Old Bailey Online.js +++ b/Old Bailey Online.js @@ -9,7 +9,7 @@ "inRepository": true, "translatorType": 4, "browserSupport": "gcsibv", - "lastUpdated": "2024-08-31 11:49:02" + "lastUpdated": "2024-08-31 13:32:20" } /* @@ -42,15 +42,16 @@ */ function detectWeb(doc, url) { - if (url.includes('/record/t') ) { + if (url.includes('/record/t')) { return "case"; - } else if (url.includes('record/OA') ) { + } + else if (url.includes('record/OA')) { return "book"; -// } else if (url.includes('/search/') && getSearchResults(doc, true)) { -// return 'multiple'; -// } - // multiples skipped as search isn't working right now...? + // } else if (url.includes('/search/') && getSearchResults(doc, true)) { + // return 'multiple'; + // } } + // multiples skipped as search isn't working right now...? return false; } @@ -77,48 +78,47 @@ async function doWeb(doc, url) { // "Date" works for both t and OA let niceDate = ZU.xpathText(mTable, '//tr[contains(th, "Date")]/td[1]'); - - if (url.includes('/record/t1') ) { + if (url.includes('/record/t1')) { var item = new Zotero.Item("case"); - var sessDate = id.substring(1,5) + "/" + id.substring(5,7) + "/" + id.substring(7,9); + + var sessDate = id.substring(1, 5) + "/" + id.substring(5, 7) + "/" + id.substring(7, 9); var offencesList = ZU.xpathText(mTable, '//tr[contains(th, "Offences")]/td[1]'); var offences = ZU.xpath(mTable, '//tr[contains(th, "Offences")]/td[1]/a'); - for (let o of offences){ - item.tags.push(o.textContent) + for (let o of offences) { + item.tags.push(o.textContent); } var verdicts = ZU.xpath(mTable, '//tr[contains(th, "Verdicts")]/td[1]/a'); - for (let v of verdicts){ - item.tags.push(v.textContent) + for (let v of verdicts) { + item.tags.push(v.textContent); } var sentences = ZU.xpath(mTable, '//tr[contains(th, "Punishments")]/td[1]/a'); - for (let s of sentences){ - item.tags.push(s.textContent) + for (let s of sentences) { + item.tags.push(s.textContent); } var itemTitle = "Trial of " + namesCleaned + ": " + offencesList + ", " + niceDate; - + item.title = itemTitle; + item.date = ZU.strToISO(sessDate); item.docketNumber = json.idkey; - item.court = "Central Criminal Court, London" // 1834 change...? - } - - else if (url.includes('record/OA1') ) { - var item = new Zotero.Item("book"); - var sessDate = id.substring(2,6) + "/" + id.substring(6,8) + "/" + id.substring(8,10); - var itemTitle = "Ordinary's Account, " + niceDate; + item.court = "Central Criminal Court, London"; } - item.title = itemTitle ; + else if (url.includes('record/OA1')) { + var item = new Zotero.Item("book"); + + var oaDate = id.substring(2, 6) + "/" + id.substring(6, 8) + "/" + id.substring(8, 10); + var oaTitle = "Ordinary's Account, " + niceDate; - item.date = ZU.strToISO(sessDate); + item.date = ZU.strToISO(oaDate); + item.title = oaTitle; + } - item.extra = "Reference Number: " + json.idkey; + item.extra = "Reference Number: " + json.idkey; item.url = url; - //item.notes = "Names: " + namesCleaned; // do something with these maybe? - item.complete(); } @@ -133,9 +133,11 @@ var testCases = [ "caseName": "Trial of Judith Cupid: Theft > Theft from place, 11th September 1734", "creators": [], "dateDecided": "1734-09-11", + "court": "Central Criminal Court, London", "docketNumber": "t17340911-7", "extra": "Reference Number: t17340911-7", "shortTitle": "Trial of Judith Cupid", + "url": "https://www.oldbaileyonline.org/record/t17340911-7", "attachments": [], "tags": [ { @@ -170,6 +172,7 @@ var testCases = [ "date": "1711-04-21", "extra": "Reference Number: OA17110421", "libraryCatalog": "Old Bailey Online", + "url": "https://www.oldbaileyonline.org/record/OA17110421", "attachments": [], "tags": [], "notes": [], @@ -186,9 +189,11 @@ var testCases = [ "caseName": "Trial of Peter Asterbawd, Andrew Forsman: Theft > Burglary, 15th January 1800", "creators": [], "dateDecided": "1800-01-15", + "court": "Central Criminal Court, London", "docketNumber": "t18000115-12", "extra": "Reference Number: t18000115-12", "shortTitle": "Trial of Peter Asterbawd, Andrew Forsman", + "url": "https://www.oldbaileyonline.org/record/t18000115-12", "attachments": [], "tags": [ { From 4db125229f8f5c5d1e655f6e1fb1955f738f57ad Mon Sep 17 00:00:00 2001 From: sharonhoward Date: Sat, 31 Aug 2024 14:47:09 +0100 Subject: [PATCH 7/8] fix linting issues OBO translator maybe probably this time. --- Old Bailey Online.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Old Bailey Online.js b/Old Bailey Online.js index a7d03984837..b73d57030b6 100644 --- a/Old Bailey Online.js +++ b/Old Bailey Online.js @@ -9,7 +9,7 @@ "inRepository": true, "translatorType": 4, "browserSupport": "gcsibv", - "lastUpdated": "2024-08-31 13:32:20" + "lastUpdated": "2024-08-31 13:46:15" } /* @@ -62,6 +62,8 @@ function getSearchResults(doc, checkOnly) { }*/ async function doWeb(doc, url) { + var item = new Zotero.Item(); + let rgx = /(\bt1[^-]+-[0-9]+[a-z]?|OA1[0-9]+[a-z]?)/; let id = url.match(rgx)[0]; @@ -79,7 +81,7 @@ async function doWeb(doc, url) { let niceDate = ZU.xpathText(mTable, '//tr[contains(th, "Date")]/td[1]'); if (url.includes('/record/t1')) { - var item = new Zotero.Item("case"); + item.itemType = "case"; var sessDate = id.substring(1, 5) + "/" + id.substring(5, 7) + "/" + id.substring(7, 9); @@ -106,7 +108,7 @@ async function doWeb(doc, url) { } else if (url.includes('record/OA1')) { - var item = new Zotero.Item("book"); + item.itemType = "book"; var oaDate = id.substring(2, 6) + "/" + id.substring(6, 8) + "/" + id.substring(8, 10); var oaTitle = "Ordinary's Account, " + niceDate; From 85e2b1c0172d7a0b89994aacd365e4ecf284eb46 Mon Sep 17 00:00:00 2001 From: sharonhoward Date: Sun, 15 Sep 2024 14:18:03 +0100 Subject: [PATCH 8/8] added session paper --- Old Bailey Online.js | 170 +++++++++++++++++++++++++++++++------------ package-lock.json | 52 ++++++------- 2 files changed, 151 insertions(+), 71 deletions(-) diff --git a/Old Bailey Online.js b/Old Bailey Online.js index b73d57030b6..85a6932736c 100644 --- a/Old Bailey Online.js +++ b/Old Bailey Online.js @@ -9,7 +9,7 @@ "inRepository": true, "translatorType": 4, "browserSupport": "gcsibv", - "lastUpdated": "2024-08-31 13:46:15" + "lastUpdated": "2024-09-15 13:03:34" } /* @@ -36,8 +36,10 @@ */ /* new URLs -// trial: /record/t18000115-12 -// OA: /record/OA16760705 +// trial report: /record/t18000115-12 [case] +// OA: /record/OA16760705 [book] +// session: /record/16740429 [book] +// other div types /record/[afso - anything else?] [book section might work for these] // api: https://www.dhi.ac.uk/api/data/oldbailey_record_single?idkey=t17210419-18 */ @@ -45,26 +47,32 @@ function detectWeb(doc, url) { if (url.includes('/record/t')) { return "case"; } - else if (url.includes('record/OA')) { + else if (url.includes('/record/1')) { return "book"; + } + else if (url.includes('/record/OA')) { + return "book"; + + // multiples are not doable at present // } else if (url.includes('/search/') && getSearchResults(doc, true)) { // return 'multiple'; // } } - // multiples skipped as search isn't working right now...? return false; } -/* TODO +/* may be possible to reinstate this in the longer term but not at present. function getSearchResults(doc, checkOnly) { - // api endpoint https://www.dhi.ac.uk/api/data/oldbailey_record?(query string) - + // have to use api endpoint. https://www.dhi.ac.uk/api/data/oldbailey_record?(query string) + // several types of search seem not to be accessible via the api (statistics, OAs, associated records) + // keyword and name searches need to be able to handle any Proceedings div type, not just trials + // (may be doable, but much more complicated code) }*/ async function doWeb(doc, url) { var item = new Zotero.Item(); - let rgx = /(\bt1[^-]+-[0-9]+[a-z]?|OA1[0-9]+[a-z]?)/; + let rgx = /(\bt1[^-]+-[0-9]+[a-z]?|OA1[0-9]+[a-z]?|\b1[0-9]{7}[AE]?$)/; let id = url.match(rgx)[0]; let jsonURL = `https://www.dhi.ac.uk/api/data/oldbailey_record_single?idkey=${id}`; @@ -74,22 +82,27 @@ async function doWeb(doc, url) { let mParsed = new DOMParser().parseFromString(metadata, 'text/html'); let mTable = mParsed.querySelector("table"); - // names for trial or OA - let names = ZU.xpathText(mTable, '//tr[contains(th, "Defendants")]/td[1]|//tr[contains(th, "People")]/td[1]'); - let namesCleaned = ZU.capitalizeTitle(names.toLowerCase(), true); - // "Date" works for both t and OA + // "Date" works for session, t and OA let niceDate = ZU.xpathText(mTable, '//tr[contains(th, "Date")]/td[1]'); + // text type + let textType = ZU.xpathText(mTable, '//tr[contains(th, "Text type")]/td[1]'); + if (url.includes('/record/t1')) { item.itemType = "case"; var sessDate = id.substring(1, 5) + "/" + id.substring(5, 7) + "/" + id.substring(7, 9); + // names for trial defendants. + var names = ZU.xpathText(mTable, '//tr[contains(th, "Defendant")]/td[1]'); + var namesCleaned = ZU.capitalizeTitle(names.toLowerCase(), true); + var offencesList = ZU.xpathText(mTable, '//tr[contains(th, "Offences")]/td[1]'); var offences = ZU.xpath(mTable, '//tr[contains(th, "Offences")]/td[1]/a'); for (let o of offences) { item.tags.push(o.textContent); } + var verdicts = ZU.xpath(mTable, '//tr[contains(th, "Verdicts")]/td[1]/a'); for (let v of verdicts) { item.tags.push(v.textContent); @@ -111,12 +124,22 @@ async function doWeb(doc, url) { item.itemType = "book"; var oaDate = id.substring(2, 6) + "/" + id.substring(6, 8) + "/" + id.substring(8, 10); - var oaTitle = "Ordinary's Account, " + niceDate; + var oaTitle = textType + ", " + niceDate; item.date = ZU.strToISO(oaDate); item.title = oaTitle; } + else if (url.includes('record/1')) { + item.itemType = "book"; + + var sessionDate = id.substring(0, 4) + "/" + id.substring(4, 6) + "/" + id.substring(6, 8); + var sessionTitle = textType + ", " + niceDate; + + item.date = ZU.strToISO(sessionDate); + item.title = sessionTitle; + } + item.extra = "Reference Number: " + json.idkey; item.url = url; @@ -128,36 +151,18 @@ async function doWeb(doc, url) { var testCases = [ { "type": "web", - "url": "https://www.oldbaileyonline.org/record/t17340911-7", + "url": "https://www.oldbaileyonline.org/record/OA17110421", "items": [ { - "itemType": "case", - "caseName": "Trial of Judith Cupid: Theft > Theft from place, 11th September 1734", + "itemType": "book", + "title": "Ordinary's Account, 21st April 1711", "creators": [], - "dateDecided": "1734-09-11", - "court": "Central Criminal Court, London", - "docketNumber": "t17340911-7", - "extra": "Reference Number: t17340911-7", - "shortTitle": "Trial of Judith Cupid", - "url": "https://www.oldbaileyonline.org/record/t17340911-7", + "date": "1711-04-21", + "extra": "Reference Number: OA17110421", + "libraryCatalog": "Old Bailey Online", + "url": "https://www.oldbaileyonline.org/record/OA17110421", "attachments": [], - "tags": [ - { - "tag": "Guilty" - }, - { - "tag": "Theft" - }, - { - "tag": "Theft from place" - }, - { - "tag": "Theft under 40s" - }, - { - "tag": "Transportation" - } - ], + "tags": [], "notes": [], "seeAlso": [] } @@ -165,16 +170,16 @@ var testCases = [ }, { "type": "web", - "url": "https://www.oldbaileyonline.org/record/OA17110421", + "url": "https://www.oldbaileyonline.org/record/16740429", "items": [ { "itemType": "book", - "title": "Ordinary's Account, 21st April 1711", + "title": "Sessions paper, 29th April 1674", "creators": [], - "date": "1711-04-21", - "extra": "Reference Number: OA17110421", + "date": "1674-04-29", + "extra": "Reference Number: 16740429", "libraryCatalog": "Old Bailey Online", - "url": "https://www.oldbaileyonline.org/record/OA17110421", + "url": "https://www.oldbaileyonline.org/record/16740429", "attachments": [], "tags": [], "notes": [], @@ -230,6 +235,81 @@ var testCases = [ "seeAlso": [] } ] + }, + { + "type": "web", + "url": "https://www.oldbaileyonline.org/record/t17340911-7", + "items": [ + { + "itemType": "case", + "caseName": "Trial of Judith Cupid: Theft > Theft from place, 11th September 1734", + "creators": [], + "dateDecided": "1734-09-11", + "court": "Central Criminal Court, London", + "docketNumber": "t17340911-7", + "extra": "Reference Number: t17340911-7", + "shortTitle": "Trial of Judith Cupid", + "url": "https://www.oldbaileyonline.org/record/t17340911-7", + "attachments": [], + "tags": [ + { + "tag": "Guilty" + }, + { + "tag": "Theft" + }, + { + "tag": "Theft from place" + }, + { + "tag": "Theft under 40s" + }, + { + "tag": "Transportation" + } + ], + "notes": [], + "seeAlso": [] + } + ] + }, + { + "type": "web", + "url": "https://www.oldbaileyonline.org/record/16810117A", + "items": [ + { + "itemType": "book", + "title": "Sessions paper, 17th January 1681", + "creators": [], + "date": "1681-01-17", + "extra": "Reference Number: 16810117A", + "libraryCatalog": "Old Bailey Online", + "url": "https://www.oldbaileyonline.org/record/16810117A", + "attachments": [], + "tags": [], + "notes": [], + "seeAlso": [] + } + ] + }, + { + "type": "web", + "url": "https://www.oldbaileyonline.org/record/OA16850506A", + "items": [ + { + "itemType": "book", + "title": "Ordinary's Account, 6th May 1685", + "creators": [], + "date": "1685-05-06", + "extra": "Reference Number: OA16850506", + "libraryCatalog": "Old Bailey Online", + "url": "https://www.oldbaileyonline.org/record/OA16850506A", + "attachments": [], + "tags": [], + "notes": [], + "seeAlso": [] + } + ] } ] /** END TEST CASES **/ diff --git a/package-lock.json b/package-lock.json index 5c02b6cb062..58893771429 100644 --- a/package-lock.json +++ b/package-lock.json @@ -295,12 +295,12 @@ "dev": true }, "node_modules/axios": { - "version": "1.6.7", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.7.tgz", - "integrity": "sha512-/hDJGff6/c7u0hDkvkGxR/oy6CbCs8ziCsC7SqmhjfozqiJGc8Z11wrv9z9lYfY4K8l+H9TpjcMDX0xOZmx+RA==", + "version": "1.7.7", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz", + "integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==", "dev": true, "dependencies": { - "follow-redirects": "^1.15.4", + "follow-redirects": "^1.15.6", "form-data": "^4.0.0", "proxy-from-env": "^1.1.0" } @@ -845,9 +845,9 @@ "dev": true }, "node_modules/follow-redirects": { - "version": "1.15.5", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz", - "integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==", + "version": "1.15.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", + "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", "dev": true, "funding": [ { @@ -1914,9 +1914,9 @@ } }, "node_modules/word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", "dev": true, "engines": { "node": ">=0.10.0" @@ -1929,9 +1929,9 @@ "dev": true }, "node_modules/ws": { - "version": "8.13.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz", - "integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==", + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", + "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", "dev": true, "engines": { "node": ">=10.0.0" @@ -2167,12 +2167,12 @@ "dev": true }, "axios": { - "version": "1.6.7", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.7.tgz", - "integrity": "sha512-/hDJGff6/c7u0hDkvkGxR/oy6CbCs8ziCsC7SqmhjfozqiJGc8Z11wrv9z9lYfY4K8l+H9TpjcMDX0xOZmx+RA==", + "version": "1.7.7", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz", + "integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==", "dev": true, "requires": { - "follow-redirects": "^1.15.4", + "follow-redirects": "^1.15.6", "form-data": "^4.0.0", "proxy-from-env": "^1.1.0" } @@ -2586,9 +2586,9 @@ "dev": true }, "follow-redirects": { - "version": "1.15.5", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz", - "integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==", + "version": "1.15.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", + "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", "dev": true }, "form-data": { @@ -3384,9 +3384,9 @@ } }, "word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", "dev": true }, "wrappy": { @@ -3396,9 +3396,9 @@ "dev": true }, "ws": { - "version": "8.13.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz", - "integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==", + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", + "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", "dev": true, "requires": {} },