1
0
Fork 0

completed transition from web script to express proxy

This commit is contained in:
James Tomasino 2021-06-18 17:34:52 +00:00
parent b5f8a480f7
commit 37c618bd57
1 changed files with 29 additions and 1 deletions

View File

@ -121,8 +121,36 @@ app.get('/atom.xml', async function (req, res) {
res.render('raw', { content: content })
})
// Any link to a direct resource will show it
// Any link to a direct static resource will show it
app.use(express.static(path.join(__dirname, '/static')))
// Override default LICENSE display and format for cosmic styles
app.get('*/LICENSE', function(req, res){
let error = false
var file = path.join('/var/gopher/', decodeURIComponent(req.path));
fs.exists(file, function(exists) {
if (exists) {
const file = bufferFile('/var/gopher/' + decodeURIComponent(req.path))
const back = '<a href="/log"><span class="dim">&lt;&lt;</span> BACK TO RS001 LOG</a>'
const content = back + '\n\n' + file
res.setHeader('content-type', 'text/html')
res.render('basic', { content: content })
} else {
error = true
}
})
// If license isn't found, give the 404
if (error) {
const back = '<a href="/"><span class="dim">&lt;&lt;</span> BACK TO COSMIC VOYAGE</a>'
const error = 'Message not found. Please try again.'
const content = back + '\n\n' + error
res.status(404)
res.render('basic', { content: content })
}
})
// Any other gopher content directly linked will show as-is
app.use(express.static('/var/gopher'))
// Grab anything that's a .txt and wrap it in .html