Skip to content
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

Add page localization #7128

Merged
merged 65 commits into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
dc9f90d
Merge commit 'ccb045b68c5b4d983a90fa125513fc476e4e2387'
mtrezza Nov 19, 2020
4d72525
Merge remote-tracking branch 'upstream/master'
mtrezza Dec 4, 2020
65a6bdb
Merge remote-tracking branch 'upstream/master'
mtrezza Dec 5, 2020
50274b8
Merge remote-tracking branch 'upstream/master'
mtrezza Dec 8, 2020
3b337cd
Merge remote-tracking branch 'upstream/master'
mtrezza Dec 15, 2020
073f0fc
Merge remote-tracking branch 'upstream/master'
mtrezza Dec 18, 2020
2ee5907
Merge remote-tracking branch 'upstream/master'
mtrezza Dec 19, 2020
241a1d8
Merge remote-tracking branch 'upstream/master'
mtrezza Dec 26, 2020
4f097ce
Merge remote-tracking branch 'upstream/master'
mtrezza Jan 14, 2021
4f32562
added localized pages; added refactored page templates; adapted test …
mtrezza Jan 17, 2021
e90f6c5
added changelog entry
mtrezza Jan 17, 2021
af33f60
fixed test description typo
mtrezza Jan 17, 2021
d763150
fixed bug in PromiseRouter where headers are not added for text reponse
mtrezza Jan 17, 2021
7021f14
added page parameters in page headers for programmatic use
mtrezza Jan 17, 2021
7a04836
refactored tests for PublicAPIRouter
mtrezza Jan 17, 2021
d80e31b
added mustache lib for template rendering
mtrezza Jan 17, 2021
cd46b0d
fixed fs.promises module reference
mtrezza Jan 17, 2021
7a24c71
fixed template placeholder typo
mtrezza Jan 18, 2021
e5e73a7
changed redirect response to provide headers instead of query parameters
mtrezza Jan 18, 2021
212ad36
fix lint
mtrezza Jan 18, 2021
2e8b228
fixed syntax errors and typos in html templates
mtrezza Jan 18, 2021
34d5343
removed obsolete URI encoding
mtrezza Jan 18, 2021
9748fb3
added locale inferring from request body and header
mtrezza Jan 18, 2021
76fe0ca
added end-to-end localizaton test
mtrezza Jan 18, 2021
597b25c
added server option validation; refactored pages server option
mtrezza Jan 18, 2021
2196342
fixed invalid redirect URL for no locale matching file
mtrezza Jan 18, 2021
1002374
added end-to-end localizaton tests
mtrezza Jan 18, 2021
389fb06
adapted tests to new response content
mtrezza Jan 18, 2021
25f62e7
re-added PublicAPIRouter; added PagesRouter as experimental feature
mtrezza Jan 19, 2021
87ec8e7
refactored PagesRouter test structure
mtrezza Jan 19, 2021
0a6cc5e
added configuration option for custom path to pages
mtrezza Jan 19, 2021
3e00128
added configuration option for custom endpoint to pages
mtrezza Jan 19, 2021
00547b3
fixed lint
mtrezza Jan 19, 2021
f2fcbd3
added tests
mtrezza Jan 20, 2021
2a38532
added a distinct page for invalid password reset link
mtrezza Jan 20, 2021
3d3db6a
renamed generic page invalidLink to expiredVerificationLink
mtrezza Jan 20, 2021
373b6df
improved HTML files documentation
mtrezza Jan 20, 2021
ff3c877
improved HTML files documentation
mtrezza Jan 20, 2021
04fbfb4
changed changelog entry for experimental feature
mtrezza Jan 20, 2021
211bb00
improved file naming to make it more descriptive
mtrezza Jan 21, 2021
b11e5b9
fixed file naming and env parameter naming
mtrezza Jan 21, 2021
617dbc9
added readme entry
mtrezza Jan 21, 2021
1573806
fixed readme TOC - hasn't been updated in a while
mtrezza Jan 21, 2021
8f3ea1c
Merge remote-tracking branch 'upstream/master'
mtrezza Jan 23, 2021
4743cbc
Merge remote-tracking branch 'upstream/master'
mtrezza Jan 28, 2021
fa7a753
added localization with JSON resource
mtrezza Jan 31, 2021
03bba6a
added JSON localization to feature pages (password reset, email verif…
mtrezza Jan 31, 2021
a54c4c7
updated readme
mtrezza Jan 31, 2021
3d01cf1
updated readme
mtrezza Jan 31, 2021
19ed17b
optimized JSON localization for feature pages; added e2e test case
mtrezza Feb 1, 2021
59de429
Merge remote-tracking branch 'upstream/master'
mtrezza Feb 1, 2021
0988b99
Merge branch 'master' into add-page-localization
mtrezza Feb 1, 2021
618c435
Merge branch 'master' into add-page-localization
mtrezza Feb 1, 2021
33b53d4
fixed readme typo
mtrezza Feb 1, 2021
4ac55ef
minor refactoring of existing tests
mtrezza Feb 7, 2021
11a2c81
fixed bug where Object type was not recognized as config key type
mtrezza Feb 7, 2021
2b9f2dc
added feature config placeholders
mtrezza Feb 7, 2021
3ba14db
prettier
mtrezza Feb 7, 2021
0ac2ec7
Merge commit '6097e82194772847954dc2c2b7559543cc7531cc' into add-page…
mtrezza Feb 7, 2021
5957c5b
Merge commit 'b59517fd68a56885c9ab73525526e42ff4003333' into add-page…
mtrezza Feb 7, 2021
3e31aae
added passing locale to page config placeholder callback
mtrezza Feb 8, 2021
76e983f
refactored passing locale to placeholder to pass test
mtrezza Feb 8, 2021
aeaac52
added config placeholder feature to README
mtrezza Feb 8, 2021
79058b0
fixed typo in README
mtrezza Feb 8, 2021
b301f9e
Merge commit 'cca493b9fb33a4c34eaaf624ec4aedd18b11dca7' into add-page…
mtrezza Feb 8, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
__BREAKING CHANGES:__
- NEW: Added file upload restriction. File upload is now only allowed for authenticated users by default for improved security. To allow file upload also for Anonymous Users or Public, set the `fileUpload` parameter in the [Parse Server Options](https://parseplatform.org/parse-server/api/master/ParseServerOptions.html). [#7071](https://github.com/parse-community/parse-server/pull/7071). Thanks to [dblythy](https://github.com/dblythy), [Manuel Trezza](https://github.com/mtrezza).
___
- NEW: Added convenience method Parse.Cloud.sendEmail(...) to send email via email adapter in Cloud Code. [#7089](https://github.com/parse-community/parse-server/pull/7089). Thanks to [dblythy](https://github.com/dblythy)
- NEW (EXPERIMENTAL): Added new page router with placeholder rendering and localization of custom and feature pages such as password reset and email verification. **Caution, this is an experimental feature that may not be appropriate for production.** [#6891](https://github.com/parse-community/parse-server/issues/6891). Thanks to [Manuel Trezza](https://github.com/mtrezza).
- NEW: Added convenience method `Parse.Cloud.sendEmail(...)` to send email via email adapter in Cloud Code. [#7089](https://github.com/parse-community/parse-server/pull/7089). Thanks to [dblythy](https://github.com/dblythy)
- NEW: LiveQuery support for $and, $nor, $containedBy, $geoWithin, $geoIntersects queries [#7113](https://github.com/parse-community/parse-server/pull/7113). Thanks to [dplewis](https://github.com/dplewis)
- NEW: Supporting patterns in LiveQuery server's config parameter `classNames` [#7131](https://github.com/parse-community/parse-server/pull/7131). Thanks to [Nes-si](https://github.com/Nes-si)
- IMPROVE: Added new account lockout policy option `accountLockout.unlockOnPasswordReset` to automatically unlock account on password reset. [#7146](https://github.com/parse-community/parse-server/pull/7146). Thanks to [Manuel Trezza](https://github.com/mtrezza).
Expand Down
301 changes: 256 additions & 45 deletions README.md

Large diffs are not rendered by default.

4,124 changes: 1,286 additions & 2,838 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"lru-cache": "5.1.1",
"mime": "2.5.0",
"mongodb": "3.6.3",
"mustache": "4.1.0",
"parse": "2.19.0",
"pg-promise": "10.9.1",
"pluralize": "8.0.0",
Expand Down
17 changes: 17 additions & 0 deletions public/custom_json.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<!--
This page demonstrates how to localize using a JSON file that contains the
translations for each placeholder.
-->
<html>

<head>
<title>{{title}}</title>
</head>

<body>
<h1>{{heading}}</h1>
<p>{{body}}</p>
</body>

</html>
23 changes: 23 additions & 0 deletions public/custom_json.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"en": {
"translation": {
"title": "Hello!",
"heading": "Welcome to {{appName}}!",
"body": "We are delighted to welcome you on board."
}
},
"de": {
"translation": {
"title": "Hallo!",
"heading": "Willkommen bei {{appName}}!",
"body": "Wir freuen uns, dich begrüßen zu dürfen."
}
},
"de-AT": {
"translation": {
"title": "Servus!",
"heading": "Willkommen bei {{appName}}!",
"body": "Wir freuen uns, dich begrüßen zu dürfen."
}
}
}
24 changes: 24 additions & 0 deletions public/de-AT/email_verification_link_expired.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<!--
This page is displayed when a user opens a verify email link with a security
token that is expired or incorrect. This can either mean the user has clicked
on a stale link (i.e. re-clicked on the link) or this could be a sign of a
malicious user trying to tamper with your app.
-->
<html>

<head>
<title>Email Verification</title>
</head>

<body>
<h1>{{appName}}</h1>
<h1>Expired verification link!</h1>
<form method="POST" action="{{{publicServerUrl}}}/apps/{{{appId}}}/resend_verification_email">
<input name="username" type="hidden" value="{{{username}}}">
<input name="locale" type="hidden" value="{{{locale}}}">
<button type="submit">Resend Link</button>
</form>
</body>

</html>
21 changes: 21 additions & 0 deletions public/de-AT/email_verification_link_invalid.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<!--
This page is displayed when a user opens a verify email link with parameters
that are missing or incorrect. This can either mean the user has incorrectly
entered a link or this could be a sign of a malicious user trying to tamper
with your app.
If the link contains an expired security token (or the email has already
been verified), this page is not displayed, there is another page for that.
-->
<html>

<head>
<title>Email Verification</title>
</head>

<body>
<h1>{{appName}}</h1>
<h1>Invalid verification link!</h1>
</body>

</html>
21 changes: 21 additions & 0 deletions public/de-AT/email_verification_send_fail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<!--
This page is displayed when a user opens a verify email link with a security
token that is expired or incorrect, then requests to receive another link,
but it fails because the username is invalid or the email has already been
verified. This can either mean the user has previously verified the email
or this could be a sign of a malicious user trying to tamper with your app.
-->
<html>

<head>
<title>Email Verification</title>
</head>

<body>
<h1>{{appName}}</h1>
<h1>Invalid link!</h1>
<p>No link sent. User not found or email already verified.</p>
</body>

</html>
19 changes: 19 additions & 0 deletions public/de-AT/email_verification_send_success.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<!--
This page is displayed when a user opens a verify email link with a
security token that is expired, then requests to receive another email
with a new link and the email is sent successfully.
-->
<html>

<head>
<title>Email Verification</title>
</head>

<body>
<h1>{{appName}}</h1>
<h1>Link sent!</h1>
<p>A new link has been sent. Check your email.</p>
</body>

</html>
18 changes: 18 additions & 0 deletions public/de-AT/email_verification_success.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<!--
This page is displayed when a user opens a verify email link and the
email gets verified successfully.
-->
<html>

<head>
<title>Email Verification</title>
</head>

<body>
<h1>{{appName}}</h1>
<h1>Email verified!</h1>
<p>Successfully verified your email for account: {{username}}.</p>
</body>

</html>
65 changes: 65 additions & 0 deletions public/de-AT/password_reset.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<!DOCTYPE html>
<!--
This page is displayed when someone clicks a valid 'reset password' link.
Users should feel free to add to this page (i.e. branding or security widgets)
but should be sure not to delete any of the form inputs or the javascript from the
template file. This javascript is what adds the necessary values to authenticate
this session with Parse.
The query params 'username' and 'app' hold the friendly names for your current user and
your app. You should feel free to incorporate their values to make the page more personal.
If you are missing form parameters in your POST, Parse will navigate back to this page and
add an 'error' query parameter.
-->
<html>

<head>
<title>Password Reset</title>
</head>

<body>
<h1>{{appName}}</h1>
<h1>Reset Your Password</h1>
<noscript><p>We apologize, but resetting your password requires javascript</p></noscript>
<p>You can set a new Password for your account: {{username}}</p>
<br />
<p>{{error}}</p>
<form id='form' action='{{{publicServerUrl}}}/apps/{{{appId}}}/request_password_reset' method='POST'>
<input name='utf-8' type='hidden' value='✓' />
<input name="username" type="hidden" id="username" value="{{{username}}}" />
<input name="token" type="hidden" id="token" value="{{{token}}}" />
<input name="locale" type="hidden" id="locale" value="{{{locale}}}" />

<p>New Password</p>
<input name="new_password" type="password" id="password" />
<p>Confirm New Password</p>
<input name="confirm_new_password" type="password" id="password_confirm" />
<br />
<p id="password_match_info"></p>
<br />
<button id="change_password">Change Password</button>
</form>

<script>
window.onload = function() {
document.getElementById("password").oninput = validatePassword;
document.getElementById("password_confirm").oninput = validatePassword;
document.getElementById("change_password").disabled = true;

function validatePassword() {
var pass2 = document.getElementById("password").value;
var pass1 = document.getElementById("password_confirm").value;
if(pass1 !== pass2) {
if(document.getElementById("password_confirm").value) {
document.getElementById("change_password").disabled = true;
document.getElementById("password_match_info").innerHTML = "Must match the previous entry";
}
} else {
document.getElementById("change_password").disabled = false;
document.getElementById("password_match_info").innerHTML = "";
}
}
}
</script>
</body>

</html>
19 changes: 19 additions & 0 deletions public/de-AT/password_reset_link_invalid.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<!--
This page is displayed when a user opens a password reset link with parameters
that are missing or incorrect. This can either mean the user has incorrectly
entered a link or this could be a sign of a malicious user trying to tamper
with your app.
-->
<html>

<head>
<title>Password Reset</title>
</head>

<body>
<h1>{{appName}}</h1>
<h1>Invalid password reset link!</h1>
</body>

</html>
18 changes: 18 additions & 0 deletions public/de-AT/password_reset_success.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<!--
This page is displayed when a user opens a reset password link, then submits
the form with a new password and the password gets updated successfully.
-->
<html>

<head>
<title>Password Reset</title>
</head>

<body>
<h1>{{appName}}</h1>
<h1>Success!</h1>
<p>Your password has been updated.</p>
</body>

</html>
24 changes: 24 additions & 0 deletions public/de/email_verification_link_expired.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<!--
This page is displayed when a user opens a verify email link with a security
token that is expired or incorrect. This can either mean the user has clicked
on a stale link (i.e. re-clicked on the link) or this could be a sign of a
malicious user trying to tamper with your app.
-->
<html>

<head>
<title>Email Verification</title>
</head>

<body>
<h1>{{appName}}</h1>
<h1>Expired verification link!</h1>
<form method="POST" action="{{{publicServerUrl}}}/apps/{{{appId}}}/resend_verification_email">
<input name="username" type="hidden" value="{{{username}}}">
<input name="locale" type="hidden" value="{{{locale}}}">
<button type="submit">Resend Link</button>
</form>
</body>

</html>
21 changes: 21 additions & 0 deletions public/de/email_verification_link_invalid.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<!--
This page is displayed when a user opens a verify email link with parameters
that are missing or incorrect. This can either mean the user has incorrectly
entered a link or this could be a sign of a malicious user trying to tamper
with your app.
If the link contains an expired security token (or the email has already
been verified), this page is not displayed, there is another page for that.
-->
<html>

<head>
<title>Email Verification</title>
</head>

<body>
<h1>{{appName}}</h1>
<h1>Invalid verification link!</h1>
</body>

</html>
21 changes: 21 additions & 0 deletions public/de/email_verification_send_fail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<!--
This page is displayed when a user opens a verify email link with a security
token that is expired or incorrect, then requests to receive another link,
but it fails because the username is invalid or the email has already been
verified. This can either mean the user has previously verified the email
or this could be a sign of a malicious user trying to tamper with your app.
-->
<html>

<head>
<title>Email Verification</title>
</head>

<body>
<h1>{{appName}}</h1>
<h1>Invalid link!</h1>
<p>No link sent. User not found or email already verified.</p>
</body>

</html>
19 changes: 19 additions & 0 deletions public/de/email_verification_send_success.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<!--
This page is displayed when a user opens a verify email link with a
security token that is expired, then requests to receive another email
with a new link and the email is sent successfully.
-->
<html>

<head>
<title>Email Verification</title>
</head>

<body>
<h1>{{appName}}</h1>
<h1>Link sent!</h1>
<p>A new link has been sent. Check your email.</p>
</body>

</html>
18 changes: 18 additions & 0 deletions public/de/email_verification_success.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<!--
This page is displayed when a user opens a verify email link and the
email gets verified successfully.
-->
<html>

<head>
<title>Email Verification</title>
</head>

<body>
<h1>{{appName}}</h1>
<h1>Email verified!</h1>
<p>Successfully verified your email for account: {{username}}.</p>
</body>

</html>
Loading