Used a modified TailwindCLI with DaisyUI
This commit is contained in:
parent
d9b0bc44fb
commit
bd28ff5324
11 changed files with 28 additions and 65 deletions
43
main.go
43
main.go
|
@ -1,14 +1,8 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/sha256"
|
|
||||||
"encoding/hex"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
|
@ -25,9 +19,6 @@ func main() {
|
||||||
// Initialize Echo router
|
// Initialize Echo router
|
||||||
e := echo.New()
|
e := echo.New()
|
||||||
|
|
||||||
// Generate a unique version identifier
|
|
||||||
version := time.Now().Format(time.RFC3339)
|
|
||||||
|
|
||||||
// Middleware
|
// Middleware
|
||||||
e.Use(middleware.Logger())
|
e.Use(middleware.Logger())
|
||||||
e.Use(middleware.Recover())
|
e.Use(middleware.Recover())
|
||||||
|
@ -39,40 +30,6 @@ func main() {
|
||||||
Level: 5,
|
Level: 5,
|
||||||
}))
|
}))
|
||||||
e.Use(middleware.RateLimiter(middleware.NewRateLimiterMemoryStore(50)))
|
e.Use(middleware.RateLimiter(middleware.NewRateLimiterMemoryStore(50)))
|
||||||
// Use middleware to set ETag and Cache-Control headers
|
|
||||||
e.Use(func(next echo.HandlerFunc) echo.HandlerFunc {
|
|
||||||
return func(c echo.Context) error {
|
|
||||||
// Get the path of the requested resource
|
|
||||||
path := c.Request().URL.Path
|
|
||||||
|
|
||||||
// If the requested resource is a CSS file
|
|
||||||
if strings.HasSuffix(path, ".css") {
|
|
||||||
log.Println(path)
|
|
||||||
// Read the CSS file
|
|
||||||
data, err := os.ReadFile(filepath.Join("public", strings.TrimPrefix(path, "/public")))
|
|
||||||
if err != nil {
|
|
||||||
// Log the error and return a 500 status
|
|
||||||
log.Println(err)
|
|
||||||
return c.NoContent(http.StatusInternalServerError)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compute the hash of the CSS file contents
|
|
||||||
hash := sha256.Sum256(data)
|
|
||||||
|
|
||||||
// Set the ETag to the hash
|
|
||||||
c.Response().Header().Set("ETag", hex.EncodeToString(hash[:]))
|
|
||||||
|
|
||||||
// Set the Content-Type to text/css
|
|
||||||
c.Response().Header().Set("Content-Type", "text/css")
|
|
||||||
} else {
|
|
||||||
// For other resources, set the ETag to the server start time
|
|
||||||
c.Response().Header().Set("ETag", version)
|
|
||||||
}
|
|
||||||
|
|
||||||
c.Response().Header().Set("Cache-Control", "public, no-cache")
|
|
||||||
return next(c)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// Static server
|
// Static server
|
||||||
e.Static("/public", "public")
|
e.Static("/public", "public")
|
||||||
|
|
2
public/css/styles.css
vendored
2
public/css/styles.css
vendored
File diff suppressed because one or more lines are too long
1
stylegen/base.css
vendored
1
stylegen/base.css
vendored
|
@ -1,4 +1,3 @@
|
||||||
@import url('daisyui.css') layer(base);
|
|
||||||
@tailwind base;
|
@tailwind base;
|
||||||
@tailwind components;
|
@tailwind components;
|
||||||
@tailwind utilities;
|
@tailwind utilities;
|
||||||
|
|
|
@ -20,27 +20,34 @@ case $OS in
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
case $ARCH in
|
# For macOS, we use a single binary called 'macos'
|
||||||
"x86_64")
|
if [ "$OS" = "macos" ]; then
|
||||||
ARCH="x64"
|
BINARY="./tw/macos"
|
||||||
;;
|
|
||||||
"arm64")
|
|
||||||
ARCH="arm64"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Unsupported architecture: $ARCH"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Construct the binary file name
|
|
||||||
BINARY="./tw/${OS}-${ARCH}"
|
|
||||||
if [ "$OS" = "windows" ]; then
|
|
||||||
BINARY="${BINARY}.exe"
|
|
||||||
else
|
else
|
||||||
# Set execute permissions on the binary
|
case $ARCH in
|
||||||
chmod +x $BINARY
|
"x86_64")
|
||||||
|
ARCH="x64"
|
||||||
|
;;
|
||||||
|
"arm64")
|
||||||
|
ARCH="arm64"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unsupported architecture: $ARCH"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Construct the binary file name
|
||||||
|
BINARY="./tw/${OS}-${ARCH}"
|
||||||
|
if [ "$OS" = "windows" ]; then
|
||||||
|
BINARY="${BINARY}.exe"
|
||||||
|
else
|
||||||
|
# Set execute permissions on the binary
|
||||||
|
chmod +x $BINARY
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo $BINARY
|
||||||
|
|
||||||
# Run the binary
|
# Run the binary
|
||||||
$BINARY build -i ./base.css -o ../public/css/styles.css --minify
|
$BINARY build -i ./base.css -o ../public/css/styles.css --minify
|
2
stylegen/tailwind.config.js
vendored
2
stylegen/tailwind.config.js
vendored
|
@ -7,6 +7,6 @@ module.exports = {
|
||||||
daisyui: {
|
daisyui: {
|
||||||
themes: ["night"],
|
themes: ["night"],
|
||||||
},
|
},
|
||||||
plugins: [require('@tailwindcss/typography')],
|
plugins: [require('daisyui'), require('@tailwindcss/typography')],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
BIN
stylegen/tw/macos-x64 → stylegen/tw/macos
Normal file → Executable file
BIN
stylegen/tw/macos-x64 → stylegen/tw/macos
Normal file → Executable file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Add table
Reference in a new issue