mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-12-11 21:05:15 -05:00
rebuild dockerfile and startup.py
This commit is contained in:
@@ -4,6 +4,7 @@ import uvicorn
|
||||
from fastapi import FastAPI
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
|
||||
import startup
|
||||
from routes import (
|
||||
backup_routes,
|
||||
meal_routes,
|
||||
@@ -42,6 +43,9 @@ def invalid_api():
|
||||
|
||||
app.include_router(static_routes.router)
|
||||
|
||||
startup.ensure_dirs()
|
||||
startup.generate_default_theme()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logger.info("-----SYSTEM STARTUP-----")
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import json
|
||||
from typing import List, Optional
|
||||
|
||||
from db.settings_models import (SiteSettingsDocument, SiteThemeDocument,
|
||||
ThemeColorsDocument, WebhooksDocument)
|
||||
from db.settings_models import (
|
||||
SiteSettingsDocument,
|
||||
SiteThemeDocument,
|
||||
ThemeColorsDocument,
|
||||
WebhooksDocument,
|
||||
)
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
|
||||
class Webhooks(BaseModel):
|
||||
webhookTime: str
|
||||
webhookURLs: Optional[List[str]]
|
||||
|
||||
40
mealie/startup.py
Normal file
40
mealie/startup.py
Normal file
@@ -0,0 +1,40 @@
|
||||
from pathlib import Path
|
||||
|
||||
from services.settings_services import Colors, SiteTheme
|
||||
from utils.logger import logger
|
||||
|
||||
CWD = Path(__file__).parent
|
||||
DATA_DIR = CWD.joinpath("data")
|
||||
TEMP_DIR = CWD.joinpath("data", "temp")
|
||||
|
||||
|
||||
def ensure_dirs():
|
||||
DATA_DIR.mkdir(parents=True, exist_ok=True)
|
||||
DATA_DIR.joinpath("img").mkdir(parents=True, exist_ok=True)
|
||||
DATA_DIR.joinpath("backups").mkdir(parents=True, exist_ok=True)
|
||||
DATA_DIR.joinpath("templates").mkdir(parents=True, exist_ok=True)
|
||||
|
||||
|
||||
def generate_default_theme():
|
||||
default_colors = {
|
||||
"primary": "#E58325",
|
||||
"accent": "#00457A",
|
||||
"secondary": "#973542",
|
||||
"success": "#5AB1BB",
|
||||
"info": "#FFFD99",
|
||||
"warning": "#FF4081",
|
||||
"error": "#EF5350",
|
||||
}
|
||||
|
||||
try:
|
||||
SiteTheme.get_by_name("default")
|
||||
return "default theme exists"
|
||||
except:
|
||||
logger.info("Generating Default Theme")
|
||||
colors = Colors(**default_colors)
|
||||
default_theme = SiteTheme(name="default", colors=colors)
|
||||
default_theme.save_to_db()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pass
|
||||
Reference in New Issue
Block a user