Enhances cover generation and updates dependencies

Adds cover generation functionality for week notes, using a background image and specified font.

Updates dependencies to the latest versions, including flake8, certifi, click, identify, platformdirs, pygments, python-dotenv, requests, urllib3, and weeknotebot.
This commit is contained in:
fundor333
2025-06-24 19:35:06 +02:00
committed by Fundor333
parent 0fd3447224
commit 8859763bf0
9 changed files with 101 additions and 58 deletions

View File

@@ -34,7 +34,7 @@ repos:
- id: pyupgrade - id: pyupgrade
args: [--py312-plus] args: [--py312-plus]
- repo: https://github.com/PyCQA/flake8 - repo: https://github.com/PyCQA/flake8
rev: 7.2.0 rev: 7.3.0
hooks: hooks:
- id: flake8 - id: flake8
additional_dependencies: additional_dependencies:

BIN
Futura Book font.ttf Normal file

Binary file not shown.

BIN
cover.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

22
generate_cover.py Normal file
View File

@@ -0,0 +1,22 @@
from PIL import Image, ImageDraw, ImageFont # 👉️ Import modules from PIL
import typer
def generate_img(message: str, path: str):
font_path = "Futura Book font.ttf" # 👉️ Font .ttf Path
font_size = 100 # 👉️ Font Size
img = Image.open("cover.jpg") # 👉️ Open Image
dr = ImageDraw.Draw(img) # 👉️ Create New Image
my_font = ImageFont.truetype(font_path, font_size) # 👉️ Initialize Font
text_x = (img.width) // 2
text_y = (img.height) // 2
dr.text((text_x, text_y), message, font=my_font, fill=(255, 255, 255), anchor="mm")
img.save("content/" + path + "/cover.png")
def main(message: str, path: str):
generate_img(message, path)
if __name__ == "__main__":
typer.run(main)

View File

@@ -1,19 +1,21 @@
import datetime import datetime
import os import os
import re import re
from PIL import Image, ImageDraw from PIL import Image, ImageDraw, ImageFont # 👉️ Import modules from PIL
import typer
WIDTH = 1200 from typing import Annotated
HEIGHT = 630
def generate_img(message: str, path: str): def generate_img(message: str, path: str):
img = Image.new("RGB", (WIDTH, HEIGHT), color="blue") font_path = "Futura Book font.ttf" # 👉️ Font .ttf Path
font_size = 100 # 👉️ Font Size
imgDraw = ImageDraw.Draw(img) img = Image.open("cover.jpg") # 👉️ Open Image
dr = ImageDraw.Draw(img) # 👉️ Create New Image
imgDraw.text((10, 10), message, fill=(255, 255, 0)) my_font = ImageFont.truetype(font_path, font_size) # 👉️ Initialize Font
text_x = (img.width) // 2
text_y = (img.height) // 2
dr.text((text_x, text_y), message, font=my_font, fill=(255, 255, 255), anchor="mm")
print("Generated content/" + path + "/cover.png")
img.save("content/" + path + "/cover.png") img.save("content/" + path + "/cover.png")
@@ -63,11 +65,21 @@ def micro_fc():
print(f"Generated {generated}/index.md") print(f"Generated {generated}/index.md")
def weeklycover():
print("Make a weekly cover")
today = datetime.datetime.now()
year = today.strftime("%Y")
week = str(int(today.strftime("%W")) + 1)
file_string = f"Week Note Nº {week}/{year}"
generate_img(file_string, f"weeknotes/{year}/{week}")
ANSWER = { ANSWER = {
"post": post_fc, "post": post_fc,
"micro": micro_fc, "micro": micro_fc,
"photo": post_photo, "photo": post_photo,
"redirect": post_redirect, "redirect": post_redirect,
"weekly_cover": weeklycover,
} }
@@ -77,5 +89,13 @@ def main_checker():
ANSWER.get(text, main_checker)() ANSWER.get(text, main_checker)()
def main(text: Annotated[str, typer.Argument()] = None):
if text is None:
text = input(
"You need a new [post], a new [photo], a new [micro] or [weekly_cover]\n"
)
ANSWER.get(text, main)()
if __name__ == "__main__": if __name__ == "__main__":
main_checker() typer.run(main)

View File

@@ -91,6 +91,7 @@ submodule: ## Get submodule for this repo
.PHONY: weekly .PHONY: weekly
weekly: ## Weekly script weekly: ## Weekly script
@weeknote -config weeknote-config.json @weeknote -config weeknote-config.json
@python3 make-post.py weekly_cover
precommit: ## Run pre-commit hooks precommit: ## Run pre-commit hooks
@git add . & poetry run pre-commit run @git add . & poetry run pre-commit run

