Skip to content

Commit

Permalink
Add site generator
Browse files Browse the repository at this point in the history
  • Loading branch information
thevahidal committed Dec 28, 2023
1 parent a1dc05b commit 2670fcc
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 9 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/hellow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: "pip"
python-version: "3.11"
cache: "poetry"

- run: pip install -r requirements.txt
- run: python script.py
- run: poetry install
- run: poetry run python script.py
8 changes: 8 additions & 0 deletions output.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><style>
body {
font-family: sans-serif;
}
.section > .title {
color: red;
}
</style></head><body><div class="section"><h1 class="title">Projects</h1><p class="description">Some of my projects</p><div class="item"><h2 class="title">Soul</h2><p class="description">A simple, fast and lightweight PHP framework.</p><a class="url" href="https://github.com/thevahidal/soul">Link</a></div><div class="item"><h2 class="title">Bukowski</h2><p class="description">A beautiful typewriter</p><a class="url" href="https://github.com/thevahidal/bukowski">Link</a></div></div><div class="section"><h1 class="title">Links</h1><p class="description">Some of my links</p><div class="item"><h2 class="title">GithHub</h2><a class="url" href="https://github.com/thevahidal">Link</a></div><div class="item"><h2 class="title">Linkedin</h2><a class="url" href="https://www.linkedin.com/in/thevahidal/">Link</a></div><div class="item"><h2 class="title">Twitter</h2><a class="url" href="https://twitter.com/thevahidal">Link</a></div></div></body></html>
18 changes: 18 additions & 0 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[tool.poetry]
name = "github-actions-python"
version = "0.1.0"
description = ""
authors = ["Vahid Al <thevahidal@gmail.com>"]
readme = "README.md"
packages = [{include = "github_actions_python"}]

[tool.poetry.dependencies]
python = "^3.11"
tinyhtml = "^1.2.0"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
1 change: 0 additions & 1 deletion requirements.txt

This file was deleted.

50 changes: 46 additions & 4 deletions script.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,46 @@
import requests
print("Hellow!")
response = requests.get("https://jsonplaceholder.typicode.com/todos/1")
print(response.json())
import tomllib

from tinyhtml import html, h, frag, raw


with open("data.toml", "rb") as f:
data = tomllib.load(f)
sections = frag(
h("div", klass="section")(
h("h1", klass="title")(section.get("title")),
h("p", klass="description")(section.get("description")),
(
h("div", klass="item")(
h("h2", klass="title")(item.get("title")),
h("p", klass="description")(item.get("description"))
if item.get("description")
else None,
h("a", klass="url", href=item.get("url"))("Link"),
)
for item in section["items"]
),
)
for section in data["sections"]
)

output = html(lang="en")(
h("head")(
h("meta", charset="utf-8"),
h("style")(
raw(
"""
body {
font-family: sans-serif;
}
.section > .title {
color: red;
}
"""
)
),
),
h("body")(sections),
).render()

with open("output.html", "w") as f:
f.write(output)

0 comments on commit 2670fcc

Please sign in to comment.