[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

@@ -21,6 +21,7 @@ class Application:
@asynccontextmanager @asynccontextmanager
async def _lifespan_event(self, app: FastAPI): async def _lifespan_event(self, app: FastAPI):
"""Lifespan event for startup and shutdown logic.""" """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. list: A list of processed sections containing metadata and rendered content.
""" """
from pathlib import Path from pathlib import Path
sections = [] sections = []
for file in sorted(os.listdir(directory_path)): for file in sorted(os.listdir(directory_path)):
if file.endswith(".md"): if file.endswith(".md"):
file_path = os.path.join(directory_path, file) file_path = os.path.join(directory_path, file)

View File

@@ -5,6 +5,8 @@ from typing import List, Dict
from fastapi import FastAPI from fastapi import FastAPI
from app.services.image_service import ImageService, FileHandler
class MetadataProcessor: class MetadataProcessor:
""" """
@@ -22,6 +24,7 @@ class MetadataProcessor:
""" """
self.input_dir = input_dir self.input_dir = input_dir
self.output_file = output_file self.output_file = output_file
self.app = app
self.data = {"categories": [], "favorites": []} self.data = {"categories": [], "favorites": []}
def _extract_metadata(self, file_path: str) -> Dict: def _extract_metadata(self, file_path: str) -> Dict:
@@ -66,11 +69,25 @@ class MetadataProcessor:
# Add to 'favorites' if 'favorite' is true # Add to 'favorites' if 'favorite' is true
if metadata.get("favorite") and metadata["favorite"].lower() == "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({ self.data["favorites"].append({
"name": metadata.get("name", "Unknown"), "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"), "description": metadata.get("summary", "No description provided"),
"path": os.path.relpath(root, self.input_dir).replace(os.sep, "/"), "path": category,
}) })
def generate_json(self): def generate_json(self):

View File

@@ -5,7 +5,7 @@ author: Henrik Jess
date: ons 11 dec 23:25:00 CET 2024 date: ons 11 dec 23:25:00 CET 2024
summary: Fødevarer er markant billigere i Portugal med få undtagelser som bær og specialvarer. summary: Fødevarer er markant billigere i Portugal med få undtagelser som bær og specialvarer.
favorite: true favorite: true
image: images/budget2.jpg image: budget2.jpg
category: Økonomi category: Økonomi
tags: [Portugal, Budget, Økonomi] tags: [Portugal, Budget, Økonomi]
--- ---

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

View File

@@ -89,7 +89,9 @@
"favorites": [ "favorites": [
{ {
"name": "Budget - Indkøb", "name": "Budget - Indkøb",
"image": "images/budget2.jpg", "image": "static/images/Budget/thumbnails/budget2.webp",
"height": 150,
"width": 150,
"description": "Fødevarer er markant billigere i Portugal med få undtagelser som bær og specialvarer.", "description": "Fødevarer er markant billigere i Portugal med få undtagelser som bær og specialvarer.",
"path": "Budget" "path": "Budget"
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@@ -26,8 +26,8 @@
{% for favorite in data.favorites %} {% for favorite in data.favorites %}
<article> <article>
<a href="/category/{{ favorite.path }}" class="image"> <a href="/category/{{ favorite.path }}" class="image">
<!-- <img src="/{{favorite.image}}" alt="{{ favorite.name }}" height="20%" width="20%" /> -->
<img src="/static/{{favorite.image}}" alt="{{ favorite.name }}" height="20%" width="20%" /> <img src="/{{favorite.image}}" alt="{{ favorite.name }}" height="{{ favorite.height }}" width="{{ favorite.width }}" />
</a> </a>
<p><b>{{ favorite.path }}</b>: {{ favorite.description }}</p> <p><b>{{ favorite.path }}</b>: {{ favorite.description }}</p>
</article> </article>