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 webserver = express()
|
||||
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.get('/', (_req, res) => {
|
||||
//...
|
||||
// res.redirect('/public/pages/neocities-lyricaltokarev/index.html')
|
||||
res.redirect('/home')
|
||||
router.use('/:lang?/', (req, res, next) => {
|
||||
if (req.params.lang == global.default_lang) {
|
||||
const pathWithoutLang = req.originalUrl.replace(`/${global.default_lang}`, '');
|
||||
return res.redirect(pathWithoutLang);
|
||||
}
|
||||
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 = []
|
||||
|
||||
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"){
|
||||
return res.redirect('/home#visitor_table')
|
||||
return res.redirect(redirect_path)
|
||||
}
|
||||
const ip = req.header('x-forwarded-for') || req.connection.remoteAddress;
|
||||
if(recent_posters.some( poster => poster.ip === ip)){
|
||||
console.log("spammer, " + ip)
|
||||
return res.redirect('/home#visitor_table')
|
||||
return res.redirect(redirect_path)
|
||||
}
|
||||
recent_posters.push({
|
||||
ip,
|
||||
@ -74,10 +82,10 @@ router.post('/comment', (req, res) => {
|
||||
const comment = req.body.comment.replace(/"/g, '""');
|
||||
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 rss = makeRss('https://lyricaltokarev.com/update_log/rss', "Update Log")
|
||||
csvData.forEach((u, i) => {
|
||||
@ -105,10 +113,12 @@ setInterval(() => {
|
||||
}, 1000)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
addPaths(thisDirectory + '/views/')
|
||||
|
||||
|
||||
router.get('/:lang?', (req, res) => {
|
||||
res.redirect(req.body.langPath + 'home')
|
||||
})
|
||||
|
||||
|
||||
module.exports = router;
|
||||
|
@ -1,8 +1,7 @@
|
||||
const { dirname } = require('path');
|
||||
const appDir = dirname(require.main.filename);
|
||||
const fs = require('fs')
|
||||
const langs = ["en", "es", "jp"]
|
||||
const default_lang = "es"
|
||||
const {langs, default_lang} = global
|
||||
|
||||
function createCommonPath(router, path, renderParams = {
|
||||
}, cb = () => {}){
|
||||
|
@ -216,7 +216,7 @@
|
||||
</table>
|
||||
<br>
|
||||
<div>
|
||||
<form id="comment_form" method="post" action="/comment">
|
||||
<form id="comment_form" method="post" action="{{langPath}}/comment">
|
||||
<textarea placeholder="きき 機器 危機 聞き 気気 キキ 木木" name="comment"></textarea>
|
||||
<br>
|
||||
<br>
|
||||
|
Loading…
Reference in New Issue
Block a user