Compare commits
8 Commits
a7d42f515d
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
27ae08690e
|
|||
|
cb4879b109
|
|||
|
77f2032faf
|
|||
|
f7bb39b266
|
|||
|
ab5337dc91
|
|||
|
095b35f410
|
|||
|
50546ae4d4
|
|||
|
2d34202c9e
|
+26
-15
@@ -7,15 +7,13 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/alexedwards/scs/v2"
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
)
|
)
|
||||||
|
|
||||||
func handler(writer http.ResponseWriter, request *http.Request) {
|
var sessionManager *scs.SessionManager
|
||||||
templ := template.Must(template.ParseFiles("./web/dist/index.html"))
|
|
||||||
|
|
||||||
templ.Execute(writer, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
err := godotenv.Load()
|
err := godotenv.Load()
|
||||||
@@ -23,20 +21,27 @@ func main() {
|
|||||||
log.Fatal("Error loading .env file")
|
log.Fatal("Error loading .env file")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handle authentication
|
||||||
|
sessionManager = scs.New()
|
||||||
|
sessionManager.Lifetime = 24 * time.Hour
|
||||||
|
|
||||||
|
// handle frontend views
|
||||||
webDir := "./web/dist"
|
webDir := "./web/dist"
|
||||||
fs := http.FileServer(http.Dir(webDir))
|
fs := http.FileServer(http.Dir(webDir))
|
||||||
|
|
||||||
http.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) {
|
http.Handle("/", sessionManager.LoadAndSave(
|
||||||
if request.URL.Path != "/" {
|
http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
|
||||||
path := filepath.Join(webDir, filepath.Clean(request.URL.Path))
|
if request.URL.Path != "/" {
|
||||||
_, err := os.Stat(path)
|
path := filepath.Join(webDir, filepath.Clean(request.URL.Path))
|
||||||
if err == nil {
|
_, err := os.Stat(path)
|
||||||
fs.ServeHTTP(writer, request)
|
if err == nil {
|
||||||
return
|
fs.ServeHTTP(writer, request)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
handler(writer, request)
|
||||||
handler(writer, request)
|
}),
|
||||||
})
|
))
|
||||||
|
|
||||||
port := os.Getenv("HTTP_PORT")
|
port := os.Getenv("HTTP_PORT")
|
||||||
if port == "" {
|
if port == "" {
|
||||||
@@ -48,3 +53,9 @@ func main() {
|
|||||||
log.Fatalf("server error: %v", err)
|
log.Fatalf("server error: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func handler(writer http.ResponseWriter, request *http.Request) {
|
||||||
|
templ := template.Must(template.ParseFiles("./web/dist/index.html"))
|
||||||
|
|
||||||
|
templ.Execute(writer, nil)
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ module solopm.com/solopm-server
|
|||||||
go 1.26.3
|
go 1.26.3
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/alexedwards/scs/v2 v2.9.0 // indirect
|
||||||
github.com/golang-migrate/migrate/v4 v4.19.1 // indirect
|
github.com/golang-migrate/migrate/v4 v4.19.1 // indirect
|
||||||
github.com/joho/godotenv v1.5.1 // indirect
|
github.com/joho/godotenv v1.5.1 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
github.com/alexedwards/scs/v2 v2.9.0 h1:xa05mVpwTBm1iLeTMNFfAWpKUm4fXAW7CeAViqBVS90=
|
||||||
|
github.com/alexedwards/scs/v2 v2.9.0/go.mod h1:ToaROZxyKukJKT/xLcVQAChi5k6+Pn1Gvmdl7h3RRj8=
|
||||||
github.com/golang-migrate/migrate/v4 v4.19.1 h1:OCyb44lFuQfYXYLx1SCxPZQGU7mcaZ7gH9yH4jSFbBA=
|
github.com/golang-migrate/migrate/v4 v4.19.1 h1:OCyb44lFuQfYXYLx1SCxPZQGU7mcaZ7gH9yH4jSFbBA=
|
||||||
github.com/golang-migrate/migrate/v4 v4.19.1/go.mod h1:CTcgfjxhaUtsLipnLoQRWCrjYXycRz/g5+RWDuYgPrE=
|
github.com/golang-migrate/migrate/v4 v4.19.1/go.mod h1:CTcgfjxhaUtsLipnLoQRWCrjYXycRz/g5+RWDuYgPrE=
|
||||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ CREATE UNIQUE INDEX IF NOT EXISTS "idx_users_provider"
|
|||||||
INSERT INTO users
|
INSERT INTO users
|
||||||
(username,is_admin,name,email,avatar_url)
|
(username,is_admin,name,email,avatar_url)
|
||||||
VALUES
|
VALUES
|
||||||
('system', true, 'System User', 'system@localhost', '')
|
('system', true, 'System User', 'system@localhost', '/uploads/avatars/system.png')
|
||||||
;
|
;
|
||||||
-- -------------------------------------------------------------
|
-- -------------------------------------------------------------
|
||||||
|
|
||||||
@@ -38,6 +38,6 @@ VALUES
|
|||||||
INSERT INTO users
|
INSERT INTO users
|
||||||
(username,is_admin,name,email,avatar_url)
|
(username,is_admin,name,email,avatar_url)
|
||||||
VALUES
|
VALUES
|
||||||
('zombie', false, 'Zombie', 'zombie@localhost', '')
|
('zombie', false, 'Zombie', 'zombie@localhost', '/uploads/avatars/zombie.png')
|
||||||
;
|
;
|
||||||
-- -------------------------------------------------------------
|
-- -------------------------------------------------------------
|
||||||
|
|||||||
@@ -4,11 +4,12 @@
|
|||||||
|
|
||||||
<nav aria-label="breadcrumb">
|
<nav aria-label="breadcrumb">
|
||||||
<ol class="flex flex-wrap pt-1 mr-12 bg-transparent rounded-lg sm:mr-16">
|
<ol class="flex flex-wrap pt-1 mr-12 bg-transparent rounded-lg sm:mr-16">
|
||||||
<li class="text-sm leading-normal">
|
<li v-if="title !== 'Dashboard'" class="text-sm leading-normal">
|
||||||
<RouterLink class="opacity-50 text-slate-700" to="/">Pages</RouterLink>
|
<RouterLink class="opacity-50 text-slate-700" to="/dashboard">Dashboard</RouterLink>
|
||||||
</li>
|
</li>
|
||||||
<li
|
<li
|
||||||
class="text-sm pl-2 capitalize leading-normal text-slate-700 before:float-left before:pr-2 before:content-['/']"
|
class="text-sm capitalize leading-normal text-slate-700"
|
||||||
|
:class="title !== 'Dashboard' ? 'pl-2 before:float-left before:pr-2 before:content-[\'/\']' : ''"
|
||||||
aria-current="page"
|
aria-current="page"
|
||||||
>
|
>
|
||||||
{{ title }}
|
{{ title }}
|
||||||
|
|||||||
@@ -66,23 +66,6 @@
|
|||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mx-4 mt-4">
|
|
||||||
<div class="relative flex min-w-0 flex-col items-center break-words rounded-2xl border-0 bg-white bg-clip-border shadow-none">
|
|
||||||
<div class="mb-7.5 h-28 w-full overflow-hidden rounded-xl">
|
|
||||||
<div class="bg-gradient-to-tl from-slate-600 to-slate-300 h-full w-full"></div>
|
|
||||||
</div>
|
|
||||||
<div class="-mt-14 w-3/4 text-center">
|
|
||||||
<p class="mt-0 mb-4 font-semibold leading-tight text-xs">Need help?</p>
|
|
||||||
<a
|
|
||||||
href="#"
|
|
||||||
class="inline-block w-full px-8 py-2 mb-4 font-bold text-center text-black uppercase transition-all ease-in bg-white border-0 rounded-lg shadow-soft-md bg-150 leading-pro text-xs hover:shadow-soft-2xl hover:scale-102"
|
|
||||||
>
|
|
||||||
Documentation
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</aside>
|
</aside>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -8,25 +8,7 @@
|
|||||||
<div class="flex-auto p-4">
|
<div class="flex-auto p-4">
|
||||||
<div class="flex flex-row -mx-3">
|
<div class="flex flex-row -mx-3">
|
||||||
<div class="flex-none w-2/3 max-w-full px-3">
|
<div class="flex-none w-2/3 max-w-full px-3">
|
||||||
<p class="mb-0 font-sans font-semibold leading-normal text-sm">Projects</p>
|
<p class="mb-0 font-sans font-semibold leading-normal text-sm">Open Issues</p>
|
||||||
<h5 class="mb-0 font-bold">—</h5>
|
|
||||||
</div>
|
|
||||||
<div class="px-3 text-right basis-1/3">
|
|
||||||
<div class="inline-flex w-12 h-12 text-center rounded-lg items-center justify-center bg-gradient-to-tl from-purple-700 to-pink-500 shadow-soft-2xl">
|
|
||||||
<i class="fas fa-layer-group text-white text-lg relative"></i>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="w-full max-w-full px-3 mb-6 sm:w-1/2 sm:flex-none xl:mb-0 xl:w-1/4">
|
|
||||||
<div class="relative flex flex-col min-w-0 break-words bg-white shadow-soft-xl rounded-2xl bg-clip-border">
|
|
||||||
<div class="flex-auto p-4">
|
|
||||||
<div class="flex flex-row -mx-3">
|
|
||||||
<div class="flex-none w-2/3 max-w-full px-3">
|
|
||||||
<p class="mb-0 font-sans font-semibold leading-normal text-sm">Open Tasks</p>
|
|
||||||
<h5 class="mb-0 font-bold">—</h5>
|
<h5 class="mb-0 font-bold">—</h5>
|
||||||
</div>
|
</div>
|
||||||
<div class="px-3 text-right basis-1/3">
|
<div class="px-3 text-right basis-1/3">
|
||||||
@@ -75,23 +57,29 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
<div class="w-full max-w-full px-3 mb-6 sm:w-1/2 sm:flex-none xl:mb-0 xl:w-1/4">
|
||||||
|
<div class="relative flex flex-col min-w-0 break-words bg-white shadow-soft-xl rounded-2xl bg-clip-border">
|
||||||
<div class="flex flex-wrap mt-6 -mx-3">
|
<div class="flex-auto p-4">
|
||||||
|
<div class="flex flex-row -mx-3">
|
||||||
<div class="w-full max-w-full px-3 mt-0 lg:w-7/12 lg:flex-none">
|
<div class="flex-none w-2/3 max-w-full px-3">
|
||||||
<div class="relative flex flex-col min-w-0 break-words bg-white border-0 shadow-soft-xl rounded-2xl bg-clip-border">
|
<p class="mb-0 font-sans font-semibold leading-normal text-sm">Projects</p>
|
||||||
<div class="border-black/12.5 rounded-t-2xl border-b-0 border-solid p-6 pb-0">
|
<h5 class="mb-0 font-bold">—</h5>
|
||||||
<h6 class="capitalize">Recent Projects</h6>
|
</div>
|
||||||
<p class="text-sm leading-normal">Your active projects</p>
|
<div class="px-3 text-right basis-1/3">
|
||||||
</div>
|
<div class="inline-flex w-12 h-12 text-center rounded-lg items-center justify-center bg-gradient-to-tl from-purple-700 to-pink-500 shadow-soft-2xl">
|
||||||
<div class="flex-auto p-6 pt-4">
|
<i class="fas fa-layer-group text-white text-lg relative"></i>
|
||||||
<p class="text-sm text-slate-500 text-center py-8">No projects yet.</p>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="w-full max-w-full px-3 mt-4 lg:w-5/12 lg:flex-none lg:mt-0">
|
</div>
|
||||||
|
|
||||||
|
<div class="flex flex-wrap mt-6 -mx-3">
|
||||||
|
|
||||||
|
<div class="w-full max-w-full px-3 mt-4 lg:w-7/12 lg:flex-none lg:mt-0">
|
||||||
<div class="relative flex flex-col min-w-0 break-words bg-white border-0 shadow-soft-xl rounded-2xl bg-clip-border">
|
<div class="relative flex flex-col min-w-0 break-words bg-white border-0 shadow-soft-xl rounded-2xl bg-clip-border">
|
||||||
<div class="border-black/12.5 rounded-t-2xl border-b-0 border-solid p-6 pb-0">
|
<div class="border-black/12.5 rounded-t-2xl border-b-0 border-solid p-6 pb-0">
|
||||||
<h6 class="capitalize">Activity</h6>
|
<h6 class="capitalize">Activity</h6>
|
||||||
@@ -103,6 +91,18 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="w-full max-w-full px-3 mt-0 lg:w-5/12 lg:flex-none">
|
||||||
|
<div class="relative flex flex-col min-w-0 break-words bg-white border-0 shadow-soft-xl rounded-2xl bg-clip-border">
|
||||||
|
<div class="border-black/12.5 rounded-t-2xl border-b-0 border-solid p-6 pb-0">
|
||||||
|
<h6 class="capitalize">Recent Projects</h6>
|
||||||
|
<p class="text-sm leading-normal">Your active projects</p>
|
||||||
|
</div>
|
||||||
|
<div class="flex-auto p-6 pt-4">
|
||||||
|
<p class="text-sm text-slate-500 text-center py-8">No projects yet.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</AppLayout>
|
</AppLayout>
|
||||||
|
|||||||
Reference in New Issue
Block a user