-
Notifications
You must be signed in to change notification settings - Fork 786
/
Copy pathgovinfo.js
189 lines (177 loc) · 6 KB
/
govinfo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
{
"translatorID": "12a3b1cb-6bbb-4cf9-904f-8f732ee3d1e3",
"label": "govinfo",
"creator": "Abe Jellinek",
"target": "https?://www\\.govinfo\\.gov/",
"minVersion": "3.0",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2022-10-28 14:47:36"
}
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2021 Abe Jellinek
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 *****
*/
function detectWeb(doc, url) {
// TEMP: Why doesn't monitorDOMChanges() work here?
// We'd like to wait for a #mods link, but instead we just have to use the URL for now
if (url.includes('/details/')) {
return 'document';
}
// no clear way to do multiples: metadata URLs differ depending on whether
// the item is a "granule" or a "package," and I can't find any clues in the
// static page. I'm really not sure how the app does it. that's a todo
return false;
}
function doWeb(doc, url) {
scrape(doc, url);
}
function scrape(doc, _url) {
let modsURL = attr(doc, '#mods', 'href');
ZU.doGet(modsURL, function (respText) {
var translator = Zotero.loadTranslator("import");
translator.setTranslator("0e2235e7-babf-413c-9acf-f27cce5f059c");
translator.setString(respText);
translator.setHandler("itemDone", function (obj, item) {
item.complete();
});
translator.translate();
});
}
/** BEGIN TEST CASES **/
var testCases = [
{
"type": "web",
"url": "https://www.govinfo.gov/app/details/GPO-WMD",
"defer": true,
"items": [
{
"itemType": "document",
"title": "Unclassified Version of the Report of the Commission on the Intelligence Capabilities of the United States Regarding Weapons of Mass Destruction",
"creators": [
{
"lastName": "United States: Commission on the Intelligence Capabilities of the United States Regarding Weapons of Mass Destruction",
"fieldMode": 1,
"creatorType": "author"
},
{
"lastName": "United States: Commission on the Intelligence Capabilities of the United States Regarding Weapons of Mass Destruction",
"fieldMode": 1,
"creatorType": "author"
}
],
"date": "2005-03-31",
"abstractNote": "The Commission on the Intelligence Capabilities of the United States Regarding Weapons of Mass Destruction was established in 2004 and charged with examining the capabilities and challenges of the American intelligence community concerning the capabilities, intentions, and activities of foreign powers relating to the design, development, manufacture, acquisition, possession, proliferation, transfer, testing, potential or threatened use, or use of weapons of mass destruction, related means of delivery, and other related threats of the 21st Century.",
"callNumber": "PREX 1.19:IN 8/W 37",
"language": "eng",
"libraryCatalog": "govinfo",
"publisher": "Commission on the Intelligence Capabilities of the United States Regarding Weapons of Mass Destruction",
"rights": "fdlp",
"url": "https://www.govinfo.gov/app/details/GPO-WMD",
"attachments": [
{
"title": "JPEG rendition",
"mimeType": "image/jpeg"
},
{
"title": "PDF rendition",
"mimeType": "application/pdf"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://www.govinfo.gov/app/details/GPO-PICTDIR-116/",
"defer": true,
"items": [
{
"itemType": "document",
"title": "Congressional Pictorial Directory: 116th Congress",
"creators": [
{
"lastName": "United States: Congress: Joint Committee on Printing",
"fieldMode": 1,
"creatorType": "author"
}
],
"date": "2019-12-20",
"abstractNote": "The 116th Congressional Pictorial Directory provides a color photograph of each member of the House of Representatives and the Senate for the 116th Congress. It also includes information about a Member of Congress' length of service, political party affiliations, and Congressional district. Also contains pictures of the President, Vice President, and House and Senate officers and officials.",
"callNumber": "Y 4.P 93/1:",
"language": "eng",
"libraryCatalog": "govinfo",
"publisher": "U.S. Government Publishing Office",
"rights": "fdlp",
"shortTitle": "Congressional Pictorial Directory",
"url": "https://www.govinfo.gov/app/details/GPO-PICTDIR-116",
"attachments": [
{
"title": "PDF rendition",
"mimeType": "application/pdf"
},
{
"title": "JPEG rendition",
"mimeType": "image/jpeg"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "https://www.govinfo.gov/app/details/GOVPUB-RR-e27242037b46c40b6e3d3c1f45d8a8cf",
"defer": true,
"items": [
{
"itemType": "document",
"title": "BCD 2021-27 Employer Status Determination",
"creators": [
{
"lastName": "United States: Railroad Retirement Board",
"fieldMode": 1,
"creatorType": "author"
}
],
"date": "2021-06-15",
"callNumber": "RR",
"language": "eng",
"libraryCatalog": "govinfo",
"publisher": "Railroad Retirement Board",
"rights": "fdlp",
"url": "https://www.govinfo.gov/app/details/GOVPUB-RR-e27242037b46c40b6e3d3c1f45d8a8cf",
"attachments": [
{
"title": "PDF rendition",
"mimeType": "application/pdf"
}
],
"tags": [],
"notes": [],
"seeAlso": []
}
]
}
]
/** END TEST CASES **/