From 42e1a65b43a4dabb5ea98daf977168be3b302fe2 Mon Sep 17 00:00:00 2001
From: gor_down <gor@lyricaltokarev.com>
Date: Mon, 5 May 2025 07:15:34 -0300
Subject: [PATCH] crear todos los paths dinamicamente para cada idioma

---
 src/router/indexRouter.js     |  4 ++--
 src/utils/createCommonPath.js | 12 +++++++++++-
 views/escudo.hbs              |  2 +-
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/router/indexRouter.js b/src/router/indexRouter.js
index d58ea74..fabd22f 100644
--- a/src/router/indexRouter.js
+++ b/src/router/indexRouter.js
@@ -6,6 +6,7 @@ const { dirname } = require('path');
 const thisDirectory = dirname(require.main.filename);
 const fs = require('fs');
 const makeRss = require('../utils/rss');
+const langs = ["es", "en"]
 
 function addPaths(path, renderParams = {}){
     let currentDefaultParams = {...renderParams}
@@ -42,7 +43,6 @@ function addPaths(path, renderParams = {}){
             }
             else{
                 if (file === 'partials' || file === 'layouts') return
-                
                 addPaths(path + file + '/', currentDefaultParams)
             }
         }
@@ -85,7 +85,7 @@ router.get('/update_log/rss', async (_req, res) => {
          rss.item({
             title: "Update #" + i,
             description: `${u.link && `<a href="${u.link}">`}${u.description}${u.link && `</a>`}`,
-            author: "Gor Down",
+            author: "Lyrical Tokarev",
             date: u.date
         })
     })
diff --git a/src/utils/createCommonPath.js b/src/utils/createCommonPath.js
index 3fd2b5f..0d571f3 100644
--- a/src/utils/createCommonPath.js
+++ b/src/utils/createCommonPath.js
@@ -1,6 +1,7 @@
 const { dirname } = require('path');
 const appDir = dirname(require.main.filename);
 const fs = require('fs')
+const langs = ["es", "en"]
 
 function createCommonPath(router, path, renderParams = {
 }, cb = () => {}){
@@ -28,7 +29,16 @@ function createCommonPath(router, path, renderParams = {
             ...fileGeneralParams
         }
     }
-    router.get('/' + path, async (req, res) => {
+    renderOptions.lang = "es"
+    createPath('/' + path, cb, renderOptions, router)
+    langs.forEach(l => {
+        renderOptions.lang = l
+        createPath('/' + l + "/" + path, cb, renderOptions, router)
+    })
+}
+
+async function createPath(path, cb, renderOptions, router){
+    router.get(path, async (req, res) => {
         const cb_params = await cb(req, res)
         renderOptions = {...renderOptions, ...cb_params}
         res.render(renderOptions.view, renderOptions)
diff --git a/views/escudo.hbs b/views/escudo.hbs
index 296b57b..d979feb 100644
--- a/views/escudo.hbs
+++ b/views/escudo.hbs
@@ -16,7 +16,7 @@
                                         <p>Blasonador: <a id="cidoku" href="http://cidoku.net">Cidoku</a></p>
                                     </td>
                                     <td valign="top">
-                                        <p>Armígero: <a href="http://lyricaltokarev.com"><span id="celeste">Gor Down</span></a></p>
+                                        <p>Armígero: <a href="http://lyricaltokarev.com"><span id="celeste">Lyrical Tokarev</span></a></p>
                                     </td>
                                     <td valign="top">
                                         <p>Otorgado el: 9 de marzo, 2025</p>