diff --git a/docs/en-US/installing-juxt.md b/docs/en-US/installing-juxt.md new file mode 100644 index 0000000..7f2e4db --- /dev/null +++ b/docs/en-US/installing-juxt.md @@ -0,0 +1,12 @@ +# Installing Juxt + +The first step to installing Juxt is playing a round of Among Us as an impostor. I promise it will all make sense ina second. + +``` +.    。    •   ゚  。   . +.      .     。   。 . +.   。      ඞ 。 .    •     • +゚   Red was not An Impostor.  。 . +'    1 Impostor remains     。 +゚   .   . ,    .  . +``` \ No newline at end of file diff --git a/docs/en-US/welcome.md b/docs/en-US/welcome.md new file mode 100644 index 0000000..1f0f132 --- /dev/null +++ b/docs/en-US/welcome.md @@ -0,0 +1,95 @@ +# Quick links + + + +# Other documentation + +We are a bunch of programmers spending our free time reverse engineering and coding game servers for 3ds and wiiu. + +We are a bunch of programmers spending our free time reverse engineering and coding game servers for 3ds and wiiu. + +We are a bunch of programmers spending our free time reverse engineering and coding game servers for 3ds and wiiu. + +```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/docs/it-IT/welcome.md b/docs/it-IT/welcome.md new file mode 100644 index 0000000..e7e6b22 --- /dev/null +++ b/docs/it-IT/welcome.md @@ -0,0 +1,95 @@ +# Link rapidi + + + +# 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/IT_it.json b/locales/IT_it.json index d560281..a4bb3ec 100644 --- a/locales/IT_it.json +++ b/locales/IT_it.json @@ -2,6 +2,7 @@ "nav": { "about": "Info", "faq": "FAQ", + "docs": "Documentazione", "credits": "Riconoscimenti", "progress": "Progresso", "blog": "Blog" @@ -173,5 +174,8 @@ "fileInput": "File da testare", "filePlaceholder": "https://il.link.di/un_file.json", "button": "Testa file" + }, + "docs": { + "missingInLocale": "Questa pagina non è disponibile nella tua lingua. Per favore, controlla la versione in inglese sotto." } } \ No newline at end of file diff --git a/locales/US_en.json b/locales/US_en.json index 8a3583b..2f28f14 100644 --- a/locales/US_en.json +++ b/locales/US_en.json @@ -173,5 +173,8 @@ "fileInput": "File to test", "filePlaceholder": "https://a.link.to/the_file.json", "button": "Test file" + }, + "docs": { + "missingInLocale": "This page is unavailable in your locale. Please check the English version below." } } \ No newline at end of file diff --git a/public/assets/css/documentation.css b/public/assets/css/documentation.css index b4d56d4..7f56e7f 100644 --- a/public/assets/css/documentation.css +++ b/public/assets/css/documentation.css @@ -1,10 +1,12 @@ -html, body { +html, +body { background: #131730; } a.logo-link { - margin:auto; + margin: auto; margin-left: 36px; height: 40px; + text-decoration: none; } header { width: calc(100% - 72px); @@ -15,7 +17,7 @@ header { header a.logo-link { display: none; } -header nav a:first-child { +header nav a:first-child { margin-left: -24px; } @@ -23,7 +25,7 @@ header nav a:first-child { display: grid; grid-template-columns: repeat(2, fit-content(100%)); grid-template-rows: repeat(2, fit-content(100%)); - min-height: 100%; + height: 100vh; } .docs-wrapper .sidebar { @@ -34,12 +36,13 @@ header nav a:first-child { background: #161931; max-height: calc(100vh - 69px); overflow-y: scroll; + min-height: 100%; } .docs-wrapper .sidebar .section { display: flex; flex-flow: column; width: 200px; - margin-left: 30px; + margin-left: 138px; margin-bottom: 72px; } .docs-wrapper .sidebar .section:first-child { @@ -146,7 +149,7 @@ header nav a:first-child { border: 3px solid var(--background); } .docs-wrapper .content pre code::-webkit-scrollbar-thumb { - border: 3px solid #0D0F20; + border: 3px solid #0d0f20; } .docs-wrapper .sidebar { scrollbar-width: thin; @@ -158,5 +161,61 @@ header nav a:first-child { } .docs-wrapper .content pre codear { scrollbar-width: thin; - scrollbar-color: var(--text-secondary-2) #0D0F20; + scrollbar-color: var(--text-secondary-2) #0d0f20; +} +.docs-wrapper .content .missing-in-locale-notice { + background: #252a51; + padding: 24px; + border-radius: 6px; +} + + +.input-wrapper { + display: flex; + margin-top: 8px; +} + +.localization-form input { + appearance: none; + -webkit-appearance: none; + border: 0; + font-family: Poppins, Arial, Helvetica, sans-serif; + font-size: 1rem; + background-color: var(--btn-secondary); + border: none; + border-radius: 4px 0 0 4px; + padding: 12px 24px; + color: var(--text-secondary); + width: 20px; + flex: 2 10%; +} + +.search input::placeholder { + color: var(--text-secondary-2); +} + +.search input:focus { + background-color: #fff; + color: var(--btn-secondary); + transition: 200ms; + outline: none; +} + +.search button { + appearance: none; + -webkit-appearance: none; + border: 0; + font-family: Poppins, Arial, Helvetica, sans-serif; + font-size: 1rem; + color: var(--text); + padding: 12px 36px; + background: var(--btn); + cursor: pointer; +} + +@media screen and (max-width: 1080px) { + .docs-wrapper .sidebar .section { + margin-left: 60px; + width: 184px; + } } diff --git a/public/assets/css/highlightjs.css b/public/assets/css/highlightjs.css index d52a4c9..e71ac73 100644 --- a/public/assets/css/highlightjs.css +++ b/public/assets/css/highlightjs.css @@ -1,7 +1,7 @@ pre code.hljs { display: block; overflow-x: auto; - padding: 12px 36px; + padding: 36px; border-radius: 10px; font-family: Poppins, Arial, Helvetica, sans-serif; } diff --git a/src/routers/docs.js b/src/routers/docs.js index 4e4999f..f8a9b7f 100644 --- a/src/routers/docs.js +++ b/src/routers/docs.js @@ -1,92 +1,85 @@ const { Router } = require('express'); const util = require('../util'); -const logger = require('../logger'); const router = new Router(); const fs = require('fs'); const path = require('path'); const marked = require('marked'); -const matter = require('gray-matter'); -/* -const postList = () => { - const files = fs.readdirSync('blogposts'); - // We get the info for each blogpost, ignoring the ones starting with _ - const posts = files - .filter(filename => !filename.startsWith('_')) - .filter(filename => filename.endsWith('.md')) // Ignores other files/folders - .map((filename) => { - const slug = filename.replace('.md', ''); - const rawPost = fs.readFileSync( - path.join('blogposts', `${filename}`), - 'utf-8' - ); - const { data: postInfo } = matter(rawPost); - return { - slug, - postInfo, - }; - }); +// Here we'll store the rendered markdown files for future requests +const cachedPages = {}; - posts.sort((a, b) => { - return new Date(b.postInfo.date) - new Date(a.postInfo.date); - }); - - return posts; -}; -*/ router.get('/', async (request, response) => { + response.redirect('/docs/welcome'); +}); +router.get('/search', async (request, response) => { const reqLocale = request.locale; const locale = util.getLocale(reqLocale.region, reqLocale.language); const localeString = reqLocale.toString(); - response.render('docs', { + response.render('docs/search', { layout: 'main', locale, localeString, + currentPage: request.params.slug, }); }); -/* -router.get('/:slug', async (request, response, next) => { +router.get('/:slug', async (request, response, next) => { const reqLocale = request.locale; const locale = util.getLocale(reqLocale.region, reqLocale.language); const localeString = reqLocale.toString(); - // Get the name of the post from the URL - const postName = request.params.slug; + // Get the name of the page from the URL + const pageName = request.params.slug; - // Get the markdown file corresponding to the post - let rawPost; - try { - rawPost = fs.readFileSync(path.join('blogposts', `${postName}.md`), 'utf-8'); - } catch(err) { - logger.error(err); + let markdownLocale = localeString; + let missingInLocale = false; + // Check if the MD file exists in the user's locale, if not try en-US and show notice, or finally log error and show 404. + if (fs.existsSync(path.join('docs', localeString, `${pageName}.md`))) { + null; + } else if (fs.existsSync(path.join('docs', 'en-US', `${pageName}.md`))) { + markdownLocale = 'en-US'; + missingInLocale = true; + } else { next(); return; } - // Convert the post info into JSON and separate it and the content - // eslint-disable-next-line prefer-const - let { data: postInfo, content } = matter(rawPost); - // Replace [yt-iframe](videoID) with the full '); + let content; + // If the page has already been rendered, use the cached version + if (cachedPages[markdownLocale]?.[pageName]) { + content = cachedPages[markdownLocale]?.[pageName]; + } else { + // Get the markdown file corresponding to the page. + content = fs.readFileSync(path.join('docs', markdownLocale, `${pageName}.md`), 'utf-8'); - // Convert the content into HTML - const htmlPost = marked(content); + // Replace [yt-iframe](videoID) with the full '); - response.render('blog/blogpost', { - layout: 'blog-opengraph', + // Convert the content into HTML + content = marked(content); + + // Push the content into the cache + if (!cachedPages[markdownLocale]) { + cachedPages[markdownLocale] = {}; + } + cachedPages[markdownLocale][pageName] = content; + } + + response.render('docs/docs', { + layout: 'main', locale, localeString, - postInfo, - htmlPost, + content, + currentPage: request.params.slug, + missingInLocale, }); }); -*/ + module.exports = router; diff --git a/views/docs.handlebars b/views/docs.handlebars deleted file mode 100644 index f0e298a..0000000 --- a/views/docs.handlebars +++ /dev/null @@ -1,136 +0,0 @@ - - -
- - - - - - - Pretendo - - - - - - {{> header}} - - {{> docs-sidebar}} - -
-
-

