Added Commands Management

This commit is contained in:
2025-10-24 23:02:44 +02:00
parent a4e122f4ea
commit 06aff27cad
26 changed files with 88445 additions and 2 deletions

View File

@@ -0,0 +1,21 @@
# Generate Icons
Create the icons files for FastHtml applications.
## How to generate the svg files
```sh
npm i -D @sicons/fa
npm i -D @sicons/fluent
npm i -D @sicons/ionicons4
npm i -D @sicons/ionicons5
npm i -D @sicons/antd
npm i -D @sicons/material
npm i -D @sicons/tabler
npm i -D @sicons/carbon
```
Update the root folder in `update_icons.py` to point to the root folder of the icons.
##
```sh
python update_icons.py
```

View File

1679
src/myfasthtml/icons/antd.py Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1617
src/myfasthtml/icons/fa.py Normal file

File diff suppressed because one or more lines are too long

30900
src/myfasthtml/icons/fluent.py Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

10870
src/myfasthtml/icons/tabler.py Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,51 @@
import os
root_folder = "/home/kodjo/Dev/MyDocManager/src/frontend/node_modules/@sicons"
import re
def pascal_to_snake(name: str) -> str:
"""Convert a PascalCase or CamelCase string to snake_case."""
# Insert underscore before capital letters (except the first one)
s1 = re.sub(r'(.)([A-Z][a-z]+)', r'\1_\2', name)
# Handle consecutive capital letters (like 'HTTPServer' -> 'http_server')
s2 = re.sub(r'([a-z0-9])([A-Z])', r'\1_\2', s1)
return s2.lower()
def create_icons(file, icon_folder):
for filename in os.listdir(f"{root_folder}/{icon_folder}"):
print("#", end='')
if not filename.endswith(".svg"):
continue
with open(f"{root_folder}/{icon_folder}/{filename}", "r") as f_read:
svg_content = f_read.read().strip()
icon_name = "icon_" + pascal_to_snake(filename.split('.')[0])
file.write(f"{icon_name} = NotStr('''{svg_content}''')\n")
print("")
if __name__ == "__main__":
for folder in ["antd", "material", "carbon", "fa", "fluent", "ionicons4", "ionicons5", "tabler"]:
# for folder in ["antd"]:
print(f"Processing icons for {folder}")
with open(f"{folder}.py", "w") as f_write:
# Add README.md content to the top of the file
if os.path.exists(f"{root_folder}/{folder}/README.md"):
with open(f"{root_folder}/{folder}/README.md", "r") as f_readme:
for line in f_readme:
if line.startswith("#"):
f_write.write(line)
else:
f_write.write(f"# {line}")
f_write.write("\n\n")
# Add imports
f_write.write("from fastcore.basics import NotStr\n\n")
# Add icons
create_icons(f_write, folder)