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
Deglobal #59
Merged
Merged
Deglobal #59
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
15f74b9
A bunch of whitespace consistency tweaks.
smashwilson 9ad28cf
Introduce a Context object.
smashwilson f4e6de5
Construct a Context for each content request.
smashwilson 28be645
Use Context in ContentRoutingService.
smashwilson a0d7e74
Use Context in TemplateRoutingService.
smashwilson 635023d
Use Contexts in the TemplateService.
smashwilson 2573a54
Use Context in PathService.
smashwilson 73ee4a2
Remove ResponseHelper from rewrite handler.
smashwilson 344108b
:hocho: RequestHelper
smashwilson 32ab813
:hocho: ResponseHelper.
smashwilson 4f2a6c4
Eliminate the HttpErrorHelper and its uses.
smashwilson b280092
Nunjucks environments are per-domain.
smashwilson a4bb808
Create routes for proxies for all sites.
smashwilson 2754077
ContentFilter only accepts one argument.
smashwilson 746b146
Pass the Context where it's supposed to go.
smashwilson 63ce228
Whitespace
smashwilson ac79ebb
getContentId does need that optional arg.
smashwilson 08f7ed3
Template location and rendering.
smashwilson 90ed29f
Get the first test passing. Phew.
smashwilson 6c1453e
Pass status codes through.
smashwilson 3dd755c
Clear cached templates to avoid confusion.
smashwilson a16f611
I know JavaScript really
smashwilson 03f7e0f
Properly mock the control repo.
smashwilson File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
var | ||
config = require('../config'), | ||
TemplateService = require('../services/template'); | ||
|
||
function Context(req, resp) { | ||
this.request = req; | ||
this.response = resp; | ||
} | ||
|
||
Context.prototype.host = function () { | ||
return config.presented_url_domain() || this.request.get('Host'); | ||
}; | ||
|
||
Context.prototype.protocol = function () { | ||
return config.presented_url_proto() || this._request.protocol; | ||
}; | ||
|
||
Context.prototype.send = function (body) { | ||
this.response.send(body); | ||
}; | ||
|
||
Context.prototype.handleError = function (err) { | ||
var code = err.statusCode || 500; | ||
if (err.statusCode && err.statusCode.toString() === "404") { | ||
code = 404; | ||
} | ||
|
||
TemplateService.render(this, code.toString(), {}, function (err, responseBody) { | ||
if (err) { | ||
console.error("I couldn't render an error template. I'm freaking out!", err); | ||
responseBody = "Er, I was going to render an error template, but I couldn't."; | ||
} | ||
|
||
this.response.status(code).send(responseBody); | ||
}.bind(this)); | ||
}; | ||
|
||
module.exports = Context; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
looks like a leftover reference to the
_request
propertyThere 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.
Oh good catch.