add zqdgr

This commit is contained in:
Zoe
2024-11-16 04:30:29 -06:00
parent a458d9ae8c
commit dc6c6d85bf
6 changed files with 56 additions and 2 deletions

2
.gitignore vendored
View File

@@ -2,3 +2,5 @@ passport
.env .env
passport.db passport.db
public/uploads/ public/uploads/
zqdgr
assets/tailwind.css

View File

@@ -8,6 +8,7 @@ Passport is a simple, fast, and lightweight web dashboard/new tab replacement.
### Prerequisites ### Prerequisites
- [ZQDGR](https://github.com/juls0730/zqdgr)
- [Go](https://go.dev/doc/install) - [Go](https://go.dev/doc/install)
- [sqlite3](https://www.sqlite.org/download.html) - [sqlite3](https://www.sqlite.org/download.html)
- [TailwdinCSS CLI](https://github.com/tailwindlabs/tailwindcss/releases/latest) - [TailwdinCSS CLI](https://github.com/tailwindlabs/tailwindcss/releases/latest)

26
main.go
View File

@@ -40,6 +40,28 @@ var viewsFS embed.FS
//go:embed assets/** //go:embed assets/**
var assetsFS embed.FS var assetsFS embed.FS
var devContent string = `<script>
let host = window.location.hostname;
const socket = new WebSocket('ws://' + host + ':2067/ws');
socket.addEventListener('message', (event) => {
if (event.data === 'refresh') {
async function testPage() {
try {
let res = await fetch(window.location.href)
} catch (error) {
console.error(error);
setTimeout(testPage, 300);
return;
}
window.location.reload();
}
testPage();
}
});
</script>`
type Category struct { type Category struct {
ID int64 `json:"id"` ID int64 `json:"id"`
Name string `json:"name"` Name string `json:"name"`
@@ -483,6 +505,10 @@ func main() {
return string(css) return string(css)
}) })
engine.AddFunc("devContent", func() string {
return devContent
})
router := fiber.New(fiber.Config{ router := fiber.New(fiber.Config{
Views: engine, Views: engine,
}) })

8
prod.go Normal file
View File

@@ -0,0 +1,8 @@
//go:build prod
// +build prod
package main
func init() {
devContent = ``
}

View File

@@ -12,5 +12,5 @@
<body class="bg-[#151316] text-white"> <body class="bg-[#151316] text-white">
{{embed}} {{embed}}
</body> </body>
{{{devContent}}}
</html> </html>

17
zqdgr.config.json Normal file
View File

@@ -0,0 +1,17 @@
{
"name": "passport",
"version": "0.0.1",
"description": "Passport is a simple, lightweight, and fast dashboard/new tab page for your browser.",
"author": "juls0730",
"license": "BSL-1.0",
"homepage": "https://github.com/juls0730/passport",
"repository": {
"type": "git",
"url": "https://github.com/juls0730/passport.git"
},
"scripts": {
"dev": "go generate; go run main.go",
"build": "go generate && go build -tags netgo,prod -o passport"
},
"pattern": "**/*.go,views/**/*.hbs,styles/**/*.css,assets/**/*.{svg,png,jpg,jpeg,webp,woff2,ttf,otf,eot,ico,gif,webp}"
}