algo de las traducciones
This commit is contained in:
parent
149a746149
commit
1b46d9f396
3
index.js
3
index.js
@ -1,3 +1,6 @@
|
|||||||
|
global.langs = ["en", "es"]
|
||||||
|
global.default_lang = "es"
|
||||||
|
|
||||||
const express = require('express')
|
const express = require('express')
|
||||||
const webserver = express()
|
const webserver = express()
|
||||||
const port = 3003
|
const port = 3003
|
||||||
|
0
src/router/common_path_logic/update_log/rss.js
Normal file
0
src/router/common_path_logic/update_log/rss.js
Normal file
@ -48,24 +48,32 @@ function addPaths(path, renderParams = {}){
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
router.use('/:lang?/', (req, res, next) => {
|
||||||
router.get('/', (_req, res) => {
|
if (req.params.lang == global.default_lang) {
|
||||||
//...
|
const pathWithoutLang = req.originalUrl.replace(`/${global.default_lang}`, '');
|
||||||
// res.redirect('/public/pages/neocities-lyricaltokarev/index.html')
|
return res.redirect(pathWithoutLang);
|
||||||
res.redirect('/home')
|
}
|
||||||
|
const lang = req.params.lang ? req.params.lang : global.default_lang
|
||||||
|
if(lang !== global.default_lang && global.langs.includes(lang)){
|
||||||
|
req.body.langPath = '/' + lang + '/'
|
||||||
|
}else{
|
||||||
|
req.body.langPath = '/'
|
||||||
|
}
|
||||||
|
next()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
const recent_posters = []
|
const recent_posters = []
|
||||||
|
|
||||||
router.post('/comment', (req, res) => {
|
|
||||||
|
router.post('/:lang?/comment', (req, res) => {
|
||||||
|
const redirect_path = req.body.langPath + "home#visitor_table"
|
||||||
if (req.body.checkbox === "on"){
|
if (req.body.checkbox === "on"){
|
||||||
return res.redirect('/home#visitor_table')
|
return res.redirect(redirect_path)
|
||||||
}
|
}
|
||||||
const ip = req.header('x-forwarded-for') || req.connection.remoteAddress;
|
const ip = req.header('x-forwarded-for') || req.connection.remoteAddress;
|
||||||
if(recent_posters.some( poster => poster.ip === ip)){
|
if(recent_posters.some( poster => poster.ip === ip)){
|
||||||
console.log("spammer, " + ip)
|
console.log("spammer, " + ip)
|
||||||
return res.redirect('/home#visitor_table')
|
return res.redirect(redirect_path)
|
||||||
}
|
}
|
||||||
recent_posters.push({
|
recent_posters.push({
|
||||||
ip,
|
ip,
|
||||||
@ -74,10 +82,10 @@ router.post('/comment', (req, res) => {
|
|||||||
const comment = req.body.comment.replace(/"/g, '""');
|
const comment = req.body.comment.replace(/"/g, '""');
|
||||||
fs.appendFileSync(thisDirectory + "/public/dynamic/sync/comments.csv", `${Date.now()},"${comment}",,0` + "\n")
|
fs.appendFileSync(thisDirectory + "/public/dynamic/sync/comments.csv", `${Date.now()},"${comment}",,0` + "\n")
|
||||||
|
|
||||||
res.redirect('/home#visitor_table')
|
res.redirect(redirect_path)
|
||||||
})
|
})
|
||||||
|
|
||||||
router.get('/update_log/rss', async (_req, res) => {
|
router.get('/:lang?/update_log/rss', async (_req, res) => {
|
||||||
const csvData = await readCsv(thisDirectory + '/public/dynamic/sync/updates.csv')
|
const csvData = await readCsv(thisDirectory + '/public/dynamic/sync/updates.csv')
|
||||||
const rss = makeRss('https://lyricaltokarev.com/update_log/rss', "Update Log")
|
const rss = makeRss('https://lyricaltokarev.com/update_log/rss', "Update Log")
|
||||||
csvData.forEach((u, i) => {
|
csvData.forEach((u, i) => {
|
||||||
@ -105,10 +113,12 @@ setInterval(() => {
|
|||||||
}, 1000)
|
}, 1000)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
addPaths(thisDirectory + '/views/')
|
addPaths(thisDirectory + '/views/')
|
||||||
|
|
||||||
|
|
||||||
|
router.get('/:lang?', (req, res) => {
|
||||||
|
res.redirect(req.body.langPath + 'home')
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
const { dirname } = require('path');
|
const { dirname } = require('path');
|
||||||
const appDir = dirname(require.main.filename);
|
const appDir = dirname(require.main.filename);
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const langs = ["en", "es", "jp"]
|
const {langs, default_lang} = global
|
||||||
const default_lang = "es"
|
|
||||||
|
|
||||||
function createCommonPath(router, path, renderParams = {
|
function createCommonPath(router, path, renderParams = {
|
||||||
}, cb = () => {}){
|
}, cb = () => {}){
|
||||||
|
@ -216,7 +216,7 @@
|
|||||||
</table>
|
</table>
|
||||||
<br>
|
<br>
|
||||||
<div>
|
<div>
|
||||||
<form id="comment_form" method="post" action="/comment">
|
<form id="comment_form" method="post" action="{{langPath}}/comment">
|
||||||
<textarea placeholder="きき 機器 危機 聞き 気気 キキ 木木" name="comment"></textarea>
|
<textarea placeholder="きき 機器 危機 聞き 気気 キキ 木木" name="comment"></textarea>
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
|
Loading…
Reference in New Issue
Block a user