mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Global site url source
This commit is contained in:
parent
61c71e6c8d
commit
d841e464f5
7 changed files with 37 additions and 17 deletions
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
const siteUrl = 'https://qmining.frylabs.net' // http(s)//asd.basd
|
let url = '' // http(s)//asd.basd
|
||||||
|
|
||||||
const express = require('express')
|
const express = require('express')
|
||||||
const bodyParser = require('body-parser')
|
const bodyParser = require('body-parser')
|
||||||
|
@ -49,7 +49,7 @@ app.use(bodyParser.json({
|
||||||
|
|
||||||
app.get('/', function (req, res) {
|
app.get('/', function (req, res) {
|
||||||
res.render('main/main', {
|
res.render('main/main', {
|
||||||
siteurl: siteUrl
|
siteurl: url
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -65,5 +65,8 @@ app.post('*', function (req, res) {
|
||||||
})
|
})
|
||||||
|
|
||||||
exports.app = app
|
exports.app = app
|
||||||
|
exports.setup = (x) => {
|
||||||
|
url = x.url
|
||||||
|
}
|
||||||
|
|
||||||
logger.Log('Main module started', logger.GetColor('yellow'))
|
logger.Log('Main module started', logger.GetColor('yellow'))
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
let url = ''
|
||||||
const express = require('express')
|
const express = require('express')
|
||||||
const app = express()
|
const app = express()
|
||||||
|
|
||||||
|
@ -26,17 +27,20 @@ const logger = require('../utils/logger.js')
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
|
|
||||||
app.get('/', function (req, res) {
|
app.get('/', function (req, res) {
|
||||||
res.redirect('https://qmining.frylabs.net' + req.url)
|
res.redirect(url + req.url)
|
||||||
})
|
})
|
||||||
|
|
||||||
app.get('*', function (req, res) {
|
app.get('*', function (req, res) {
|
||||||
res.redirect('https://qmining.frylabs.net' + req.url)
|
res.redirect(url + req.url)
|
||||||
})
|
})
|
||||||
|
|
||||||
app.post('*', function (req, res) {
|
app.post('*', function (req, res) {
|
||||||
res.redirect('https://qmining.frylabs.net' + req.url)
|
res.redirect(url + req.url)
|
||||||
})
|
})
|
||||||
|
|
||||||
exports.app = app
|
exports.app = app
|
||||||
|
exports.setup = (x) => {
|
||||||
|
url = x.url
|
||||||
|
}
|
||||||
|
|
||||||
logger.Log('Old module started', logger.GetColor('yellow'))
|
logger.Log('Old module started', logger.GetColor('yellow'))
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
const siteUrl = 'https://qmining.frylabs.net' // http(s)//asd.basd
|
let url = ''
|
||||||
|
|
||||||
const express = require('express')
|
const express = require('express')
|
||||||
const bodyParser = require('body-parser')
|
const bodyParser = require('body-parser')
|
||||||
|
@ -60,7 +60,7 @@ app.get('/', function (req, res) {
|
||||||
// req.hostname
|
// req.hostname
|
||||||
|
|
||||||
res.render('qmining/main', {
|
res.render('qmining/main', {
|
||||||
siteurl: siteUrl,
|
siteurl: url,
|
||||||
qa: actions.ProcessQA()
|
qa: actions.ProcessQA()
|
||||||
})
|
})
|
||||||
res.end()
|
res.end()
|
||||||
|
@ -97,7 +97,7 @@ app.get('/legacy', function (req, res) {
|
||||||
data: d,
|
data: d,
|
||||||
scount: scount,
|
scount: scount,
|
||||||
qcount: qcount,
|
qcount: qcount,
|
||||||
siteurl: siteUrl
|
siteurl: url
|
||||||
})
|
})
|
||||||
|
|
||||||
logger.LogReq(req)
|
logger.LogReq(req)
|
||||||
|
@ -154,7 +154,7 @@ app.get('/greasy', function (req, res) {
|
||||||
})
|
})
|
||||||
|
|
||||||
app.get('/install', function (req, res) {
|
app.get('/install', function (req, res) {
|
||||||
res.redirect('http://qmining.frylabs.net/moodle-test-userscript/stable.user.js')
|
res.redirect(url + '/moodle-test-userscript/stable.user.js')
|
||||||
res.end()
|
res.end()
|
||||||
logger.LogReq(req)
|
logger.LogReq(req)
|
||||||
})
|
})
|
||||||
|
@ -225,5 +225,8 @@ app.post('*', function (req, res) {
|
||||||
})
|
})
|
||||||
|
|
||||||
exports.app = app
|
exports.app = app
|
||||||
|
exports.setup = (x) => {
|
||||||
|
url = x.url
|
||||||
|
}
|
||||||
|
|
||||||
logger.Log('Qmining module started', logger.GetColor('yellow'))
|
logger.Log('Qmining module started', logger.GetColor('yellow'))
|
||||||
|
|
|
@ -23,6 +23,7 @@ const bodyParser = require('body-parser')
|
||||||
const busboy = require('connect-busboy')
|
const busboy = require('connect-busboy')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const app = express()
|
const app = express()
|
||||||
|
let url = ''
|
||||||
|
|
||||||
const logger = require('../utils/logger.js')
|
const logger = require('../utils/logger.js')
|
||||||
// const utils = require('../utils/utils.js')
|
// const utils = require('../utils/utils.js')
|
||||||
|
@ -91,7 +92,8 @@ app.get('/*', function (req, res) {
|
||||||
res.render('stuff/folders', {
|
res.render('stuff/folders', {
|
||||||
folders: f,
|
folders: f,
|
||||||
dirname: relPath,
|
dirname: relPath,
|
||||||
prevDir
|
prevDir,
|
||||||
|
url
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
let fileStream = fs.createReadStream(curr)
|
let fileStream = fs.createReadStream(curr)
|
||||||
|
@ -99,7 +101,8 @@ app.get('/*', function (req, res) {
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
res.render('stuff/nofile', {
|
res.render('stuff/nofile', {
|
||||||
missingFile: curr
|
missingFile: curr,
|
||||||
|
url
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -118,5 +121,8 @@ app.post('*', function (req, res) {
|
||||||
})
|
})
|
||||||
|
|
||||||
exports.app = app
|
exports.app = app
|
||||||
|
exports.setup = (x) => {
|
||||||
|
url = x.url
|
||||||
|
}
|
||||||
|
|
||||||
logger.Log('Stuff module started', logger.GetColor('yellow'))
|
logger.Log('Stuff module started', logger.GetColor('yellow'))
|
||||||
|
|
|
@ -68,7 +68,13 @@ const app = express()
|
||||||
Object.keys(modules).forEach(function (k, i) {
|
Object.keys(modules).forEach(function (k, i) {
|
||||||
let x = modules[k]
|
let x = modules[k]
|
||||||
try {
|
try {
|
||||||
x.app = require(x.path).app
|
let mod = require(x.path)
|
||||||
|
if (mod.setup) {
|
||||||
|
mod.setup({
|
||||||
|
url: 'http://' + x.urls[0] // TODO http https or neither
|
||||||
|
})
|
||||||
|
}
|
||||||
|
x.app = mod.app
|
||||||
x.urls.forEach((url) => {
|
x.urls.forEach((url) => {
|
||||||
app.use(vhost(url, x.app))
|
app.use(vhost(url, x.app))
|
||||||
})
|
})
|
||||||
|
|
|
@ -65,7 +65,7 @@
|
||||||
<%=dirname%>
|
<%=dirname%>
|
||||||
</h1>
|
</h1>
|
||||||
</center>
|
</center>
|
||||||
<a href="<%= "http://stuff.frylabs.net" + prevDir%>" > Up one level </a>
|
<a href="<%= url + prevDir%>" > Up one level </a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<table class="maintable">
|
<table class="maintable">
|
||||||
|
@ -75,7 +75,7 @@
|
||||||
<button class="butt">
|
<button class="butt">
|
||||||
<table class="subtable">
|
<table class="subtable">
|
||||||
<td style='width:30%;'>
|
<td style='width:30%;'>
|
||||||
<a href="<%= "http://stuff.frylabs.net" + folders[i].path%>"> <%=folders[i].name %> </a>
|
<a href="<%= url + folders[i].path%>"> <%=folders[i].name %> </a>
|
||||||
</td>
|
</td>
|
||||||
<td style='width:30%;'>
|
<td style='width:30%;'>
|
||||||
<%=folders[i].path %>
|
<%=folders[i].path %>
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
<body bgcolor="#212127">
|
<body bgcolor="#212127">
|
||||||
|
@ -58,7 +57,6 @@
|
||||||
.butt:hover {
|
.butt:hover {
|
||||||
background-color: #555;
|
background-color: #555;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<center>
|
<center>
|
||||||
|
@ -67,7 +65,7 @@
|
||||||
</br>
|
</br>
|
||||||
<%= missingFile %>
|
<%= missingFile %>
|
||||||
</br>
|
</br>
|
||||||
<a href="<%= "http://stuff.frylabs.net" %>" > Back to root </a>
|
<a href="<%= url %>" > Back to root </a>
|
||||||
</h1>
|
</h1>
|
||||||
</center>
|
</center>
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue