add webmanifest for public app, make timezone configurable to fix schedule hours comparison
This commit is contained in:
parent
a34457492c
commit
feb3973869
@ -1,4 +1,5 @@
|
|||||||
name: Casa de alguien
|
name: Casa de alguien
|
||||||
|
timezone: America/Mexico_City
|
||||||
|
|
||||||
adapter:
|
adapter:
|
||||||
kind: dry-run
|
kind: dry-run
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
<link rel="manifest" href="/static/admin-manifest.webmanifest" />
|
<link rel="manifest" href="/static/admin-manifest.webmanifest" />
|
||||||
<link rel="icon" type="image/png" href="/static/icon/128.png" sizes="128x128" />
|
<link rel="icon" type="image/png" href="/static/icon/128.png" sizes="128x128" />
|
||||||
<link rel="icon" type="image/png" href="/static/icon/512.png" sizes="512" />
|
<link rel="icon" type="image/png" href="/static/icon/512.png" sizes="512" />
|
||||||
|
|
||||||
<link rel="apple-touch-icon" href="/static/icon/512.png">
|
<link rel="apple-touch-icon" href="/static/icon/512.png">
|
||||||
<link rel="apple-touch-icon" sizes="152x152" href="/static/icon/152.png">
|
<link rel="apple-touch-icon" sizes="152x152" href="/static/icon/152.png">
|
||||||
<link rel="apple-touch-icon" sizes="384x384" href="/static/icon/384.png">
|
<link rel="apple-touch-icon" sizes="384x384" href="/static/icon/384.png">
|
||||||
|
@ -9,7 +9,13 @@
|
|||||||
<link rel="stylesheet" href="https://cdn.rob.mx/css/fonts.css" />
|
<link rel="stylesheet" href="https://cdn.rob.mx/css/fonts.css" />
|
||||||
<link rel="stylesheet" href="https://cdn.rob.mx/nidito/index.css" />
|
<link rel="stylesheet" href="https://cdn.rob.mx/nidito/index.css" />
|
||||||
<link rel="stylesheet" href="/static/index.css" />
|
<link rel="stylesheet" href="/static/index.css" />
|
||||||
<!-- link rel="manifest" href="/static/manifest.webmanifest" /-->
|
<link rel="manifest" href="/static/manifest.webmanifest" />
|
||||||
|
<link rel="icon" type="image/png" href="/static/icon/128.png" sizes="128x128" />
|
||||||
|
<link rel="icon" type="image/png" href="/static/icon/512.png" sizes="512" />
|
||||||
|
<link rel="apple-touch-icon" href="/static/icon/512.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="152x152" href="/static/icon/152.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="384x384" href="/static/icon/384.png">
|
||||||
|
<link rel="apple-touch-icon" sizes="192x192" href="/static/icon/192.png">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header id="main-header">
|
<header id="main-header">
|
||||||
|
@ -48,12 +48,12 @@ type HTTPConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Name string `yaml:"name"`
|
Name string `yaml:"name"`
|
||||||
Adapter map[string]any `yaml:"adapter"`
|
Adapter map[string]any `yaml:"adapter"`
|
||||||
HTTP *HTTPConfig `yaml:"http"`
|
HTTP *HTTPConfig `yaml:"http"`
|
||||||
WebPush *push.Config `yaml:"push"`
|
WebPush *push.Config `yaml:"push"`
|
||||||
|
Timezone string `yaml:"timezone"`
|
||||||
DB string `yaml:"db"`
|
DB string `yaml:"db"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConfigDefaults(dbPath string) *Config {
|
func ConfigDefaults(dbPath string) *Config {
|
||||||
@ -146,7 +146,7 @@ func notifyAdmins(message string) {
|
|||||||
for _, sub := range subs {
|
for _, sub := range subs {
|
||||||
err := push.Notify(message, sub)
|
err := push.Notify(message, sub)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Errorf("could not push notification to subscription %s: %s", sub.ID, err)
|
logrus.Errorf("could not push notification to subscription %s: %s", sub.ID(), err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -155,14 +155,14 @@ func rex(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|||||||
var err error
|
var err error
|
||||||
u := user.FromContext(r)
|
u := user.FromContext(r)
|
||||||
|
|
||||||
defer func() {
|
defer func(req *http.Request, err error) {
|
||||||
_, sqlErr := _db.Collection("log").Insert(newAuditLog(r, err))
|
_, sqlErr := _db.Collection("log").Insert(newAuditLog(req, err))
|
||||||
if sqlErr != nil {
|
if sqlErr != nil {
|
||||||
logrus.Errorf("could not record error log: %s", sqlErr)
|
logrus.Errorf("could not record error log: %s", sqlErr)
|
||||||
}
|
}
|
||||||
}()
|
}(r, err)
|
||||||
|
|
||||||
err = u.IsAllowed(time.Now())
|
err = u.IsAllowed(time.Now().In(TZ))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Errorf("Denying rex to %s: %s", u.Name, err)
|
logrus.Errorf("Denying rex to %s: %s", u.Name, err)
|
||||||
http.Error(w, "Access denied", http.StatusForbidden)
|
http.Error(w, "Access denied", http.StatusForbidden)
|
||||||
@ -182,6 +182,7 @@ func rex(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var _db db.Session
|
var _db db.Session
|
||||||
|
var TZ *time.Location = time.UTC
|
||||||
|
|
||||||
func Initialize(config *Config) (http.Handler, error) {
|
func Initialize(config *Config) (http.Handler, error) {
|
||||||
devMode := os.Getenv("ENV") == "dev"
|
devMode := os.Getenv("ENV") == "dev"
|
||||||
@ -190,6 +191,14 @@ func Initialize(config *Config) (http.Handler, error) {
|
|||||||
allowCORS(nil)(w, r, nil)
|
allowCORS(nil)(w, r, nil)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if config.Timezone != "" {
|
||||||
|
mtz, err := time.LoadLocation(config.Timezone)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("Unknown timezone %s", config.Timezone)
|
||||||
|
}
|
||||||
|
TZ = mtz
|
||||||
|
}
|
||||||
|
|
||||||
db := sqlite.ConnectionURL{
|
db := sqlite.ConnectionURL{
|
||||||
Database: config.DB,
|
Database: config.DB,
|
||||||
Options: map[string]string{
|
Options: map[string]string{
|
||||||
|
@ -4,9 +4,44 @@
|
|||||||
"display": "standalone",
|
"display": "standalone",
|
||||||
"icons": [
|
"icons": [
|
||||||
{
|
{
|
||||||
"src": "static/icon@192.png",
|
"src": "static/icon/72.png",
|
||||||
|
"sizes": "72x72",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "static/icon/96.png",
|
||||||
|
"sizes": "96x96",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "static/icon/128.png",
|
||||||
|
"sizes": "128x128",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "static/icon/144.png",
|
||||||
|
"sizes": "144x144",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "static/icon/152.png",
|
||||||
|
"sizes": "152x152",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "static/icon/192.png",
|
||||||
"sizes": "192x192",
|
"sizes": "192x192",
|
||||||
"type": "image/png"
|
"type": "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "static/icon/384.png",
|
||||||
|
"sizes": "384x384",
|
||||||
|
"type": "image/png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "static/icon/512.png",
|
||||||
|
"sizes": "512x512",
|
||||||
|
"type": "image/png"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"name": "Puerta Nidito",
|
"name": "Puerta Nidito",
|
||||||
|
@ -126,7 +126,7 @@ func (user *User) IsAllowed(t time.Time) error {
|
|||||||
return fmt.Errorf("usuario expirado, avísale a Roberto")
|
return fmt.Errorf("usuario expirado, avísale a Roberto")
|
||||||
}
|
}
|
||||||
|
|
||||||
if user.Schedule != nil && !user.Schedule.AllowedAt(time.Now()) {
|
if user.Schedule != nil && !user.Schedule.AllowedAt(t) {
|
||||||
return fmt.Errorf("accesso denegado, intente nuevamente en otro momento")
|
return fmt.Errorf("accesso denegado, intente nuevamente en otro momento")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user