add zqdgr
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,4 +1,6 @@
|
||||
passport
|
||||
.env
|
||||
passport.db
|
||||
public/uploads/
|
||||
public/uploads/
|
||||
zqdgr
|
||||
assets/tailwind.css
|
||||
@@ -8,6 +8,7 @@ Passport is a simple, fast, and lightweight web dashboard/new tab replacement.
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- [ZQDGR](https://github.com/juls0730/zqdgr)
|
||||
- [Go](https://go.dev/doc/install)
|
||||
- [sqlite3](https://www.sqlite.org/download.html)
|
||||
- [TailwdinCSS CLI](https://github.com/tailwindlabs/tailwindcss/releases/latest)
|
||||
|
||||
26
main.go
26
main.go
@@ -40,6 +40,28 @@ var viewsFS embed.FS
|
||||
//go:embed assets/**
|
||||
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 {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
@@ -483,6 +505,10 @@ func main() {
|
||||
return string(css)
|
||||
})
|
||||
|
||||
engine.AddFunc("devContent", func() string {
|
||||
return devContent
|
||||
})
|
||||
|
||||
router := fiber.New(fiber.Config{
|
||||
Views: engine,
|
||||
})
|
||||
|
||||
8
prod.go
Normal file
8
prod.go
Normal file
@@ -0,0 +1,8 @@
|
||||
//go:build prod
|
||||
// +build prod
|
||||
|
||||
package main
|
||||
|
||||
func init() {
|
||||
devContent = ``
|
||||
}
|
||||
@@ -12,5 +12,5 @@
|
||||
<body class="bg-[#151316] text-white">
|
||||
{{embed}}
|
||||
</body>
|
||||
|
||||
{{{devContent}}}
|
||||
</html>
|
||||
17
zqdgr.config.json
Normal file
17
zqdgr.config.json
Normal 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}"
|
||||
}
|
||||
Reference in New Issue
Block a user