Add dark theme

This commit is contained in:
Melon 2023-12-17 15:55:41 +00:00
parent f00d1c4a51
commit 56ff556928
Signed by: melon
GPG Key ID: 6C9D970C50D26A25
16 changed files with 29 additions and 49 deletions

View File

@ -2,6 +2,7 @@
<html lang="en">
<head>
<title>{{.ServiceName}}</title>
<link rel="stylesheet" href="/theme/dark.css" media="screen and (prefers-color-scheme: dark)">
</head>
<body>
<header>

View File

@ -2,6 +2,7 @@
<html lang="en">
<head>
<title>{{.ServiceName}}</title>
<link rel="stylesheet" href="/theme/dark.css" media="screen and (prefers-color-scheme: dark)">
</head>
<body>
<header>

View File

@ -2,6 +2,7 @@
<html lang="en">
<head>
<title>{{.ServiceName}}</title>
<link rel="stylesheet" href="/theme/dark.css" media="screen and (prefers-color-scheme: dark)">
</head>
<body>
<header>

View File

@ -2,6 +2,7 @@
<html lang="en">
<head>
<title>{{.ServiceName}}</title>
<link rel="stylesheet" href="/theme/dark.css" media="screen and (prefers-color-scheme: dark)">
</head>
<body>
<header>

View File

@ -2,6 +2,7 @@
<html lang="en">
<head>
<title>{{.ServiceName}}</title>
<link rel="stylesheet" href="/theme/dark.css" media="screen and (prefers-color-scheme: dark)">
</head>
<body>
<header>

View File

@ -2,6 +2,7 @@
<html lang="en">
<head>
<title>{{.ServiceName}}</title>
<link rel="stylesheet" href="/theme/dark.css" media="screen and (prefers-color-scheme: dark)">
</head>
<body>
<header>

View File

@ -2,6 +2,7 @@
<html lang="en">
<head>
<title>{{.ServiceName}}</title>
<link rel="stylesheet" href="/theme/dark.css" media="screen and (prefers-color-scheme: dark)">
</head>
<body>
<header>

View File

@ -2,6 +2,7 @@
<html lang="en">
<head>
<title>{{.ServiceName}}</title>
<link rel="stylesheet" href="/theme/dark.css" media="screen and (prefers-color-scheme: dark)">
<script>
window.addEventListener("load", function () {
selectText("app-secret");

View File

@ -2,6 +2,7 @@
<html lang="en">
<head>
<title>{{.ServiceName}}</title>
<link rel="stylesheet" href="/theme/dark.css" media="screen and (prefers-color-scheme: dark)">
</head>
<body>
<header>

View File

@ -2,6 +2,7 @@
<html lang="en">
<head>
<title>{{.ServiceName}}</title>
<link rel="stylesheet" href="/theme/dark.css" media="screen and (prefers-color-scheme: dark)">
</head>
<body>
<header>

View File

@ -2,6 +2,7 @@
<html lang="en">
<head>
<title>{{.ServiceName}}</title>
<link rel="stylesheet" href="/theme/dark.css" media="screen and (prefers-color-scheme: dark)">
</head>
<body>
<header>

View File

@ -2,6 +2,7 @@
<html lang="en">
<head>
<title>{{.ServiceName}}</title>
<link rel="stylesheet" href="/theme/dark.css" media="screen and (prefers-color-scheme: dark)">
</head>
<body>
<header>

View File

@ -1,49 +0,0 @@
package server
import (
"context"
"errors"
"fmt"
"github.com/go-oauth2/oauth2/v4"
)
var _ oauth2.TokenStore = &TestingStruct{}
type TestingStruct struct {
}
func (t TestingStruct) Create(ctx context.Context, info oauth2.TokenInfo) error {
fmt.Println(info.GetAccessExpiresIn())
fmt.Println(info.GetRefreshExpiresIn())
return errors.New("error")
}
func (t TestingStruct) RemoveByCode(ctx context.Context, code string) error {
//TODO implement me
panic("implement me")
}
func (t TestingStruct) RemoveByAccess(ctx context.Context, access string) error {
//TODO implement me
panic("implement me")
}
func (t TestingStruct) RemoveByRefresh(ctx context.Context, refresh string) error {
//TODO implement me
panic("implement me")
}
func (t TestingStruct) GetByCode(ctx context.Context, code string) (oauth2.TokenInfo, error) {
//TODO implement me
panic("implement me")
}
func (t TestingStruct) GetByAccess(ctx context.Context, access string) (oauth2.TokenInfo, error) {
//TODO implement me
panic("implement me")
}
func (t TestingStruct) GetByRefresh(ctx context.Context, refresh string) (oauth2.TokenInfo, error) {
//TODO implement me
panic("implement me")
}

View File

@ -1,6 +1,7 @@
package server
import (
"bytes"
"crypto/subtle"
_ "embed"
"encoding/json"
@ -10,6 +11,7 @@ import (
"github.com/1f349/tulip/database"
"github.com/1f349/tulip/openid"
scope2 "github.com/1f349/tulip/scope"
"github.com/1f349/tulip/theme"
"github.com/go-oauth2/oauth2/v4/errors"
"github.com/go-oauth2/oauth2/v4/generates"
"github.com/go-oauth2/oauth2/v4/manage"
@ -153,6 +155,11 @@ func NewHttpServer(conf Conf, db *database.DB, privKey []byte) *http.Server {
http.Error(rw, "Logout failed", http.StatusInternalServerError)
}))
// theme styles
r.GET("/theme/dark.css", func(rw http.ResponseWriter, req *http.Request, params httprouter.Params) {
http.ServeContent(rw, req, "dark.css", time.Now(), bytes.NewReader(theme.DarkThemeCss))
})
// login steps
r.GET("/login", OptionalAuthentication(false, hs.LoginGet))
r.POST("/login", OptionalAuthentication(false, hs.LoginPost))

4
theme/dark.css Normal file
View File

@ -0,0 +1,4 @@
html, body {
background-color: #242424;
color: #eeeeee;
}

6
theme/theme.go Normal file
View File

@ -0,0 +1,6 @@
package theme
import _ "embed"
//go:embed dark.css
var DarkThemeCss []byte