12
package-lock.json generated
View File

@@ -150,9 +150,9 @@
} }
}, },
"node_modules/caniuse-lite": { "node_modules/caniuse-lite": {
"version": "1.0.30001723", "version": "1.0.30001724",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001723.tgz", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001724.tgz",
"integrity": "sha512-1R/elMjtehrFejxwmexeXAtae5UO9iSyFn6G/I806CYC/BLyyBk1EPhrKBkWhy6wM6Xnm47dSJQec+tLJ39WHw==", "integrity": "sha512-WqJo7p0TbHDOythNTqYujmaJTvtYRZrjpP8TCvH6Vb9CYJerJNKamKzIWOM4BkQatWj9H2lYulpdAQNBe7QhNA==",
"funding": [ "funding": [
{ {
"type": "opencollective", "type": "opencollective",
@@ -241,9 +241,9 @@
} }
}, },
"node_modules/electron-to-chromium": { "node_modules/electron-to-chromium": {
"version": "1.5.170", "version": "1.5.173",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.170.tgz", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.173.tgz",
"integrity": "sha512-GP+M7aeluQo9uAyiTCxgIj/j+PrWhMlY7LFVj8prlsPljd0Fdg9AprlfUi+OCSFWy9Y5/2D/Jrj9HS8Z4rpKWA==", "integrity": "sha512-2bFhXP2zqSfQHugjqJIDFVwa+qIxyNApenmXTp9EjaKtdPrES5Qcn9/aSFy/NaP2E+fWG/zxKu/LBvY36p5VNQ==",
"license": "ISC" "license": "ISC"
}, },
"node_modules/emoji-regex": { "node_modules/emoji-regex": {

66
poetry.lock generated
View File

@@ -25,14 +25,14 @@ lxml = ["lxml"]
[[package]] [[package]]
name = "certifi" name = "certifi"
version = "2025.4.26" version = "2025.6.15"
description = "Python package for providing Mozilla's CA Bundle." description = "Python package for providing Mozilla's CA Bundle."
optional = false optional = false
python-versions = ">=3.6" python-versions = ">=3.7"
groups = ["main"] groups = ["main"]
files = [ files = [
{file = "certifi-2025.4.26-py3-none-any.whl", hash = "sha256:30350364dfe371162649852c63336a15c70c6510c2ad5015b21c2345311805f3"}, {file = "certifi-2025.6.15-py3-none-any.whl", hash = "sha256:2e0c7ce7cb5d8f8634ca55d2ba7e6ec2689a2fd6537d8dec1296a477a4910057"},
{file = "certifi-2025.4.26.tar.gz", hash = "sha256:0a816057ea3cdefcef70270d2c515e4506bbc954f417fa5ade2021213bb8f0c6"}, {file = "certifi-2025.6.15.tar.gz", hash = "sha256:d747aa5a8b9bbbb1bb8c22bb13e22bd1f18e9796defa16bab421f7f7a317323b"},
] ]
[[package]] [[package]]
@@ -151,14 +151,14 @@ files = [
[[package]] [[package]]
name = "click" name = "click"
version = "8.1.8" version = "8.2.1"
description = "Composable command line interface toolkit" description = "Composable command line interface toolkit"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.10"
groups = ["main"] groups = ["main"]
files = [ files = [
{file = "click-8.1.8-py3-none-any.whl", hash = "sha256:63c132bbbed01578a06712a2d1f497bb62d9c1c0d329b7903a866228027263b2"}, {file = "click-8.2.1-py3-none-any.whl", hash = "sha256:61a3265b914e850b85317d0b3109c7f8cd35a670f963866005d6ef1d5175a12b"},
{file = "click-8.1.8.tar.gz", hash = "sha256:ed53c9d8990d83c2a27deae68e4ee337473f6330c040a31d4225c9574d16096a"}, {file = "click-8.2.1.tar.gz", hash = "sha256:27c491cc05d968d271d5a1db13e3b5a184636d9d930f148c50b038f0d0646202"},
] ]
[package.dependencies] [package.dependencies]
@@ -223,14 +223,14 @@ typing = ["typing-extensions (>=4.12.2) ; python_version < \"3.11\""]
[[package]] [[package]]
name = "identify" name = "identify"
version = "2.6.10" version = "2.6.12"
description = "File identification library for Python" description = "File identification library for Python"
optional = false optional = false
python-versions = ">=3.9" python-versions = ">=3.9"
groups = ["dev"] groups = ["dev"]
files = [ files = [
{file = "identify-2.6.10-py2.py3-none-any.whl", hash = "sha256:5f34248f54136beed1a7ba6a6b5c4b6cf21ff495aac7c359e1ef831ae3b8ab25"}, {file = "identify-2.6.12-py2.py3-none-any.whl", hash = "sha256:ad9672d5a72e0d2ff7c5c8809b62dfa60458626352fb0eb7b55e69bdc45334a2"},
{file = "identify-2.6.10.tar.gz", hash = "sha256:45e92fd704f3da71cc3880036633f48b4b7265fd4de2b57627cb157216eb7eb8"}, {file = "identify-2.6.12.tar.gz", hash = "sha256:d8de45749f1efb108badef65ee8386f0f7bb19a7f26185f74de6367bffbaf0e6"},
] ]
[package.extras] [package.extras]
@@ -583,14 +583,14 @@ xmp = ["defusedxml"]
[[package]] [[package]]
name = "platformdirs" name = "platformdirs"
version = "4.3.7" version = "4.3.8"
description = "A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`." description = "A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`."
optional = false optional = false
python-versions = ">=3.9" python-versions = ">=3.9"
groups = ["dev"] groups = ["dev"]
files = [ files = [
{file = "platformdirs-4.3.7-py3-none-any.whl", hash = "sha256:a03875334331946f13c549dbd8f4bac7a13a50a895a0eb1e8c6a8ace80d40a94"}, {file = "platformdirs-4.3.8-py3-none-any.whl", hash = "sha256:ff7059bb7eb1179e2685604f4aaf157cfd9535242bd23742eadc3c13542139b4"},
{file = "platformdirs-4.3.7.tar.gz", hash = "sha256:eb437d586b6a0986388f0d6f74aa0cde27b48d0e3d66843640bfb6bdcdb6e351"}, {file = "platformdirs-4.3.8.tar.gz", hash = "sha256:3d512d96e16bcb959a814c9f348431070822a6496326a4be0911c40b5a74c2bc"},
] ]
[package.extras] [package.extras]
@@ -619,14 +619,14 @@ virtualenv = ">=20.10.0"
[[package]] [[package]]
name = "pygments" name = "pygments"
version = "2.19.1" version = "2.19.2"
description = "Pygments is a syntax highlighting package written in Python." description = "Pygments is a syntax highlighting package written in Python."
optional = false optional = false
python-versions = ">=3.8" python-versions = ">=3.8"
groups = ["main"] groups = ["main"]
files = [ files = [
{file = "pygments-2.19.1-py3-none-any.whl", hash = "sha256:9ea1544ad55cecf4b8242fab6dd35a93bbce657034b0611ee383099054ab6d8c"}, {file = "pygments-2.19.2-py3-none-any.whl", hash = "sha256:86540386c03d588bb81d44bc3928634ff26449851e99741617ecb9037ee5ec0b"},
{file = "pygments-2.19.1.tar.gz", hash = "sha256:61c16d2a8576dc0649d9f39e089b5f02bcd27fba10d8fb4dcc28173f7a45151f"}, {file = "pygments-2.19.2.tar.gz", hash = "sha256:636cb2477cec7f8952536970bc533bc43743542f70392ae026374600add5b887"},
] ]
[package.extras] [package.extras]
@@ -634,14 +634,14 @@ windows-terminal = ["colorama (>=0.4.6)"]
[[package]] [[package]]
name = "python-dotenv" name = "python-dotenv"
version = "1.1.0" version = "1.1.1"
description = "Read key-value pairs from a .env file and set them as environment variables" description = "Read key-value pairs from a .env file and set them as environment variables"
optional = false optional = false
python-versions = ">=3.9" python-versions = ">=3.9"
groups = ["main"] groups = ["main"]
files = [ files = [
{file = "python_dotenv-1.1.0-py3-none-any.whl", hash = "sha256:d7c01d9e2293916c18baf562d95698754b0dbbb5e74d457c45d4f6561fb9d55d"}, {file = "python_dotenv-1.1.1-py3-none-any.whl", hash = "sha256:31f23644fe2602f88ff55e1f5c79ba497e01224ee7737937930c448e4d0e24dc"},
{file = "python_dotenv-1.1.0.tar.gz", hash = "sha256:41f90bc6f5f177fb41f53e87666db362025010eb28f60a01c9143bfa33a2b2d5"}, {file = "python_dotenv-1.1.1.tar.gz", hash = "sha256:a8a6399716257f45be6a007360200409fce5cda2661e3dec71d23dc15f6189ab"},
] ]
[package.extras] [package.extras]
@@ -712,19 +712,19 @@ files = [
[[package]] [[package]]
name = "requests" name = "requests"
version = "2.32.3" version = "2.32.4"
description = "Python HTTP for Humans." description = "Python HTTP for Humans."
optional = false optional = false
python-versions = ">=3.8" python-versions = ">=3.8"
groups = ["main"] groups = ["main"]
files = [ files = [
{file = "requests-2.32.3-py3-none-any.whl", hash = "sha256:70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6"}, {file = "requests-2.32.4-py3-none-any.whl", hash = "sha256:27babd3cda2a6d50b30443204ee89830707d396671944c998b5975b031ac2b2c"},
{file = "requests-2.32.3.tar.gz", hash = "sha256:55365417734eb18255590a9ff9eb97e9e1da868d4ccd6402399eaf68af20a760"}, {file = "requests-2.32.4.tar.gz", hash = "sha256:27d0316682c8a29834d3264820024b62a36942083d52caf2f14c0591336d3422"},
] ]
[package.dependencies] [package.dependencies]
certifi = ">=2017.4.17" certifi = ">=2017.4.17"
charset-normalizer = ">=2,<4" charset_normalizer = ">=2,<4"
idna = ">=2.5,<4" idna = ">=2.5,<4"
urllib3 = ">=1.21.1,<3" urllib3 = ">=1.21.1,<3"
@@ -788,14 +788,14 @@ files = [
[[package]] [[package]]
name = "urllib3" name = "urllib3"
version = "2.4.0" version = "2.5.0"
description = "HTTP library with thread-safe connection pooling, file post, and more." description = "HTTP library with thread-safe connection pooling, file post, and more."
optional = false optional = false
python-versions = ">=3.9" python-versions = ">=3.9"
groups = ["main"] groups = ["main"]
files = [ files = [
{file = "urllib3-2.4.0-py3-none-any.whl", hash = "sha256:4e16665048960a0900c702d4a66415956a584919c03361cac9f1df5c5dd7e813"}, {file = "urllib3-2.5.0-py3-none-any.whl", hash = "sha256:e6b01673c0fa6a13e374b50871808eb3bf7046c4b125b216f6bf1cc604cff0dc"},
{file = "urllib3-2.4.0.tar.gz", hash = "sha256:414bc6535b787febd7567804cc015fee39daab8ad86268f1310a9250697de466"}, {file = "urllib3-2.5.0.tar.gz", hash = "sha256:3fc47733c7e419d4bc3f6b3dc2b4f890bb743906a30d56ba4a5bfa4bbff92760"},
] ]
[package.extras] [package.extras]
@@ -806,14 +806,14 @@ zstd = ["zstandard (>=0.18.0)"]
[[package]] [[package]]
name = "virtualenv" name = "virtualenv"
version = "20.30.0" version = "20.31.2"
description = "Virtual Python Environment builder" description = "Virtual Python Environment builder"
optional = false optional = false
python-versions = ">=3.8" python-versions = ">=3.8"
groups = ["dev"] groups = ["dev"]
files = [ files = [
{file = "virtualenv-20.30.0-py3-none-any.whl", hash = "sha256:e34302959180fca3af42d1800df014b35019490b119eba981af27f2fa486e5d6"}, {file = "virtualenv-20.31.2-py3-none-any.whl", hash = "sha256:36efd0d9650ee985f0cad72065001e66d49a6f24eb44d98980f630686243cf11"},
{file = "virtualenv-20.30.0.tar.gz", hash = "sha256:800863162bcaa5450a6e4d721049730e7f2dae07720e0902b0e4040bd6f9ada8"}, {file = "virtualenv-20.31.2.tar.gz", hash = "sha256:e10c0a9d02835e592521be48b332b6caee6887f332c111aa79a09b9e79efc2af"},
] ]
[package.dependencies] [package.dependencies]
@@ -827,14 +827,14 @@ test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess
[[package]] [[package]]
name = "weeknotebot" name = "weeknotebot"
version = "1.6.1" version = "1.7.0"
description = "A bot for generate WeekNote for Hugo" description = "A bot for generate WeekNote for Hugo"
optional = false optional = false
python-versions = ">=3.10" python-versions = ">=3.10"
groups = ["main"] groups = ["main"]
files = [ files = [
{file = "weeknotebot-1.6.1-py3-none-any.whl", hash = "sha256:528cbf79c69391783073cda30175f796a30b5163dee1e03fe3214d1e57d0924c"}, {file = "weeknotebot-1.7.0-py3-none-any.whl", hash = "sha256:fb1915a2c0171b64038bdbdcc38822d1c75b8c14b36da6651c30a1c01317030b"},
{file = "weeknotebot-1.6.1.tar.gz", hash = "sha256:dcf152ca1e2b6db6244ea4e86ab86f93078ce9d3845a6ba202524aa1e92857c6"}, {file = "weeknotebot-1.7.0.tar.gz", hash = "sha256:66239b40de8835b0961d8ce15e5fe7ca03b0e516d05bfc20b902b5e20af554af"},
] ]
[package.dependencies] [package.dependencies]

View File

@@ -1,7 +1,7 @@
beautifulsoup4==4.13.4 ; python_version >= "3.11" and python_version < "4.0" beautifulsoup4==4.13.4 ; python_version >= "3.11" and python_version < "4.0"
certifi==2025.4.26 ; python_version >= "3.11" and python_version < "4.0" certifi==2025.6.15 ; python_version >= "3.11" and python_version < "4.0"
charset-normalizer==3.4.2 ; python_version >= "3.11" and python_version < "4.0" charset-normalizer==3.4.2 ; python_version >= "3.11" and python_version < "4.0"
click==8.1.8 ; python_version >= "3.11" and python_version < "4.0" click==8.2.1 ; python_version >= "3.11" and python_version < "4.0"
colorama==0.4.6 ; python_version >= "3.11" and python_version < "4.0" and platform_system == "Windows" colorama==0.4.6 ; python_version >= "3.11" and python_version < "4.0" and platform_system == "Windows"
feedparser==6.0.11 ; python_version >= "3.11" and python_version < "4.0" feedparser==6.0.11 ; python_version >= "3.11" and python_version < "4.0"
idna==3.10 ; python_version >= "3.11" and python_version < "4.0" idna==3.10 ; python_version >= "3.11" and python_version < "4.0"
@@ -11,13 +11,13 @@ marshmallow==3.26.1 ; python_version >= "3.11" and python_version < "4.0"
mdurl==0.1.2 ; python_version >= "3.11" and python_version < "4.0" mdurl==0.1.2 ; python_version >= "3.11" and python_version < "4.0"
packaging==25.0 ; python_version >= "3.11" and python_version < "4.0" packaging==25.0 ; python_version >= "3.11" and python_version < "4.0"
pillow==11.2.1 ; python_version >= "3.11" and python_version < "4.0" pillow==11.2.1 ; python_version >= "3.11" and python_version < "4.0"
pygments==2.19.1 ; python_version >= "3.11" and python_version < "4.0" pygments==2.19.2 ; python_version >= "3.11" and python_version < "4.0"
python-dotenv==1.1.0 ; python_version >= "3.11" and python_version < "4.0" python-dotenv==1.1.1 ; python_version >= "3.11" and python_version < "4.0"
pyyaml==6.0.2 ; python_version >= "3.11" and python_version < "4.0" pyyaml==6.0.2 ; python_version >= "3.11" and python_version < "4.0"
requests==2.32.3 ; python_version >= "3.11" and python_version < "4.0" requests==2.32.4 ; python_version >= "3.11" and python_version < "4.0"
rich==13.9.4 ; python_version >= "3.11" and python_version < "4.0" rich==13.9.4 ; python_version >= "3.11" and python_version < "4.0"
sgmllib3k==1.0.0 ; python_version >= "3.11" and python_version < "4.0" sgmllib3k==1.0.0 ; python_version >= "3.11" and python_version < "4.0"
soupsieve==2.7 ; python_version >= "3.11" and python_version < "4.0" soupsieve==2.7 ; python_version >= "3.11" and python_version < "4.0"
typing-extensions==4.14.0 ; python_version >= "3.11" and python_version < "4.0" typing-extensions==4.14.0 ; python_version >= "3.11" and python_version < "4.0"
urllib3==2.4.0 ; python_version >= "3.11" and python_version < "4.0" urllib3==2.5.0 ; python_version >= "3.11" and python_version < "4.0"
weeknotebot==1.6.1 ; python_version >= "3.11" and python_version < "4.0" weeknotebot==1.7.0 ; python_version >= "3.11" and python_version < "4.0"