transition from parchment to downloads
This commit is contained in:
0
db/forms.js
Normal file
0
db/forms.js
Normal file
@@ -2,7 +2,7 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Downloads</title>
|
<title>Parchment</title>
|
||||||
<link rel="icon" href="Quill.png">
|
<link rel="icon" href="Quill.png">
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
@@ -25,6 +25,6 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="draggable"></div>
|
<div class="draggable"></div>
|
||||||
<webview src="http://localhost:3020" style="width:100vw; height:100vh;"></webview>
|
<webview src="http://localhost:80" style="width:100vw; height:100vh;"></webview>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -19,13 +19,15 @@ class Server {
|
|||||||
UIPath = path.join(__dirname, '../ui')
|
UIPath = path.join(__dirname, '../ui')
|
||||||
|
|
||||||
registerRoutes(router) {
|
registerRoutes(router) {
|
||||||
router.get('/', this.index)
|
|
||||||
router.get('/*', this.get)
|
router.get('/*', this.get)
|
||||||
return router
|
return router
|
||||||
}
|
}
|
||||||
|
|
||||||
index = async (req, res) => {
|
index = async (req, res) => {
|
||||||
let filePath = path.join(this.UIPath, "index.html");
|
let filePath = path.join(this.UIPath, "index.html");
|
||||||
|
res.sendFile(filePath)
|
||||||
|
return
|
||||||
|
|
||||||
let html = await fs.readFile(filePath, 'utf-8');
|
let html = await fs.readFile(filePath, 'utf-8');
|
||||||
|
|
||||||
let downloads = await getAllDownloadsFiles()
|
let downloads = await getAllDownloadsFiles()
|
||||||
@@ -42,15 +44,16 @@ class Server {
|
|||||||
|
|
||||||
get = async (req, res) => {
|
get = async (req, res) => {
|
||||||
let url = req.url
|
let url = req.url
|
||||||
|
let filePath;
|
||||||
|
if(url.startsWith("/_")) {
|
||||||
|
filePath = path.join(this.UIPath, url);
|
||||||
|
} else if(url.includes("75820185")) {
|
||||||
|
filePath = path.join(this.UIPath, url.split("75820185")[1]);
|
||||||
|
} else {
|
||||||
|
filePath = path.join(this.UIPath, "index.html");
|
||||||
|
}
|
||||||
|
|
||||||
let filePath = path.join(this.UIPath, url);
|
res.sendFile(filePath);
|
||||||
|
|
||||||
res.sendFile(filePath, (err) => {
|
|
||||||
if (err) {
|
|
||||||
console.error(`Error serving ${filePath}:`, err);
|
|
||||||
res.status(err.status || 500).send('File not found or error serving file.');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logRequest(req, res, next) {
|
logRequest(req, res, next) {
|
||||||
@@ -93,7 +96,7 @@ class Server {
|
|||||||
|
|
||||||
const server = http.createServer(app);
|
const server = http.createServer(app);
|
||||||
initWebSocket(server);
|
initWebSocket(server);
|
||||||
const PORT = 3020;
|
const PORT = 80;
|
||||||
server.listen(PORT, () => {
|
server.listen(PORT, () => {
|
||||||
console.log("\n")
|
console.log("\n")
|
||||||
console.log(chalk.yellow("**************Downloads****************"))
|
console.log(chalk.yellow("**************Downloads****************"))
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -10,6 +10,7 @@
|
|||||||
--brown: #c6a476;
|
--brown: #c6a476;
|
||||||
--darkbrown: #60320c;
|
--darkbrown: #60320c;
|
||||||
--darkred: #7f0b09;
|
--darkred: #7f0b09;
|
||||||
|
--darkorange: #b15900;
|
||||||
--orange: #FE9201;
|
--orange: #FE9201;
|
||||||
--periwinkle: #655BAF;
|
--periwinkle: #655BAF;
|
||||||
|
|
||||||
|
|||||||
94
ui/components/DownloadsPanel.js
Normal file
94
ui/components/DownloadsPanel.js
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
class DownloadsPanel extends Shadow {
|
||||||
|
render() {
|
||||||
|
ZStack(() => {
|
||||||
|
input("", "60vw")
|
||||||
|
.backgroundColor("var(--accent3)")
|
||||||
|
.color("var(--accent)")
|
||||||
|
.border("none")
|
||||||
|
.borderTop("1px solid var(--accent)")
|
||||||
|
.borderBottom("1px solid var(--accent)")
|
||||||
|
.outline("0.5px solid black")
|
||||||
|
.borderRadius(7, px)
|
||||||
|
.transition("padding .2s")
|
||||||
|
.padding(0.5, em)
|
||||||
|
.position("absolute")
|
||||||
|
.x(50, vw).y(7, em)
|
||||||
|
.transform("translate(-50%, -50%)")
|
||||||
|
.onInput(() => {
|
||||||
|
console.log('typing')
|
||||||
|
})
|
||||||
|
.onFocus(function (focusing) {
|
||||||
|
if(focusing) {
|
||||||
|
this.style.padding = "1em"
|
||||||
|
this.style.borderColor = "var(--darkred)"
|
||||||
|
} else {
|
||||||
|
this.style.padding = "0.5em"
|
||||||
|
this.style.borderColor = "var(--accent)"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// VStack(() => {
|
||||||
|
// const json = this.getJSONData()
|
||||||
|
|
||||||
|
// p(json.length + " Entries")
|
||||||
|
// .marginBottom(2, em)
|
||||||
|
|
||||||
|
// // Split into two alternating columns
|
||||||
|
// const left = []
|
||||||
|
// const right = []
|
||||||
|
|
||||||
|
// for (let i = 0; i < 200; i++) {
|
||||||
|
// if (i % 2 === 0) {
|
||||||
|
// left.push(json[i])
|
||||||
|
// } else {
|
||||||
|
// right.push(json[i])
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// console.log(left)
|
||||||
|
// HStack(() => {
|
||||||
|
// // LEFT COLUMN
|
||||||
|
// VStack(() => {
|
||||||
|
// for (let item of left) {
|
||||||
|
// p(item.name)
|
||||||
|
// .marginLeft(0, em)
|
||||||
|
// .marginBottom(0.1, em)
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
|
||||||
|
// // RIGHT COLUMN
|
||||||
|
// VStack(() => {
|
||||||
|
// for (let item of right) {
|
||||||
|
// p(item.name)
|
||||||
|
// .marginLeft(0, em)
|
||||||
|
// .marginBottom(0.1, em)
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// .marginLeft(3, em) // spacing between columns
|
||||||
|
// })
|
||||||
|
// })
|
||||||
|
// .paddingLeft(5, em)
|
||||||
|
// .paddingTop(10, em)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
getJSONData() {
|
||||||
|
const script = document.getElementById('jsonData');
|
||||||
|
if (!script) {
|
||||||
|
console.warn('initial-data script not found');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// script.textContent is the raw JSON string
|
||||||
|
const data = JSON.parse(script.textContent);
|
||||||
|
console.log(data)
|
||||||
|
return data;
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Failed to parse initial-data JSON:', err);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
register(DownloadsPanel)
|
||||||
@@ -1,48 +1,22 @@
|
|||||||
|
import "./NavMenu.js"
|
||||||
|
import "./HomePanel.js"
|
||||||
|
import "./DownloadsPanel.js"
|
||||||
|
|
||||||
class Home extends Shadow {
|
class Home extends Shadow {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
ZStack(() => {
|
ZStack(() => {
|
||||||
input("", "60vw")
|
|
||||||
.backgroundColor("var(--accent3)")
|
|
||||||
.color("var(--accent)")
|
|
||||||
.border("none")
|
|
||||||
.borderTop("1px solid var(--accent)")
|
|
||||||
.borderBottom("1px solid var(--accent)")
|
|
||||||
.outline("0.5px solid black")
|
|
||||||
.borderRadius(7, px)
|
|
||||||
.transition("padding .2s")
|
|
||||||
.padding(0.5, em)
|
|
||||||
.position("absolute")
|
|
||||||
.x(50, vw).y(7, em)
|
|
||||||
.transform("translate(-50%, -50%)")
|
|
||||||
.onInput(() => {
|
|
||||||
console.log('typing')
|
|
||||||
})
|
|
||||||
.onFocus(function (focusing) {
|
|
||||||
if(focusing) {
|
|
||||||
this.style.padding = "1em"
|
|
||||||
this.style.borderColor = "var(--darkred)"
|
|
||||||
} else {
|
|
||||||
this.style.padding = "0.5em"
|
|
||||||
this.style.borderColor = "var(--accent)"
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
VStack(() => {
|
|
||||||
let json = this.getJSONData()
|
|
||||||
p(json.length + " Entries")
|
|
||||||
.marginBottom(2, em)
|
|
||||||
|
|
||||||
for(let i=0; i<100; i++) {
|
NavMenu()
|
||||||
p(json[i].name)
|
|
||||||
.marginLeft(0, em)
|
switch(window.location.pathname) {
|
||||||
.marginBottom(0.1, em)
|
case "/":
|
||||||
}
|
HomePanel()
|
||||||
})
|
break;
|
||||||
.paddingLeft(5, em)
|
case "/downloads":
|
||||||
.paddingTop(10, em)
|
DownloadsPanel()
|
||||||
|
break;
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.backgroundColor("var(--main)")
|
.backgroundColor("var(--main)")
|
||||||
.display("block")
|
.display("block")
|
||||||
@@ -52,24 +26,10 @@ class Home extends Shadow {
|
|||||||
.onAppear(() => {
|
.onAppear(() => {
|
||||||
document.body.style.backgroundColor = "var(--main)"
|
document.body.style.backgroundColor = "var(--main)"
|
||||||
})
|
})
|
||||||
}
|
.onNavigate(() => {
|
||||||
|
console.log("navved")
|
||||||
getJSONData() {
|
this.rerender()
|
||||||
const script = document.getElementById('jsonData');
|
})
|
||||||
if (!script) {
|
|
||||||
console.warn('initial-data script not found');
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
// script.textContent is the raw JSON string
|
|
||||||
const data = JSON.parse(script.textContent);
|
|
||||||
console.log(data)
|
|
||||||
return data;
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Failed to parse initial-data JSON:', err);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
7
ui/components/HomePanel.js
Normal file
7
ui/components/HomePanel.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
class HomePanel extends Shadow {
|
||||||
|
render() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
register(HomePanel)
|
||||||
37
ui/components/NavMenu.js
Normal file
37
ui/components/NavMenu.js
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
class NavMenu extends Shadow {
|
||||||
|
|
||||||
|
NavButton(text) {
|
||||||
|
return p(text)
|
||||||
|
.cursor("default")
|
||||||
|
.onAppear(function () {
|
||||||
|
console.log(window.location.pathname, "/" + this.innerText.toLowerCase())
|
||||||
|
if(window.location.pathname === ("/" + this.innerText.toLowerCase())) {
|
||||||
|
this.style.textDecoration = "underline"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.onHover(function (hovering) {
|
||||||
|
if(hovering) {
|
||||||
|
this.style.textDecoration = "underline"
|
||||||
|
} else {
|
||||||
|
this.style.textDecoration = ""
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.onClick(function (done) {
|
||||||
|
if(done) {
|
||||||
|
window.navigateTo(this.innerText === "Home" ? "/" : this.innerText.toLowerCase())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
HStack(() => {
|
||||||
|
this.NavButton("Home")
|
||||||
|
this.NavButton("Downloads")
|
||||||
|
})
|
||||||
|
.gap(2, em)
|
||||||
|
.x(50, vw).y(5, vh)
|
||||||
|
.center()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
register(NavMenu)
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>Downloads</title>
|
<title>Parchment</title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<link rel="icon" href="/_/icons/logo.png">
|
<link rel="icon" href="/_/icons/logo.png">
|
||||||
<link rel="stylesheet" href="/_/code/shared.css"></script>
|
<link rel="stylesheet" href="/_/code/shared.css"></script>
|
||||||
<script src="/_/code/quill.js"></script>
|
<script src="/_/code/quill.js"></script>
|
||||||
<script type="module" src="/index.js"></script>
|
<script type="module" src="/75820185/index.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body style="margin: 0px;">
|
<body style="margin: 0px;">
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user