Quick links

- - -

Other documentation

-

We are a bunch of programmers spending our free time reverse engineering and coding game servers for 3ds and wiiu.

-

We are a bunch of programmers spending our free time reverse engineering and coding game servers for 3ds and wiiu.

-

We are a bunch of programmers spending our free time reverse engineering and coding game servers for 3ds and wiiu.

-
-                
-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/views/docs/docs.handlebars b/views/docs/docs.handlebars new file mode 100644 index 0000000..a0e5f68 --- /dev/null +++ b/views/docs/docs.handlebars @@ -0,0 +1,49 @@ + + +
+ + + + + + + Pretendo + + + + + + {{> header}} + + {{> docs-sidebar}} + +
+
+ {{#if missingInLocale}} +

{{locale.docs.missingInLocale}}

+ {{/if}} + + {{{ content }}} +
+
+
+ + + + + + diff --git a/views/docs/search.handlebars b/views/docs/search.handlebars new file mode 100644 index 0000000..7184a73 --- /dev/null +++ b/views/docs/search.handlebars @@ -0,0 +1,40 @@ + + +
+ + + + + + + Pretendo + + + + + + {{> header}} + + {{> docs-sidebar}} + +
+
+
+
+
+
+ diff --git a/views/partials/docs-sidebar.handlebars b/views/partials/docs-sidebar.handlebars index 55cfb9c..cd54be5 100644 --- a/views/partials/docs-sidebar.handlebars +++ b/views/partials/docs-sidebar.handlebars @@ -1,40 +1,50 @@ \ No newline at end of file + + + \ No newline at end of file