generated from VLADIMIR/template
update
This commit is contained in:
parent
0a6294a62f
commit
a975baffa7
Binary file not shown.
@ -2,6 +2,8 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"embed"
|
||||||
|
"io/fs"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -19,6 +21,9 @@ import (
|
|||||||
"google.golang.org/grpc/credentials/insecure"
|
"google.golang.org/grpc/credentials/insecure"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:embed static/user/*
|
||||||
|
var userFS embed.FS
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// Create a listener on TCP port
|
// Create a listener on TCP port
|
||||||
lis, err := net.Listen("tcp", ":8080")
|
lis, err := net.Listen("tcp", ":8080")
|
||||||
@ -74,9 +79,36 @@ func main() {
|
|||||||
|
|
||||||
gwServer := &http.Server{
|
gwServer := &http.Server{
|
||||||
Addr: ":8090",
|
Addr: ":8090",
|
||||||
Handler: gwmux,
|
Handler: cors(gwmux),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Serve gRPC-Gateway server
|
||||||
log.Println("Serving gRPC-Gateway on http://0.0.0.0:8090")
|
log.Println("Serving gRPC-Gateway on http://0.0.0.0:8090")
|
||||||
|
go func() {
|
||||||
log.Fatalln(gwServer.ListenAndServe())
|
log.Fatalln(gwServer.ListenAndServe())
|
||||||
|
}()
|
||||||
|
|
||||||
|
muxUser := http.NewServeMux()
|
||||||
|
subUserFS, err := fs.Sub(userFS, "static/user")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
fileServerUser := http.FileServer(http.FS(subUserFS))
|
||||||
|
muxUser.Handle("/", fileServerUser)
|
||||||
|
|
||||||
|
// Serve admin web server
|
||||||
|
log.Println("Serving user web on http://0.0.0.0:8100")
|
||||||
|
log.Fatalln(http.ListenAndServe(":8100", muxUser))
|
||||||
|
}
|
||||||
|
|
||||||
|
func cors(h http.Handler) http.Handler {
|
||||||
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||||
|
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, PATCH, DELETE")
|
||||||
|
w.Header().Set("Access-Control-Allow-Headers", "Accept, Content-Type, Content-Length, Accept-Encoding, Authorization, ResponseType, X-Id, X-Password")
|
||||||
|
if r.Method == "OPTIONS" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
h.ServeHTTP(w, r)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1 @@
|
|||||||
|
@media (min-width: 1024px){.about{min-height:100vh;display:flex;align-items:center}}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
import{_ as o,c as s,a as t,o as a}from"./index-C4gC0qcx.js";const n={},c={class:"about"};function r(_,e){return a(),s("div",c,e[0]||(e[0]=[t("h1",null,"This is an about page",-1)]))}const l=o(n,[["render",r]]);export{l as default};
|
||||||
26
cmd/pinned_message/static/user/assets/index-C4gC0qcx.js
Normal file
26
cmd/pinned_message/static/user/assets/index-C4gC0qcx.js
Normal file
File diff suppressed because one or more lines are too long
1
cmd/pinned_message/static/user/assets/index-DWVNKSuJ.css
Normal file
1
cmd/pinned_message/static/user/assets/index-DWVNKSuJ.css
Normal file
@ -0,0 +1 @@
|
|||||||
|
:root{--vt-c-white: #ffffff;--vt-c-white-soft: #f8f8f8;--vt-c-white-mute: #f2f2f2;--vt-c-black: #181818;--vt-c-black-soft: #222222;--vt-c-black-mute: #282828;--vt-c-indigo: #2c3e50;--vt-c-divider-light-1: rgba(60, 60, 60, .29);--vt-c-divider-light-2: rgba(60, 60, 60, .12);--vt-c-divider-dark-1: rgba(84, 84, 84, .65);--vt-c-divider-dark-2: rgba(84, 84, 84, .48);--vt-c-text-light-1: var(--vt-c-indigo);--vt-c-text-light-2: rgba(60, 60, 60, .66);--vt-c-text-dark-1: var(--vt-c-white);--vt-c-text-dark-2: rgba(235, 235, 235, .64)}:root{--color-background: var(--vt-c-white);--color-background-soft: var(--vt-c-white-soft);--color-background-mute: var(--vt-c-white-mute);--color-border: var(--vt-c-divider-light-2);--color-border-hover: var(--vt-c-divider-light-1);--color-heading: var(--vt-c-text-light-1);--color-text: var(--vt-c-text-light-1);--section-gap: 160px}@media (prefers-color-scheme: dark){:root{--color-background: var(--vt-c-black);--color-background-soft: var(--vt-c-black-soft);--color-background-mute: var(--vt-c-black-mute);--color-border: var(--vt-c-divider-dark-2);--color-border-hover: var(--vt-c-divider-dark-1);--color-heading: var(--vt-c-text-dark-1);--color-text: var(--vt-c-text-dark-2)}}*,*:before,*:after{box-sizing:border-box;margin:0;font-weight:400}body{min-height:100vh;color:var(--color-text);background:var(--color-background);transition:color .5s,background-color .5s;line-height:1.6;font-family:Inter,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;font-size:15px;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#app{max-width:1280px;margin:0 auto;padding:1rem;font-weight:400}a,.green{text-decoration:none;color:#00bd7e;transition:.4s;padding:3px}@media (hover: hover){a:hover{background-color:#00bd7e33}}@media (min-width: 1024px){body{display:flex;place-items:center}#app{display:grid;grid-template-columns:1fr 1fr;padding:0 2rem}}.day-block[data-v-c08ccda7]{border:solid 1px rebeccapurple;margin:10px 0;padding:15px;border-radius:10px}.item[data-v-fd0742eb]{margin-top:2rem;display:flex;position:relative}.details[data-v-fd0742eb]{flex:1;margin-left:1rem}i[data-v-fd0742eb]{display:flex;place-items:center;place-content:center;width:32px;height:32px;color:var(--color-text)}h3[data-v-fd0742eb]{font-size:1.2rem;font-weight:500;margin-bottom:.4rem;color:var(--color-heading)}@media (min-width: 1024px){.item[data-v-fd0742eb]{margin-top:0;padding:.4rem 0 1rem calc(var(--section-gap) / 2)}i[data-v-fd0742eb]{top:calc(50% - 25px);left:-26px;position:absolute;border:1px solid var(--color-border);background:var(--color-background);border-radius:8px;width:50px;height:50px}.item[data-v-fd0742eb]:before{content:" ";border-left:1px solid var(--color-border);position:absolute;left:0;bottom:calc(50% + 25px);height:calc(50% - 25px)}.item[data-v-fd0742eb]:after{content:" ";border-left:1px solid var(--color-border);position:absolute;left:0;top:calc(50% + 25px);height:calc(50% - 25px)}.item[data-v-fd0742eb]:first-of-type:before{display:none}.item[data-v-fd0742eb]:last-of-type:after{display:none}}
|
||||||
BIN
cmd/pinned_message/static/user/favicon.ico
Normal file
BIN
cmd/pinned_message/static/user/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
14
cmd/pinned_message/static/user/index.html
Normal file
14
cmd/pinned_message/static/user/index.html
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<link rel="icon" href="/favicon.ico">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Vite App</title>
|
||||||
|
<script type="module" crossorigin src="/assets/index-C4gC0qcx.js"></script>
|
||||||
|
<link rel="stylesheet" crossorigin href="/assets/index-DWVNKSuJ.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="app"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@ -6,6 +6,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"pinned_message/internal/models"
|
"pinned_message/internal/models"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ScheduleStorage struct {
|
type ScheduleStorage struct {
|
||||||
@ -42,5 +43,19 @@ func (s *ScheduleStorage) GetSchedule() ([]*models.Day, error) {
|
|||||||
if err := json.Unmarshal(data, &days); err != nil {
|
if err := json.Unmarshal(data, &days); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return days, nil
|
filterDays := make([]*models.Day, 0, len(days))
|
||||||
|
for _, day := range days {
|
||||||
|
if isBeforeToday(day.Date) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
filterDays = append(filterDays, day)
|
||||||
|
}
|
||||||
|
return filterDays, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func isBeforeToday(targetDate time.Time) bool {
|
||||||
|
now := time.Now()
|
||||||
|
todayMidnight := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location())
|
||||||
|
targetMidnight := time.Date(targetDate.Year(), targetDate.Month(), targetDate.Day(), 0, 0, 0, 0, targetDate.Location())
|
||||||
|
return targetMidnight.Before(todayMidnight)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user