From 1686fea0fa7725ed4c93abbefd01b9b959fffe9c Mon Sep 17 00:00:00 2001 From: Aidan Date: Sun, 26 Jan 2025 02:57:40 -0500 Subject: [PATCH] fix loading, dockerize, improve link style (no .html), minify files automatically (and use files in code) --- .gitea/workflows/minify.yaml | 50 +++++++++++++++++++++++++++++++ default.conf | 57 ++++++++++++++++++++++++++++++++++++ docker-compose.yml | 9 ++++++ src/about.html | 20 +++++++------ src/cloud.html | 22 +++++++------- src/contact.html | 20 +++++++------ src/design.html | 20 +++++++------ src/index.html | 22 +++++++------- src/projects.html | 20 +++++++------ src/status.html | 24 ++++++++------- 10 files changed, 197 insertions(+), 67 deletions(-) create mode 100644 .gitea/workflows/minify.yaml create mode 100644 default.conf create mode 100644 docker-compose.yml diff --git a/.gitea/workflows/minify.yaml b/.gitea/workflows/minify.yaml new file mode 100644 index 0000000..9157428 --- /dev/null +++ b/.gitea/workflows/minify.yaml @@ -0,0 +1,50 @@ +name: Minify HTML and CSS + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + minify: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: 18 + + - name: Install minification tools + run: | + npm install -g html-minifier-terser csso-cli terser + + - name: Minify HTML files + run: | + find src/ -name '*.html' ! -name '*min*' -exec sh -c 'html-minifier-terser --collapse-whitespace --remove-comments --minify-js true --minify-css true -o "${0%.html}.min.html" "$0"' {} \; + + - name: Minify CSS files + run: | + find src/css/ -name '*.css' ! -name '*min*' -exec sh -c 'csso "$0" --output "${0%.css}.min.css"' {} \; + + - name: Minify JS files + run: | + find src/ -name '*.js' ! -name '*min*' -exec sh -c 'terser --compress --mangle --output "${0%.js}.min.js" "$0"' {} \; + + - name: Commit and push changes + env: + USERNAME_GITEA: ${{ secrets.USERNAME_GITEA }} + TOKEN_GITEA: ${{ secrets.TOKEN_GITEA }} + run: | + git config --global user.name "LibreCloud Actions Bot" + git config --global user.email "git@pontusmail.org" + git remote set-url origin https://${USERNAME_GITEA}:${TOKEN_GITEA}@git.pontusmail.org/aidan/aidxnFUNretro.git + git add . + git commit -m "[bot] Minifying HTML and CSS automatically" + git push origin main diff --git a/default.conf b/default.conf new file mode 100644 index 0000000..9b8b506 --- /dev/null +++ b/default.conf @@ -0,0 +1,57 @@ +server { + listen 80; + listen [::]:80; + server_name localhost; + + location / { + root /usr/share/nginx/html; + index index.min.html; + autoindex on; + } + + # TODO: This could be improved later + location = /about { + root /usr/share/nginx/html; + index about.min.html; + try_files /about.min.html =404; + } + location = /cloud { + root /usr/share/nginx/html; + index cloud.min.html; + try_files /cloud.min.html =404; + } + location = /contact { + root /usr/share/nginx/html; + index about.min.html; + try_files /contact.min.html =404; + } + location = /design { + root /usr/share/nginx/html; + index about.min.html; + try_files /design.min.html =404; + } + location = /ping { + root /usr/share/nginx/html; + index ping.min.html; + try_files /ping.min.html =404; + } + location = /projects { + root /usr/share/nginx/html; + index projects.min.html; + try_files /projects.min.html =404; + } + location = /status { + root /usr/share/nginx/html; + index status.min.html; + try_files /status.min.html =404; + } + + #error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..50476f8 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +services: + pontus-web: + image: nginx + restart: always + ports: + - 2281:80 + volumes: + - ./default.conf:/etc/nginx/conf.d/default.conf + - ./src:/usr/share/nginx/html \ No newline at end of file diff --git a/src/about.html b/src/about.html index 23a8a88..9ac7ddc 100644 --- a/src/about.html +++ b/src/about.html @@ -7,11 +7,13 @@ - - + + -
+
+ Loading animation +
- - + + \ No newline at end of file diff --git a/src/cloud.html b/src/cloud.html index 1016fe6..f1e5733 100644 --- a/src/cloud.html +++ b/src/cloud.html @@ -7,11 +7,13 @@ - - + + -
+
+ Loading animation +
- - + + \ No newline at end of file diff --git a/src/contact.html b/src/contact.html index 5ca7302..a913009 100644 --- a/src/contact.html +++ b/src/contact.html @@ -7,11 +7,13 @@ - - + + -
+
+ Loading animation +
- - + + diff --git a/src/design.html b/src/design.html index e578fbe..2fcb9d7 100644 --- a/src/design.html +++ b/src/design.html @@ -7,11 +7,13 @@ - - + + -
+
+ Loading animation +
- - + + \ No newline at end of file diff --git a/src/index.html b/src/index.html index 50c733f..1ba2ebb 100644 --- a/src/index.html +++ b/src/index.html @@ -7,11 +7,13 @@ - - + + -
+
+ Loading animation +
- - + + \ No newline at end of file diff --git a/src/projects.html b/src/projects.html index f8f07b6..17e5c7d 100644 --- a/src/projects.html +++ b/src/projects.html @@ -7,11 +7,13 @@ - - + + -
+
+ Loading animation +
- - + + diff --git a/src/status.html b/src/status.html index 91ee9d0..0bb86a5 100644 --- a/src/status.html +++ b/src/status.html @@ -7,25 +7,27 @@ - - + + -
+
+ Loading animation +
- - - + + + \ No newline at end of file