From 3f6f09c0334192e0c5428784311c4393cc385f12 Mon Sep 17 00:00:00 2001 From: Ash Monty Date: Fri, 19 Aug 2022 20:46:13 +0200 Subject: [PATCH 01/20] chore: add weblate widget to readme --- README.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 89b5bac..f7fe71d 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,18 @@ -# Website for Pretendo Network +# Website -This is the Repository for the Website of the Pretendo Network. +This repository contains the source code for [our website](https://pretendo.network). All contributions should go in the [dev branch](https://github.com/PretendoNetwork/website/tree/dev). -Contributions should go in the [dev branch](https://github.com/PretendoNetwork/website/tree/dev). +### Localization +If you'd like to help localize Pretendo Network, you can check out our project on [Weblate](https://hosted.weblate.org/engage/pretendonetwork/). -Visit the [live version](https://pretendo.network) + + Translation status + + +* * * + +Join our Discord: - + \ No newline at end of file From 146c00731079b2b166b132cf2d5c93dfd545f525 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Sep 2022 22:02:16 +0000 Subject: [PATCH 02/20] chore(deps): bump mongoose from 6.4.0 to 6.4.6 Bumps [mongoose](https://github.com/Automattic/mongoose) from 6.4.0 to 6.4.6. - [Release notes](https://github.com/Automattic/mongoose/releases) - [Changelog](https://github.com/Automattic/mongoose/blob/master/CHANGELOG.md) - [Commits](https://github.com/Automattic/mongoose/compare/6.4.0...6.4.6) --- updated-dependencies: - dependency-name: mongoose dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index e6ab64d..f4adcf2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3078,9 +3078,9 @@ } }, "node_modules/mongoose": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-6.4.0.tgz", - "integrity": "sha512-eBDrueap1Zx3qFrcYylTiqTFlL5iTEaYAxoDF1MSRdipwAzChQRMJve+vxHtxPhI2q5tmf9RYHfZwXfTUHPd3g==", + "version": "6.4.6", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-6.4.6.tgz", + "integrity": "sha512-ZAfNCWgXhwev6k/+rMzjHIJ/+wLkundQU/i+aUTqmCgGoYqc+B5e4EC4Y3E1XaLzNXiWID1/vocSM6zs5IAGvA==", "dependencies": { "bson": "^4.6.2", "kareem": "2.4.1", @@ -6938,9 +6938,9 @@ } }, "mongoose": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-6.4.0.tgz", - "integrity": "sha512-eBDrueap1Zx3qFrcYylTiqTFlL5iTEaYAxoDF1MSRdipwAzChQRMJve+vxHtxPhI2q5tmf9RYHfZwXfTUHPd3g==", + "version": "6.4.6", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-6.4.6.tgz", + "integrity": "sha512-ZAfNCWgXhwev6k/+rMzjHIJ/+wLkundQU/i+aUTqmCgGoYqc+B5e4EC4Y3E1XaLzNXiWID1/vocSM6zs5IAGvA==", "requires": { "bson": "^4.6.2", "kareem": "2.4.1", From 7703ad51b96731d5ffda4559e87f228e174cb61b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Sep 2022 22:02:29 +0000 Subject: [PATCH 03/20] chore(deps): bump undici from 5.8.0 to 5.10.0 Bumps [undici](https://github.com/nodejs/undici) from 5.8.0 to 5.10.0. - [Release notes](https://github.com/nodejs/undici/releases) - [Commits](https://github.com/nodejs/undici/compare/v5.8.0...v5.10.0) --- updated-dependencies: - dependency-name: undici dependency-type: indirect ... Signed-off-by: dependabot[bot] --- package-lock.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index e6ab64d..f8e47b1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4354,9 +4354,9 @@ } }, "node_modules/undici": { - "version": "5.8.0", - "resolved": "https://registry.npmjs.org/undici/-/undici-5.8.0.tgz", - "integrity": "sha512-1F7Vtcez5w/LwH2G2tGnFIihuWUlc58YidwLiCv+jR2Z50x0tNXpRRw7eOIJ+GvqCqIkg9SB7NWAJ/T9TLfv8Q==", + "version": "5.10.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.10.0.tgz", + "integrity": "sha512-c8HsD3IbwmjjbLvoZuRI26TZic+TSEe8FPMLLOkN1AfYRhdjnKBU6yL+IwcSCbdZiX4e5t0lfMDLDCqj4Sq70g==", "engines": { "node": ">=12.18" } @@ -7928,9 +7928,9 @@ } }, "undici": { - "version": "5.8.0", - "resolved": "https://registry.npmjs.org/undici/-/undici-5.8.0.tgz", - "integrity": "sha512-1F7Vtcez5w/LwH2G2tGnFIihuWUlc58YidwLiCv+jR2Z50x0tNXpRRw7eOIJ+GvqCqIkg9SB7NWAJ/T9TLfv8Q==" + "version": "5.10.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.10.0.tgz", + "integrity": "sha512-c8HsD3IbwmjjbLvoZuRI26TZic+TSEe8FPMLLOkN1AfYRhdjnKBU6yL+IwcSCbdZiX4e5t0lfMDLDCqj4Sq70g==" }, "universalify": { "version": "2.0.0", From f45895790fc1d256a457ed70c773f88f2ef647fd Mon Sep 17 00:00:00 2001 From: mrjvs Date: Tue, 20 Sep 2022 18:54:49 +0200 Subject: [PATCH 04/20] Revert "hotfixes" --- docs/it_IT/welcome.md | 73 ++++++++++++++++++++++ locales/en_US.json | 27 +-------- src/routes/account.js | 7 +-- src/server.js | 51 ++++++++++++++++ src/util.js | 12 +--- views/account/account.handlebars | 81 +++++++++++++------------ views/account/login.handlebars | 14 ++--- views/account/register.handlebars | 18 +++--- views/account/upgrade.handlebars | 30 ++++----- views/blog/blog.handlebars | 8 +-- views/blog/blogpost.handlebars | 4 +- views/docs/docs.handlebars | 10 ++- views/docs/search.handlebars | 8 +-- views/docs/welcome.handlebars | 12 ++-- views/home.handlebars | 50 +++++++-------- views/localization.handlebars | 12 ++-- views/partials/docs-sidebar.handlebars | 12 ++-- views/partials/footer.handlebars | 28 ++++----- views/partials/header.handlebars | 18 +++--- views/partials/progress-list.handlebars | 2 +- views/progress.handlebars | 6 +- 21 files changed, 290 insertions(+), 193 deletions(-) create mode 100644 docs/it_IT/welcome.md diff --git a/docs/it_IT/welcome.md b/docs/it_IT/welcome.md new file mode 100644 index 0000000..1fbbc7a --- /dev/null +++ b/docs/it_IT/welcome.md @@ -0,0 +1,73 @@ +# Altra documentazione + +Siamo un gruppo di programmer che spendono il loro tempo libero a sviluppare e fare reverse-engineering per i server online per la 3DS e Wii U. + +Siamo un gruppo di programmer che spendono il loro tempo libero a sviluppare e fare reverse-engineering per i server online per la 3DS e Wii U. + +Siamo un gruppo di programmer che spendono il loro tempo libero a sviluppare e fare reverse-engineering per i server online per la 3DS e Wii U. + +```javascript +function returnTrue() { + class trueOrFalseObject { + constructor(trueOrFalse) { + this.trueOrFalse = trueOrFalse; + } + get trueOrFalse() { + return this.trueOrFalse(); + } + convertNumberToBoolean(trueOrFalse) { + if (convertStringToNumber(trueOrFalse) === 0) { + return true; + } else if (convertStringToNumber(trueOrFalse) == 1) { + return false; + } + } + convertStringToNumber(trueOrFalse) { + if (trueOrFalse === "true") { + return 0; + } else if (trueOrFalse === "false") { + return true * 69 - 1 - false * 69 * 420 - 69 + 2; + } + } + trueOrFalse() { + return this.convertNumberToBoolean(trueOrFalse); + } + } + + let objectWhichWeKnowIsTrue = new trueOrFalseObject("true"); + + function checkIfTrueOrFalse(objectToCheckIfTrueOrFalse) { + if (objectToCheckIfTrueOrFalse === objectWhichWeKnowIsTrue.trueOrFalse) { + return objectWhichWeKnowIsTrue.trueOrFalse; + console.log( + "Successfully checked if the object is true or false. Result: the object is true." + ); + // TODO: fix text not console logging + } else { + objectWhichWeKnowIsTrue = new trueOrFalseObject("false"); + if (objectToCheckIfTrueOrFalse === objectWhichWeKnowIsTrue.trueOrFalse) { + return objectWhichWeKnowIsTrue.trueOrFalse; + console.log( + "Successfully checked if the object is true or false. Result: the object is false." + ); + // TODO: fix text not console logging + } else { + // something went horribly wrong + } + objectWhichWeKnowIsTrue = new trueOrFalseObject("true"); + } + } + + const isTrueTrueOrFalse = checkIfTrueOrFalse("true"); + const isfalseTrueOrFalse = checkIfTrueOrFalse("false"); + + const trueOrFalseJSON = { + true: isTrueTrueOrFalse, + false: isfalseTrueOrFalse, + }; + + return trueOrFalseJSON.true +} + +console.log(returnTrue()) +``` diff --git a/locales/en_US.json b/locales/en_US.json index 936f6e7..1824f8b 100644 --- a/locales/en_US.json +++ b/locales/en_US.json @@ -7,7 +7,6 @@ "progress": "Progress", "blog": "Blog", "account": "Account", - "donate": "Donate", "accountWidget": { "settings": "Settings", "logout": "Logout" @@ -238,7 +237,6 @@ "publishedOn": "on" }, "account": { - "account": "Account", "loginForm": { "login": "Login", "register": "Register", @@ -256,9 +254,7 @@ "downloadFiles": "Download account files", "downloadFilesDescription": "(will not work on Nintendo Network)", "upgrade": "Upgrade account", - "unavailable": "Unavailable", "settingCards": { - "userSettings": "User settings", "profile": "Profile", "nickname": "Nickname", "birthDate": "Birth date", @@ -284,10 +280,7 @@ "linkDiscord": "Link Discord account", "newsletter": "Newsletter", "newsletterPrompt": "Receive project updates via email (you can opt-out at any time)", - "passwordPrompt": "Enter your PNID password to download Cemu files", - "no_signins_notice": "Sign in history not currently tracked. Check back again later!", - "no_newsletter_notice": "Newsletter not currently available. Check back again later", - "no_edit_from_dashboard": "Editing PNID settings from user dashboard is currently unavailable. Please update user settings from your linked game console" + "passwordPrompt": "Enter your PNID password to download Cemu files" } }, "accountLevel": [ @@ -337,26 +330,10 @@ "caption": "Search for it here" } ] - }, - "search": { - "title": "Got an error code?", - "caption": "Type it in the box below to get information on your issue!", - "label": "Error code", - "no_match": "No matches found" - }, - "sidebar": { - "getting_started": "Getting started", - "welcome": "Welcome", - "install_extended": "Install Pretendo", - "install": "Install", - "search": "Search", - "juxt_err": "Error codes - Juxt" - } }, "modals": { "cancel": "Cancel", - "confirm": "Confirm", - "close": "Close" + "confirm": "Confirm" } } diff --git a/src/routes/account.js b/src/routes/account.js index fb5f8df..166e185 100644 --- a/src/routes/account.js +++ b/src/routes/account.js @@ -70,11 +70,7 @@ router.get('/', requireLoginMiddleware, async (request, response) => { }); router.get('/login', async (request, response) => { - const renderData = { - error: request.cookies.error_message - }; - - response.render('account/login', renderData); + response.render('account/login'); }); router.post('/login', async (request, response) => { @@ -101,7 +97,6 @@ router.get('/register', async (request, response) => { email: request.cookies.email, username: request.cookies.username, mii_name: request.cookies.mii_name, - error: request.cookies.error_message }; response.clearCookie('email', { domain: '.pretendo.network' }); diff --git a/src/server.js b/src/server.js index c26f332..940ed15 100644 --- a/src/server.js +++ b/src/server.js @@ -12,6 +12,7 @@ const database = require('./database'); const util = require('./util'); const logger = require('./logger'); const config = require('../config.json'); +const defaultLocale = require('../locales/en_US.json'); const { http: { port } } = config; const app = express(); @@ -136,6 +137,56 @@ app.engine('handlebars', handlebars({ neq(value1, value2) { return value1 !== value2; }, + times(n, block) { + let accum = ''; + for(let i = 0; i < n; i++) { + accum += block.fn(i); + } + return accum; + }, + localeHelper(locale, propString, propVar, extra) { + /* + locale: the json locale object + propString: the "path" to the property to get (e.g. "faq.title") + propVar: the dynamic property name to get after the "path" (e.g. localeHelper locale "account.level" would result in ) + e.g. localeHelper locale "account.test" "account.level" would result in locale.account.test[account.level] + */ + + let value = locale; + const props = propString.split('.'); + + if ( typeof propVar === 'string' || propVar instanceof String || + typeof propVar === 'number' || propVar instanceof Number ) { + props.push(propVar); + } + + function getPropFromLocale(value, props) { + for (const p of props) { + value = value[p]; + } + + return value; + } + + // fall back to english if the prop doesn't exist in the current locale + try { + value = getPropFromLocale(value, props); + } catch (e) { + value = defaultLocale; + try { + value = getPropFromLocale(value, props); + } catch (e) { + logger.error(`Could not find locale property ${props.join('.')}`); + } + } + + // TODO: Make this more dynamic + if (extra) { + value = value[extra]; + } + + return value; + }, slug(string) { return string.toLowerCase().replaceAll(/ /g, '-'); } diff --git a/src/util.js b/src/util.js index 87149b4..6598b31 100644 --- a/src/util.js +++ b/src/util.js @@ -6,14 +6,11 @@ const Stripe = require('stripe'); const { marked } = require('marked'); const { REST: DiscordRest } = require('@discordjs/rest'); const { Routes: DiscordRoutes } = require('discord-api-types/v10'); -const merge = require('lodash.merge'); - const mailer = require('./mailer'); const database = require('./database'); const logger = require('./logger'); - const config = require('../config.json'); -const baseLocale = require(`${__dirname}/../locales/en_US.json`); + const discordRest = new DiscordRest({ version: '10' }).setToken(config.discord.bot_token); const stripe = new Stripe(config.stripe.secret_key); @@ -26,15 +23,12 @@ function getLocale(language, region) { const path = `${__dirname}/../locales/${language}_${region}.json`; if (fs.pathExistsSync(path)) { - const selectedLocale = require(path); - const finalLocale = merge(baseLocale, selectedLocale); - - return finalLocale; + return require(path); } logger.warn(`Could not find locale ${language}_${region}! Loading en_US`); - return baseLocale; + return require(`${__dirname}/../locales/en_US.json`); } function getRawDocs(locale, subpath, pageName) { diff --git a/views/account/account.handlebars b/views/account/account.handlebars index 230d70c..2ffe7f6 100644 --- a/views/account/account.handlebars +++ b/views/account/account.handlebars @@ -16,29 +16,29 @@

