From 78454f8713fdad3bbc765768726a15b3bae54412 Mon Sep 17 00:00:00 2001 From: joncrangle <94425204+joncrangle@users.noreply.github.com> Date: Mon, 13 Nov 2023 21:44:11 -0500 Subject: [PATCH] improvement: tailwind cli to build stylesheet --- .github/workflows/build-css.yaml | 37 ++++++++++++++++++++++++++++++++ .gitignore | 4 +++- cmd/main.go | 11 +++++++++- handlers/form.html | 7 +++--- package.json | 9 ++++++++ styles/input.css | 3 +++ tailwind.config.js | 9 ++++++++ 7 files changed, 74 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/build-css.yaml create mode 100644 package.json create mode 100644 styles/input.css create mode 100644 tailwind.config.js diff --git a/.github/workflows/build-css.yaml b/.github/workflows/build-css.yaml new file mode 100644 index 0000000..a95cddc --- /dev/null +++ b/.github/workflows/build-css.yaml @@ -0,0 +1,37 @@ +name: Build Tailwind CSS + +on: + push: + paths: + - "handlers/form.html" + workflow_dispatch: + +jobs: + tailwindbuilder: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Install pnpm + uses: pnpm/action-setup@v2 + with: + version: 8 + - + name: Build Tailwind CSS + run: pnpm build + - + name: Commit generated stylesheet + run: | + if git diff --quiet; then + echo "No changes to commit." + exit 0 + else + echo "Changes detected, committing..." + git config --global user.name "Github action" + git config --global user.email "username@users.noreply.github.com" + git add cmd + git commit -m "Generated stylesheet" + git push + fi \ No newline at end of file diff --git a/.gitignore b/.gitignore index fdf1127..27ff4d9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ # dev binary ladder -VERSION \ No newline at end of file +VERSION +output.css +styles.css \ No newline at end of file diff --git a/cmd/main.go b/cmd/main.go index 36c6fef..51d1582 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -1,7 +1,7 @@ package main import ( - _ "embed" + "embed" "fmt" "log" "os" @@ -17,6 +17,7 @@ import ( //go:embed favicon.ico var faviconData string +var cssData embed.FS func main() { parser := argparse.NewParser("ladder", "Every Wall needs a Ladder") @@ -75,6 +76,14 @@ func main() { } app.Get("/", handlers.Form) + app.Get("/styles.css", func(c *fiber.Ctx) error { + cssData, err := cssData.ReadFile("styles.css") + if err != nil { + return c.Status(fiber.StatusInternalServerError).SendString("Internal Server Error") + } + c.Set("Content-Type", "text/css") + return c.Send(cssData) + }) app.Get("ruleset", handlers.Ruleset) app.Get("raw/*", handlers.Raw) diff --git a/handlers/form.html b/handlers/form.html index 52ea39f..39f76b2 100644 --- a/handlers/form.html +++ b/handlers/form.html @@ -3,9 +3,8 @@ - ladder - + @@ -20,12 +19,12 @@
-
-