forked from Financial-Times/treecreeper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7fef7e7
commit ea80d88
Showing
102 changed files
with
691 additions
and
4,057 deletions.
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
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 |
---|---|---|
|
@@ -17,3 +17,4 @@ packages/**/package-lock.json | |
|
||
package-lock.json | ||
.stylelintcache | ||
packages/tc-ui/dist |
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
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
2 changes: 1 addition & 1 deletion
2
packages/tc-ui/src/components/messages.jsx → demo/cms/components/messages.jsx
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
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
2 changes: 1 addition & 1 deletion
2
packages/tc-ui/src/page/error-page.jsx → demo/cms/render/error-page.jsx
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const querystring = require('querystring'); | ||
|
||
const { renderHtml } = require('./react-renderer'); | ||
|
||
const errorTemplate = require('./error-page'); | ||
|
||
const handleError = func => async (...args) => { | ||
try { | ||
return func(...args); | ||
} catch (error) { | ||
const status = error.status || 500; | ||
return { | ||
status, | ||
body: renderHtml(errorTemplate, { status, error }), | ||
}; | ||
} | ||
}; | ||
|
||
const renderPage = ({ template, data, event = {}, status = 200 }) => { | ||
const user = event.isSignedIn && event.username; | ||
const fromDewey = !!(event.query || {})['from-dewey']; | ||
const { message, messageType } = event.query || {}; | ||
return { | ||
status, | ||
body: renderHtml( | ||
template, | ||
Object.assign(data, { | ||
user, | ||
fromDewey, | ||
message, | ||
messageType, | ||
querystring: querystring.stringify(event.query), | ||
}), | ||
), | ||
headers: { | ||
'Content-Type': 'text/html', | ||
'Cache-Control': 'max-age=0, private', | ||
}, | ||
}; | ||
}; | ||
|
||
module.exports = { | ||
handleError, | ||
renderPage, | ||
}; |
Oops, something went wrong.