{{tierName}}

{{else}} {{#if (neq account.access_level -1)}} -

{{ lookup locale.account.accountLevel account.access_level }}

+

{{ localeHelper locale "account.accountLevel" account.access_level }}

{{else}} -

{{ locale.account.banned }}

+

{{ localeHelper locale "account.banned" }}

{{/if}} {{/if}}
-

{{ locale.account.settings.settingCards.userSettings }}

+

User settings

-

{{ locale.account.settings.settingCards.profile }}

+

{{ localeHelper locale "account.settings.settingCards.profile" }}

@@ -46,30 +46,30 @@
  • -

    {{ locale.account.settings.settingCards.nickname }}

    +

    {{ localeHelper locale "account.settings.settingCards.nickname" }}

    {{account.mii.name}}

  • -

    {{ locale.account.settings.settingCards.birthDate }}

    +

    {{ localeHelper locale "account.settings.settingCards.birthDate" }}

    {{account.birthdate}}

  • -

    {{ locale.account.settings.settingCards.gender }}

    +

    {{ localeHelper locale "account.settings.settingCards.gender" }}

    {{account.gender}}

  • -

    {{ locale.account.settings.settingCards.country }}

    +

    {{ localeHelper locale "account.settings.settingCards.country" }}

    {{account.country}}

  • -

    {{ locale.account.settings.settingCards.timezone }}

    +

    {{ localeHelper locale "account.settings.settingCards.timezone" }}

    {{account.timezone.name}}

-

{{ locale.account.settings.settingCards.serverEnv }}

+

{{ localeHelper locale "account.settings.settingCards.serverEnv" }}

@@ -82,7 +82,7 @@ -

{{ locale.account.settings.settingCards.production }}

+

{{ localeHelper locale "account.settings.settingCards.production" }}

{{#if isTester}} @@ -90,21 +90,21 @@ -

{{ locale.account.settings.settingCards.beta }}

+

{{ localeHelper locale "account.settings.settingCards.beta" }}

{{/if}}
{{#unless isTester}} -

{{{ locale.account.settings.settingCards.upgradePrompt }}}

+

{{{ localeHelper locale "account.settings.settingCards.upgradePrompt" }}}

{{else}} -

{{ locale.account.settings.settingCards.hasAccessPrompt }}

+

{{ localeHelper locale "account.settings.settingCards.hasAccessPrompt" }}

{{/unless}}
-

{{ locale.account.settings.settingCards.signInSecurity }}

+

{{ localeHelper locale "account.settings.settingCards.signInSecurity" }}

-

{{ locale.account.account }}

+

Account

@@ -112,20 +112,20 @@
  • -

    {{ locale.account.settings.settingCards.email }}

    +

    {{ localeHelper locale "account.settings.settingCards.email" }}

    {{account.email.address}}

  • -

    {{ locale.account.settings.settingCards.password }}

    +

    {{ localeHelper locale "account.settings.settingCards.password" }}

    ●●●●●●●●

-

{{ locale.account.settings.settingCards.passwordResetNotice }}

+

{{ localeHelper locale "account.settings.settingCards.passwordResetNotice" }}

-

{{ locale.account.settings.settingCards.otherSettings }}

+

{{ localeHelper locale "account.settings.settingCards.otherSettings" }}

-

{{ locale.account.settings.settingCards.discord }}

+

{{ localeHelper locale "account.settings.settingCards.discord" }}

{{#if discordUser}} -

{{ locale.account.settings.settingCards.connectedToDiscord }} {{ discordUser.username }}#{{ discordUser.discriminator }}

+

{{ localeHelper locale "account.settings.settingCards.connectedToDiscord" }} {{ discordUser.username }}#{{ discordUser.discriminator }}

- + {{else}} -

{{ locale.account.settings.settingCards.noDiscordLinked }} {{ locale.account.settings.settingCards.linkDiscord }}

+

{{ localeHelper locale "account.settings.settingCards.noDiscordLinked" }} {{ localeHelper locale "account.settings.settingCards.linkDiscord" }}

{{/if}}
-

{{ locale.account.settings.settingCards.newsletter }}

-

{{ locale.account.settings.settingCards.no_newsletter_notice }}

+

{{ localeHelper locale "account.settings.settingCards.newsletter" }}

+

Newsletter not currently available. Check back again later

@@ -185,22 +185,23 @@ + diff --git a/views/account/login.handlebars b/views/account/login.handlebars index 6ae3aa3..7664ed6 100644 --- a/views/account/login.handlebars +++ b/views/account/login.handlebars @@ -6,22 +6,22 @@ diff --git a/views/account/register.handlebars b/views/account/register.handlebars index 0c8b726..8419bad 100644 --- a/views/account/register.handlebars +++ b/views/account/register.handlebars @@ -7,33 +7,33 @@ diff --git a/views/account/upgrade.handlebars b/views/account/upgrade.handlebars index 5ef9a07..d353629 100644 --- a/views/account/upgrade.handlebars +++ b/views/account/upgrade.handlebars @@ -2,7 +2,7 @@
- {{ locale.upgrade.back }} + {{ localeHelper locale "upgrade.back" }}

- {{this.price}} / {{ locale.upgrade.month }} + {{this.price}} / {{ localeHelper locale "upgrade.month" }}

{{/each}}
- - + +
diff --git a/views/blog/blog.handlebars b/views/blog/blog.handlebars index ee03b0a..d5056e9 100644 --- a/views/blog/blog.handlebars +++ b/views/blog/blog.handlebars @@ -7,8 +7,8 @@
-

{{ locale.blogPage.title }}

-

{{{ locale.blogPage.description }}}

+

{{ localeHelper locale "blogPage.title" }}

+

{{{ localeHelper locale "blogPage.description" }}}

@@ -18,12 +18,12 @@

{{{ this.postInfo.title }}}

{{{ this.postInfo.caption }}}

- {{ ../locale.blogPage.published }} + {{ localeHelper ../locale "blogPage.published" }}
{{{ this.postInfo.author }}}
- {{ ../locale.blogPage.publishedOn }} + {{ localeHelper ../locale "blogPage.publishedOn" }} {{{ this.postInfo.date }}}
diff --git a/views/blog/blogpost.handlebars b/views/blog/blogpost.handlebars index 21ac56b..dfb61ec 100644 --- a/views/blog/blogpost.handlebars +++ b/views/blog/blogpost.handlebars @@ -9,12 +9,12 @@

{{{ postInfo.title }}}

- {{ locale.blogPage.published }} + {{ localeHelper locale "blogPage.published" }}
{{ postInfo.author }} {{{ postInfo.author }}}
- {{ locale.blogPage.publishedOn }} + {{ localeHelper locale "blogPage.publishedOn" }} {{{ postInfo.date }}}
diff --git a/views/docs/docs.handlebars b/views/docs/docs.handlebars index b080960..ec5394c 100644 --- a/views/docs/docs.handlebars +++ b/views/docs/docs.handlebars @@ -38,9 +38,15 @@
- +
+ Note! +
+ Pretendo Network is currently in closed beta! The servers are only accessible to testers. To become a tester, + upgrade your PNID here +
+ {{#if missingInLocale}} -

{{ locale.docs.missingInLocale }}

+

{{ localeHelper locale "docs.missingInLocale" }}

{{/if}} {{{ content }}} diff --git a/views/docs/search.handlebars b/views/docs/search.handlebars index b05907a..339a4a2 100644 --- a/views/docs/search.handlebars +++ b/views/docs/search.handlebars @@ -39,9 +39,9 @@