-
Notifications
You must be signed in to change notification settings - Fork 80
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
PDF: Switch to using Proton #1090
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,23 +22,14 @@ module.exports = options => ({ | |
operations: { | ||
generatePDF: (hyper, req) => { | ||
const rp = req.params; | ||
const newProbability = options.new_probability || 0; | ||
return hyper.get(new URI([rp.domain, 'sys', 'page_revisions', 'page', rp.title])) | ||
.then((latestRevision) => { | ||
if (options.new_uri && (Math.random() < newProbability || req.query.new_pdf)) { | ||
const newResult = hyper.get(new URI( | ||
if (options.new_uri) { | ||
return hyper.get(new URI( | ||
`${options.new_uri}/${rp.domain}/v1/` | ||
+ `pdf/${encodeURIComponent(rp.title)}/a4/desktop` | ||
)) | ||
.catch((e) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd still keep logging There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Won't throwing the error here make RB log it automatically? We don't want to end up with duplicate log entries. |
||
hyper.logger.log('error/proton', e); | ||
if (req.query.new_pdf) { | ||
throw e; | ||
} | ||
}); | ||
if (req.query.new_pdf) { | ||
return newResult; | ||
} | ||
+ `pdf/${encodeURIComponent(rp.title)}` | ||
+ `/${rp.format || 'a4'}/${rp.type || `desktop`}` | ||
)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we need to do more - change the public API to allow for changing the hardcoded There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, damn, forgot that part. Very good point. Will change. |
||
} | ||
return hyper.get({ | ||
uri: new URI(`${options.uri}/pdf`), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe let's rename new_uri to uri?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about it, but to keep it backwards compatible, I opted with leaving it as-is. Perhaps we could go with this now and revisit in the future?