Skip to content

Commit

Permalink
Client-side fix for freelawproject/courtlistener#766.
Browse files Browse the repository at this point in the history
Makes it so that we upload docket history reports with a different upload_type than dockets.
  • Loading branch information
mlissner committed Nov 17, 2017
1 parent 623e208 commit d5a2d62
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 17 deletions.
22 changes: 17 additions & 5 deletions content_delegate.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,14 @@ ContentDelegate.prototype.handleDocketDisplayPage = function() {
if (history.state && history.state.uploaded) {
return;
}

if (!(PACER.isDocketDisplayUrl(this.url) && this.pacer_case_id)) {
let isDocketDisplayUrl = PACER.isDocketDisplayUrl(this.url);
let isDocketHistoryDisplayUrl = PACER.isDocketHistoryDisplayUrl(this.url);
if (!(isDocketHistoryDisplayUrl || isDocketDisplayUrl)) {
// If it's not a docket display URL or a docket history URL, punt.
return;
}
if (!this.pacer_case_id) {
// If we don't have the pacer_case_id, punt.
return;
}

Expand All @@ -113,9 +119,15 @@ ContentDelegate.prototype.handleDocketDisplayPage = function() {
);
}
}, this);

this.recap.uploadDocket(this.court, this.pacer_case_id,
document.documentElement.innerHTML, callback);
if (isDocketDisplayUrl){
this.recap.uploadDocket(this.court, this.pacer_case_id,
document.documentElement.innerHTML, 'DOCKET',
callback);
} else if (isDocketHistoryDisplayUrl) {
this.recap.uploadDocket(this.court, this.pacer_case_id,
document.documentElement.innerHTML, 'DOCKET_HISTORY_REPORT',
callback);
}
} else {
console.info(`RECAP: Not uploading docket. RECAP is disabled.`)
}
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"author": "Free Law Project and the Center for Information Technology and Policy at Princeton",
"description": "RECAP improves the experience of using PACER, the online public access system for the U.S. federal courts.",
"homepage_url": "https://free.law/recap/",
"version": "1.1.7",
"version": "1.1.8",
"icons": {
"16": "assets/images/icon-16.png",
"19": "assets/images/icon-19.png",
Expand Down
12 changes: 8 additions & 4 deletions pacer.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,22 @@ let PACER = {
return false;
},

// Returns true if the URL is for the form for querying the list of documents
// in a docket (i.e. the "Docket Sheet" or "History/Documents" query page).
// Returns true if the URL is for docket query page.
isDocketQueryUrl: function (url) {
// The part after the "?" is all digits.
return !!url.match(/\/(DktRpt|HistDocQry)\.pl\?\d+$/);
},

// Returns true if the given URL is for a docket display page (i.e. the page
// after submitting the "Docket Sheet" or "History/Documents" query page).
// after submitting the "Docket Sheet" query page).
isDocketDisplayUrl: function (url) {
// The part after the "?" has hyphens in it.
return !!url.match(/\/(DktRpt|HistDocQry)\.pl\?\w+-[\w-]+$/);
return !!url.match(/\/DktRpt\.pl\?\w+-[\w-]+$/);
},

// Returns true if the given URL is for a docket history display page.
isDocketHistoryDisplayUrl: function (url) {
return !!url.match(/\/HistDocQry\.pl\?\w+-[\w-]+$/);
},

// Returns true if this is a "Document Selection Menu" page (a list of the
Expand Down
15 changes: 8 additions & 7 deletions recap.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ function Recap() {
UPLOAD_TYPES = {
'DOCKET': 1,
'ATTACHMENT_PAGE': 2,
'PDF': 3
'PDF': 3,
'DOCKET_HISTORY_REPORT': 4
};

return {
Expand Down Expand Up @@ -81,13 +82,12 @@ function Recap() {
}
},

// Uploads an HTML docket to the RECAP server, calling the callback with
// a boolean success flag.
uploadDocket: function (pacer_court, pacer_case_id, html, cb) {
// Uploads an HTML docket or docket history report to the RECAP server
uploadDocket: function (pacer_court, pacer_case_id, html, upload_type, cb) {
let formData = new FormData();
formData.append('court', PACER.convertToCourtListenerCourt(pacer_court));
formData.append('pacer_case_id', pacer_case_id);
formData.append('upload_type', UPLOAD_TYPES['DOCKET']);
formData.append('upload_type', UPLOAD_TYPES[upload_type]);
formData.append('filepath_local', new Blob([html], {type: 'text/plain'}));
formData.append('debug', DEBUG);
$.ajax({
Expand All @@ -97,8 +97,9 @@ function Recap() {
contentType: false,
data: formData,
success: function(data, textStatus, xhr){
console.info(`RECAP: Successfully uploaded docket: '${textStatus}' ` +
`with processing queue id of ${data['id']}`);
console.info(`RECAP: Successfully uploaded docket or docket ` +
`history report: '${textStatus}' with processing queue id of ` +
`${data['id']}`);
cb(data || null);
},
error: function(xhr, textStatus, errorThrown){
Expand Down

0 comments on commit d5a2d62

Please sign in to comment.