diff --git a/.github/workflows/build.py b/.github/workflows/build.py new file mode 100644 index 0000000..782d74d --- /dev/null +++ b/.github/workflows/build.py @@ -0,0 +1,43 @@ +from string import Template +import os +from os.path import getmtime, getsize +from datetime import datetime + + +def size(size_in_bytes): + """convert""" + size_kb = size_in_bytes / 1024.0 + size_mb = size_kb / 1024.0 + + if size_mb >= 1: + return f"{size_mb:.2f}M" + elif size_kb >= 1: + return f"{size_kb:.2f}K" + return size_in_bytes + + +PATH_TO_FILE = "index.html" +FOLDER = "download/" + +t = Template( + """ + [   ] + $file + $date + $size +   + """ +) +listed = os.listdir(FOLDER) +s = "" +for name in listed: + p = FOLDER + name + if name.endswith(".gz"): + date = datetime.fromtimestamp(getmtime(p)).strftime("%Y-%m-%d %H:%M:%S") + s += t.substitute(file=name, date=date, size=size(getsize(p))) +with open(FOLDER + PATH_TO_FILE, "r", encoding="utf-8") as file: + file_data = file.read() + file_data = file_data.replace("", s) + +with open(FOLDER + PATH_TO_FILE, "w", encoding="utf-8") as file: + file.write(file_data) diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml new file mode 100644 index 0000000..4022df6 --- /dev/null +++ b/.github/workflows/static.yml @@ -0,0 +1,44 @@ +# Simple workflow for deploying static content to GitHub Pages +name: Deploy static content to Pages + +on: + # Runs on pushes targeting the default branch + push: + branches: ["main"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + # Single deploy job since we're just deploying + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Pages + uses: actions/configure-pages@v4 + - name: render index.html + run: python3 .github/workflows/build.py + - name: Upload artifact + uses: actions/upload-pages-artifact@v2 + with: + path: "." + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v3 diff --git a/download/index.html b/download/index.html new file mode 100644 index 0000000..3d136d6 --- /dev/null +++ b/download/index.html @@ -0,0 +1,36 @@ + + + + Index of /download + + +

Index of /download

+ + + + + + + + + + + + + + + + + + + + + + +
+ [ICO] + NameLast modifiedSizeDescription

+ [PARENTDIR] + Parent Directory - 

+ +