Skip to content

Commit 83a0da2

Browse files
authored
Clean up case titles
1 parent 04c3440 commit 83a0da2

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

Old Bailey Online.js

+17-12
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"inRepository": true,
1010
"translatorType": 4,
1111
"browserSupport": "gcsibv",
12-
"lastUpdated": "2018-10-08 14:15:17"
12+
"lastUpdated": "2018-10-12 23:37:03"
1313
}
1414

1515
/*
@@ -32,7 +32,7 @@
3232
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
3333
3434
***** END LICENSE BLOCK *****
35-
*/
35+
*/
3636
// URLs
3737
// trial: div=t18000115-12
3838
// session: name=16900430
@@ -46,7 +46,7 @@ function detectWeb(doc, url) {
4646
return "case";
4747
} else if ( url.includes("search.jsp") && getSearchResults(doc, true)) {
4848
return "multiple";
49-
}
49+
}
5050
}
5151

5252
// to do: not trials...
@@ -91,20 +91,25 @@ if (url.includes('browse.jsp') && ( url.includes('div=OA') || url.includes('nam
9191

9292
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
9393

94-
newItem.date = ZU.strToISO(sessDate);
94+
newItem.date = ZU.strToISO(sessDate);
9595

9696
if (newItem.itemType == "case" && trialTitle && trialTitle == trialTitle.toUpperCase()) {
9797
newItem.title = ZU.capitalizeTitle(trialTitle, true); // todo tidying this up - sometimes no name, messy punctuation
9898
} else if (newItem.itemType == "book") {
9999
newItem.title = trialTitle + " " + sessDate;
100100
}
101+
102+
newItem.title = newItem.title.trim().replace(/[,.]+$/, "");
103+
if (!newItem.title) {
104+
newItem.title = "[no title]";
105+
}
101106

102107
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
103108

104109
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)
105110

106111
if (newItem.itemType == "case") {
107-
newItem.docketNumber = referenceNo;
112+
newItem.docketNumber = referenceNo;
108113
}
109114

110115
if (newItem.itemType == "book") {
@@ -144,7 +149,7 @@ if (newItem.itemType == "case") {
144149

145150
// use print-friendly URLs for snapshots
146151

147-
var attachmentUrl = "https://www.oldbaileyonline.org/print.jsp?div=" + referenceNo;
152+
var attachmentUrl = "https://www.oldbaileyonline.org/print.jsp?div=" + referenceNo;
148153
newItem.attachments.push({ url : attachmentUrl, title : "OBO Snapshot", mimeType : "text/html" });
149154

150155
newItem.complete();
@@ -166,7 +171,7 @@ function doWeb(doc, url) {
166171
}
167172
ZU.processDocuments(articles, scrape);
168173
});
169-
} else if (url.includes('browse.jsp') && ( url.includes('div=') || url.includes('name=') ) ) {
174+
} else if (url.includes('browse.jsp') && ( url.includes('div=') || url.includes('name=') ) ) {
170175
scrape(doc, url);
171176
}
172177
}
@@ -186,7 +191,7 @@ var testCases = [
186191
"items": [
187192
{
188193
"itemType": "case",
189-
"caseName": "Peter Asterbawd, Andrew Forsman.",
194+
"caseName": "Peter Asterbawd, Andrew Forsman",
190195
"creators": [],
191196
"dateDecided": "1800-01-15",
192197
"docketNumber": "t18000115-12",
@@ -233,7 +238,7 @@ var testCases = [
233238
"creators": [],
234239
"date": "1711-04-21",
235240
"extra": "Reference Number: OA17110421",
236-
"libraryCatalog": "Old Bailey Online 201809",
241+
"libraryCatalog": "Old Bailey Online",
237242
"place": "London",
238243
"url": "https://www.oldbaileyonline.org/browse.jsp?div=OA17110421",
239244
"attachments": [
@@ -258,7 +263,7 @@ var testCases = [
258263
"creators": [],
259264
"date": "1711-04-21",
260265
"extra": "Reference Number: OA17110421",
261-
"libraryCatalog": "Old Bailey Online 201809",
266+
"libraryCatalog": "Old Bailey Online",
262267
"place": "London",
263268
"url": "https://www.oldbaileyonline.org/browse.jsp?name=OA17110421",
264269
"attachments": [
@@ -283,7 +288,7 @@ var testCases = [
283288
"creators": [],
284289
"date": "1710-04-18",
285290
"extra": "Reference Number: 17100418",
286-
"libraryCatalog": "Old Bailey Online 201809",
291+
"libraryCatalog": "Old Bailey Online",
287292
"place": "London",
288293
"url": "https://www.oldbaileyonline.org/browse.jsp?name=17100418",
289294
"attachments": [
@@ -304,7 +309,7 @@ var testCases = [
304309
"items": [
305310
{
306311
"itemType": "case",
307-
"caseName": ".",
312+
"caseName": "[no title]",
308313
"creators": [],
309314
"dateDecided": "1678-08-28",
310315
"docketNumber": "t16780828-12",

0 commit comments

Comments
 (0)