This commit is contained in:
shiva raj badu 2025-05-12 02:03:15 +05:45
commit 3e34f06093
11 changed files with 104 additions and 2211 deletions

View file

@ -9,7 +9,7 @@ export const baseDir = app.getAppPath();
export const fastapiDir = isDev ? path.join(baseDir, "servers/fastapi") : path.join(baseDir, "resources/fastapi");
export const nextjsDir = isDev ? path.join(baseDir, "servers/nextjs") : path.join(baseDir, "resources/nextjs");
export const tempDir = app.getPath("temp")
export const tempDir = path.join(app.getPath("temp"), "presenton")
export const userDataDir = app.getPath("userData")
export const downloadsDir = app.getPath("downloads")
export const userConfigPath = path.join(userDataDir, "userConfig.json")

View file

@ -12,7 +12,7 @@
"dev": "tsc && electron --gtk-version=3 .",
"setup:env": "npm install && cd servers/fastapi && poetry install && cd ../../servers/nextjs && npm install",
"build:ts": "tsc",
"build:css": "tailwindcss -i ./resources/ui/assets/tailwind.import.css -o ./resources/ui/assets/tailwind.css",
"build:css": "tailwindcss -i ./resources/ui/assets/css/tailwind.import.css -o ./resources/ui/assets/css/tailwind.css --watch",
"build:nextjs": "rm -rf resources/nextjs && cp -r servers/nextjs resources/nextjs && cd resources/nextjs && npm install --omit=dev && npm run build",
"build:fastapi": "rm -rf resources/fastapi && cd servers/fastapi && .venv/bin/pyinstaller --name fastapi --distpath ../../resources server.py",
"build:electron": "tsc && node build.js",

Binary file not shown.

After

Width:  |  Height:  |  Size: 861 KiB

View file

@ -3,13 +3,30 @@
<head>
<title>Presenton Open Source</title>
<link rel="stylesheet" href="../assets/tailwind.css">
<link rel="stylesheet" href="../assets/css/tailwind.css">
<script src="./script.js"></script>
<style>
.loading-circle {
width: 40px;
height: 40px;
border: 4px solid rgba(255, 255, 255, 0.3);
border-radius: 50%;
border-top-color: white;
animation: spin 1s ease-in-out infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
</style>
</head>
<body class="bg-gray-900 text-white flex flex-col items-center justify-center h-screen">
<h1 class="text-4xl font-bold">Presenton Open Source</h1>
<p class="mt-4">Waiting for server to start...</p>
<img src="../assets/images/presenton_logo.png" alt="Presenton Logo" class="h-20">
<p class="mt-20 text-lg">Waiting for server to start...</p>
<div class="loading-circle mt-10"></div>
</body>
</html>

View file

@ -9,8 +9,10 @@ from api.routers.presentation.models import (
ExportAsRequest,
PresentationAndPath,
)
from api.services.database import get_sql_session
from api.services.instances import temp_file_service
from api.services.logging import LoggingService
from api.sql_models import PresentationSqlModel
from api.utils import get_presentation_dir
from image_processor.image_from_pptx import get_pdf_from_pptx
from ppt_generator.pptx_presentation_creator import PptxPresentationCreator
@ -37,12 +39,22 @@ class ExportAsPDFHandler(FetchPresentationAssetsMixin):
await self.fetch_presentation_assets()
ppt_path = os.path.join(self.presentation_dir, "presentation.pptx")
with get_sql_session() as sql_session:
presentation = sql_session.get(
PresentationSqlModel, self.data.presentation_id
)
ppt_path = os.path.join(
self.presentation_dir,
f"{presentation.title.replace('/', '_').replace(' ', '_')}.pptx",
)
ppt_creator = PptxPresentationCreator(self.data.pptx_model, self.temp_dir)
ppt_creator.create_ppt()
ppt_creator.save(ppt_path)
print(ppt_path)
pdf_path = get_pdf_from_pptx(ppt_path, self.presentation_dir)
response = PresentationAndPath(

View file

@ -37,7 +37,15 @@ class ExportAsPptxHandler(FetchPresentationAssetsMixin):
await self.fetch_presentation_assets()
ppt_path = os.path.join(self.presentation_dir, "presentation.pptx")
with get_sql_session() as sql_session:
presentation = sql_session.get(
PresentationSqlModel, self.data.presentation_id
)
ppt_path = os.path.join(
self.presentation_dir,
f"{presentation.title.replace('/', '_').replace(' ', '_')}.pptx",
)
ppt_creator = PptxPresentationCreator(self.data.pptx_model, self.temp_dir)
ppt_creator.create_ppt()
ppt_creator.save(ppt_path)

View file

@ -1,9 +1,10 @@
from contextlib import contextmanager
import os
from sqlalchemy import create_engine
from sqlmodel import Session
sql_url = "sqlite:///sqlite.db"
sql_url = "sqlite:///" + os.path.join(os.getenv("APP_DATA_DIRECTORY"), "fastapi.db")
sql_engine = create_engine(sql_url, connect_args={"check_same_thread": False})

View file

@ -7,6 +7,7 @@ class TempFileService:
base_dir = os.getenv("TEMP_DIRECTORY")
def __init__(self):
self.cleanup_base_dir()
os.makedirs(self.base_dir, exist_ok=True)
def create_dir_in_dir(self, base_dir: str, dir_name: Optional[str] = None) -> str:

View file

@ -8,6 +8,7 @@ from image_processor.utils import get_page_images_from_pdf
def get_pdf_from_pptx(pptx_path: str, temp_dir: str) -> str:
base_name = os.path.splitext(os.path.basename(pptx_path))[0]
print(base_name)
subprocess.run(
f"{os.getenv('LIBREOFFICE')} --headless --invisible --convert-to pdf {pptx_path} --outdir {temp_dir}",
@ -17,6 +18,7 @@ def get_pdf_from_pptx(pptx_path: str, temp_dir: str) -> str:
pdf_filename = f"{base_name}.pdf"
pdf_path = os.path.join(temp_dir, pdf_filename)
print(pdf_path)
return pdf_path