More branding & yapping
This commit is contained in:
parent
6971adf579
commit
c17725e9b3
4 changed files with 50 additions and 8 deletions
16
index.js
16
index.js
|
@ -30,10 +30,6 @@ function humanFileSize(bytes, si = false, dp = 1) {
|
|||
return bytes.toFixed(dp) + ' ' + units[u];
|
||||
}
|
||||
|
||||
var baseHTML = fs.readFileSync(path.join(__dirname, 'resources/base.html')).toString()
|
||||
var baseStart = baseHTML.substring(0, baseHTML.indexOf('{CONTENT}'))
|
||||
var baseEnd = baseHTML.substring(baseHTML.indexOf('{CONTENT}') + 9, baseHTML.length)
|
||||
|
||||
if (!directory) {
|
||||
console.error("No directory specified! Please specify one using the environment variable FILES_DIR.")
|
||||
return
|
||||
|
@ -49,12 +45,22 @@ app.get("/*", (req, res) => {
|
|||
var file = req.params[0]
|
||||
var absPath = path.join(directory, file)
|
||||
|
||||
if (file != '') {
|
||||
var baseHTML = fs.readFileSync(path.join(__dirname, 'resources/base.html')).toString()
|
||||
} else {
|
||||
var baseHTML = fs.readFileSync(path.join(__dirname, 'resources/root.html')).toString()
|
||||
}
|
||||
|
||||
var baseStart = baseHTML.substring(0, baseHTML.indexOf('{CONTENT}'))
|
||||
var baseEnd = baseHTML.substring(baseHTML.indexOf('{CONTENT}') + 9, baseHTML.length)
|
||||
|
||||
res.setHeader('Content-Type', 'text/html')
|
||||
|
||||
res.setHeader("X-Accel-Buffering", "no")
|
||||
|
||||
try {
|
||||
var dirContents = fs.readdirSync(absPath)
|
||||
var dirStats = fs.statSync(absPath)
|
||||
} catch (error) {
|
||||
res.send(baseStart.replace("{TITLE}", "404: not found!") + "<h2>404: not found!</h2>" + baseEnd)
|
||||
return
|
||||
|
@ -62,6 +68,8 @@ app.get("/*", (req, res) => {
|
|||
|
||||
res.write(baseStart.replace("{TITLE}", '/' + file))
|
||||
|
||||
res.write(`<h3>${dirContents.length} Files</h3>`)
|
||||
|
||||
if (file != '') {
|
||||
res.write('<a href="../">Parent Directory</a><br>')
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"description": "A feature rich and customizable NodeJS program for easily displaying a directory on the web.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "node index.js"
|
||||
"start": "node index.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
|
@ -7,11 +8,16 @@
|
|||
|
||||
<link rel="stylesheet" href="https://violets-purgatory.dev/style.css">
|
||||
|
||||
|
||||
<title>{TITLE}</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<ul>
|
||||
{CONTENT}
|
||||
</ul>
|
||||
<div class="fadediv">
|
||||
<ul>
|
||||
{CONTENT}
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
28
resources/root.html
Normal file
28
resources/root.html
Normal file
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<link rel="stylesheet" href="https://violets-purgatory.dev/style.css">
|
||||
|
||||
<title>Violet's Clipdump</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Welcome to Violet's Clip dump</h1>
|
||||
<div class="fadediv">
|
||||
<p>Yes, you heard that right. Well its more like a File Share but "Clip dump" is still pretty accurate,
|
||||
and rolls off the tongue better.<br>
|
||||
Here you'll mainly find just clips of me playin games and stuff. Its not really something designed to be
|
||||
"looked through"
|
||||
but I decided why not. It's not very organized so be warned!</p>
|
||||
<ul>
|
||||
{CONTENT}
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in a new issue