[main] Images images images
All checks were successful
Build, Push, and Deploy to Nomad / docker-nomad (push) Successful in 51s

This commit is contained in:
2024-12-30 21:37:36 +01:00
parent 13bc417d45
commit 7f08417eb1
14 changed files with 27 additions and 11 deletions

Binary file not shown.

View File

@@ -13,7 +13,7 @@ from app.services.image_service import ImageService
class Application:
def __init__(self):
"""Initialize the FastAPI app and configure it."""
self.app = FastAPI(lifespan=self._lifespan_event)
self.app = FastAPI( lifespan = self._lifespan_event )
self._set_image_sizes()
self._setup_static_files()
self._include_routers()
@@ -21,6 +21,7 @@ class Application:
@asynccontextmanager
async def _lifespan_event(self, app: FastAPI):
"""Lifespan event for startup and shutdown logic."""

View File

@@ -35,11 +35,7 @@ class MarkdownProcessor:
list: A list of processed sections containing metadata and rendered content.
"""
from pathlib import Path
sections = []
for file in sorted(os.listdir(directory_path)):
if file.endswith(".md"):
file_path = os.path.join(directory_path, file)

View File

@@ -5,6 +5,8 @@ from typing import List, Dict
from fastapi import FastAPI
from app.services.image_service import ImageService, FileHandler
class MetadataProcessor:
"""
@@ -22,6 +24,7 @@ class MetadataProcessor:
"""
self.input_dir = input_dir
self.output_file = output_file
self.app = app
self.data = {"categories": [], "favorites": []}
def _extract_metadata(self, file_path: str) -> Dict:
@@ -66,11 +69,25 @@ class MetadataProcessor:
# Add to 'favorites' if 'favorite' is true
if metadata.get("favorite") and metadata["favorite"].lower() == "true":
image_type = "thumbnails"
category = os.path.relpath( root, self.input_dir ).replace( os.sep, "/" )
filehandler = FileHandler(category=category, image_type=image_type, filename=metadata.get("image"))
imageservice = ImageService(self.app)
default_size = imageservice.get_image_size( image_type )
width = default_size.get( "width" )
height = default_size.get( "height" )
image_tag = imageservice.image_tag(category, image_type, metadata.get("image","Unkown"))
print(filehandler.dest_filename_webp)
print(image_tag)
self.data["favorites"].append({
"name": metadata.get("name", "Unknown"),
"image": metadata.get("image", "images/default.jpg"),
"image": filehandler.dest_filename_webp,
"height": height,
"width": width,
"description": metadata.get("summary", "No description provided"),
"path": os.path.relpath(root, self.input_dir).replace(os.sep, "/"),
"path": category,
})
def generate_json(self):