generated from hjess/PythonTemplateProject
[main] Images images images
All checks were successful
Build, Push, and Deploy to Nomad / docker-nomad (push) Successful in 51s
All checks were successful
Build, Push, and Deploy to Nomad / docker-nomad (push) Successful in 51s
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -21,6 +21,7 @@ class Application:
|
||||
|
||||
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def _lifespan_event(self, app: FastAPI):
|
||||
"""Lifespan event for startup and shutdown logic."""
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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)
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -5,7 +5,7 @@ author: Henrik Jess
|
||||
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.
|
||||
favorite: true
|
||||
image: images/budget2.jpg
|
||||
image: budget2.jpg
|
||||
category: Økonomi
|
||||
tags: [Portugal, Budget, Økonomi]
|
||||
---
|
||||
|
||||
BIN
data/Budget/images/budget2.jpg
Normal file
BIN
data/Budget/images/budget2.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 46 KiB |
@@ -89,7 +89,9 @@
|
||||
"favorites": [
|
||||
{
|
||||
"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.",
|
||||
"path": "Budget"
|
||||
}
|
||||
|
||||
BIN
static/images/Budget/thumbnails/budget2.jpg
Normal file
BIN
static/images/Budget/thumbnails/budget2.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.8 KiB |
BIN
static/images/Budget/thumbnails/budget2.webp
Normal file
BIN
static/images/Budget/thumbnails/budget2.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.7 KiB |
@@ -26,8 +26,8 @@
|
||||
{% for favorite in data.favorites %}
|
||||
<article>
|
||||
<a href="/category/{{ favorite.path }}" class="image">
|
||||
|
||||
<img src="/static/{{favorite.image}}" alt="{{ favorite.name }}" height="20%" width="20%" />
|
||||
<!-- <img src="/{{favorite.image}}" alt="{{ favorite.name }}" height="20%" width="20%" /> -->
|
||||
<img src="/{{favorite.image}}" alt="{{ favorite.name }}" height="{{ favorite.height }}" width="{{ favorite.width }}" />
|
||||
</a>
|
||||
<p><b>{{ favorite.path }}</b>: {{ favorite.description }}</p>
|
||||
</article>
|
||||
|
||||
Reference in New Issue
Block a user