Skip to content

Commit 045b9f4

Browse files
authored
Merge pull request #1 from CodeShellDev/dev
Rework & Refactor
2 parents 837e309 + 319c414 commit 045b9f4

22 files changed

Lines changed: 1549 additions & 563 deletions

.github/templates/README.template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
WoL Redirect is a Docker Container with graphical interface, which allows users to wake up their services.
44
Integrates with all of the WoL Containers.
5-
5+
s
66
_Well, except for meteorite_
77

88
## Installation

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ FROM node:alpine
22

33
WORKDIR /app
44

5+
ENV NODE_ENV=production
6+
57
COPY . .
68

79
RUN npm install
810

9-
CMD ["npm", "start"]
11+
CMD ["npm", "start", "-s"]

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22

33
WoL Redirect is a Docker Container with graphical interface, which allows users to wake up their services.
44
Integrates with all of the WoL Containers.
5-
5+
s
66
_Well, except for meteorite_
77

88
## Installation
99

1010
Get the latest `docker-compose.yaml` file:
1111

1212
```yaml
13-
---
1413
services:
1514
wol:
1615
container_name: wol-client

docker-compose.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
---
21
services:
32
wol:
43
container_name: wol-client

package-lock.json

Lines changed: 143 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,33 @@
11
{
22
"name": "wol-redirect",
3-
"version": "1.0.0",
4-
"description": "A Redirect and WoL Service",
3+
"version": "none",
4+
"description": "",
5+
"homepage": "https://github.com/CodeShellDev/wol-redirect#readme",
6+
"bugs": {
7+
"url": "https://github.com/CodeShellDev/wol-redirect/issues"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/CodeShellDev/wol-redirect.git"
12+
},
13+
"license": "MIT",
14+
"author": "codeshelldev",
15+
"type": "module",
516
"main": "app.js",
617
"scripts": {
718
"test": "echo \"Error: no test specified\" && exit 1",
819
"start": "node ./src/app.js --silent"
920
},
10-
"author": "codeshell",
11-
"license": "MIT",
1221
"dependencies": {
22+
"connect-redis": "^9.0.0",
1323
"cookie-parser": "^1.4.7",
1424
"ejs": "^3.1.10",
1525
"express": "^4.21.1",
16-
"express-session": "^1.18.1",
26+
"express-session": "^1.18.2",
1727
"passport": "^0.7.0",
18-
"passport-oauth2": "^1.8.0"
28+
"passport-oauth2": "^1.8.0",
29+
"redis": "^5.10.0",
30+
"uuid": "^13.0.0",
31+
"ws": "^8.18.3"
1932
}
2033
}

public/js/theme.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const THEME_KEY = "theme"
2+
3+
export function setTheme(theme) {
4+
document.body.setAttribute("data-theme", theme)
5+
localStorage.setItem(THEME_KEY, theme)
6+
}
7+
8+
export function applyInitialTheme() {
9+
const saved = localStorage.getItem(THEME_KEY)
10+
const system = matchMedia("(prefers-color-scheme: dark)").matches
11+
const theme = saved || (system ? "dark" : "light")
12+
13+
document.documentElement.setAttribute("data-theme", theme)
14+
}
15+
16+
export function initToggle(query = ".theme-toggle") {
17+
const toggle = document.querySelector(query)
18+
if (!toggle) return
19+
20+
toggle.addEventListener("click", () => {
21+
const html = document.documentElement
22+
const next = html.getAttribute("data-theme") === "dark" ? "light" : "dark"
23+
24+
html.setAttribute("data-theme", next)
25+
localStorage.setItem(THEME_KEY, next)
26+
})
27+
}

public/js/user.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
export function getProfileColor(
2+
str,
3+
{ hues = [10, 40, 60, 90, 120, 150, 180, 200, 220, 250, 280, 310, 340] } = {}
4+
) {
5+
let hash = 0
6+
for (let i = 0; i < str.length; i++) {
7+
hash = str.charCodeAt(i) + ((hash << 5) - hash)
8+
}
9+
10+
const hue = hues[Math.abs(hash) % hues.length]
11+
12+
const saturation = 70
13+
const lightness = 60
14+
15+
return `hsl(${hue}, ${saturation}%, ${lightness}%)`
16+
}
17+
18+
export function setUser(userData, query = ".user .profile") {
19+
const userProfile = document.querySelector(query)
20+
21+
userProfile.textContent = userData.name.substring(0, 2).toUpperCase()
22+
userProfile.style.backgroundColor = getProfileColor(userData.name)
23+
}

0 commit comments

Comments
 (0)