Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Old Bailey Online.js #1760

Merged
merged 4 commits into from Nov 12, 2018
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
64 changes: 52 additions & 12 deletions Old Bailey Online.js
Expand Up @@ -9,7 +9,7 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2018-10-08 14:06:13"
"lastUpdated": "2018-10-12 23:37:03"
}

/*
Expand All @@ -32,7 +32,7 @@
along with Zotero. If not, see <http://www.gnu.org/licenses/>.

***** END LICENSE BLOCK *****
*/
*/
// URLs
// trial: div=t18000115-12
// session: name=16900430
Expand All @@ -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...
Expand Down Expand Up @@ -86,24 +86,30 @@ 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);
newItem.date = ZU.strToISO(sessDate);

if (newItem.itemType == "case" && newItem.title && newItem.title == newItem.title.toUpperCase()) {
if (newItem.itemType == "case" && trialTitle && trialTitle == trialTitle.toUpperCase()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to split this further up, because maybe also trialTitle for a case might exitsts which is not all uppercase:

if (newItem.itemType == "case" && trialTitle) {
   if (trialTitle == trialTitle.toUpperCase()) {
      newItem.title = ZU.capitalizeTitle(trialTitle, true);
   } else {
      newItem.title = 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;
}

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") {
Expand Down Expand Up @@ -143,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();
Expand All @@ -165,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);
}
}
Expand All @@ -185,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",
Expand Down Expand Up @@ -232,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": [
Expand All @@ -257,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": [
Expand All @@ -282,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": [
Expand All @@ -296,6 +302,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": "[no title]",
"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 **/