creaded correct docker image creation file
This commit is contained in:
@@ -516,3 +516,100 @@ def delete_single_leftover(content_id):
|
||||
flash(f'Error deleting file: {str(e)}', 'danger')
|
||||
|
||||
return redirect(url_for('admin.leftover_media'))
|
||||
|
||||
|
||||
@admin_bp.route('/dependencies')
|
||||
@login_required
|
||||
@admin_required
|
||||
def dependencies():
|
||||
"""Show system dependencies status."""
|
||||
import subprocess
|
||||
|
||||
# Check LibreOffice
|
||||
libreoffice_installed = False
|
||||
libreoffice_version = "Not installed"
|
||||
try:
|
||||
result = subprocess.run(['libreoffice', '--version'],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=5)
|
||||
if result.returncode == 0:
|
||||
libreoffice_installed = True
|
||||
libreoffice_version = result.stdout.strip()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Check Poppler (for PDF)
|
||||
poppler_installed = False
|
||||
poppler_version = "Not installed"
|
||||
try:
|
||||
result = subprocess.run(['pdftoppm', '-v'],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=5)
|
||||
if result.returncode == 0 or 'pdftoppm' in result.stderr:
|
||||
poppler_installed = True
|
||||
poppler_version = "Installed"
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Check FFmpeg (for video)
|
||||
ffmpeg_installed = False
|
||||
ffmpeg_version = "Not installed"
|
||||
try:
|
||||
result = subprocess.run(['ffmpeg', '-version'],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=5)
|
||||
if result.returncode == 0:
|
||||
ffmpeg_installed = True
|
||||
ffmpeg_version = result.stdout.split('\n')[0]
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return render_template('admin/dependencies.html',
|
||||
libreoffice_installed=libreoffice_installed,
|
||||
libreoffice_version=libreoffice_version,
|
||||
poppler_installed=poppler_installed,
|
||||
poppler_version=poppler_version,
|
||||
ffmpeg_installed=ffmpeg_installed,
|
||||
ffmpeg_version=ffmpeg_version,
|
||||
emoji_installed=emoji_installed,
|
||||
emoji_version=emoji_version)
|
||||
|
||||
|
||||
@admin_bp.route('/install-libreoffice', methods=['POST'])
|
||||
@login_required
|
||||
@admin_required
|
||||
def install_libreoffice():
|
||||
"""Install LibreOffice for PPTX conversion."""
|
||||
import subprocess
|
||||
|
||||
try:
|
||||
# Run installation script
|
||||
script_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))),
|
||||
'install_libreoffice.sh')
|
||||
|
||||
if not os.path.exists(script_path):
|
||||
flash('Installation script not found', 'danger')
|
||||
return redirect(url_for('admin.dependencies'))
|
||||
|
||||
result = subprocess.run(['sudo', 'bash', script_path],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=300)
|
||||
|
||||
if result.returncode == 0:
|
||||
log_action('info', 'LibreOffice installed successfully')
|
||||
flash('LibreOffice installed successfully! You can now convert PPTX files.', 'success')
|
||||
else:
|
||||
log_action('error', f'LibreOffice installation failed: {result.stderr}')
|
||||
flash(f'Installation failed: {result.stderr}', 'danger')
|
||||
|
||||
except subprocess.TimeoutExpired:
|
||||
flash('Installation timeout. Please try again.', 'warning')
|
||||
except Exception as e:
|
||||
log_action('error', f'Error installing LibreOffice: {str(e)}')
|
||||
flash(f'Error: {str(e)}', 'danger')
|
||||
|
||||
return redirect(url_for('admin.dependencies'))
|
||||
|
||||
@@ -401,8 +401,8 @@ def process_presentation_file(filepath: str, filename: str) -> tuple[bool, str]:
|
||||
continue
|
||||
|
||||
if not libreoffice_cmd:
|
||||
log_action('warning', f'LibreOffice not found, skipping slide conversion for: {filename}')
|
||||
return True, "Presentation accepted without conversion (LibreOffice unavailable)"
|
||||
log_action('warning', f'LibreOffice not found, cannot convert: {filename}')
|
||||
return False, "LibreOffice is not installed. Please install it from the Admin Panel → System Dependencies to upload PowerPoint files."
|
||||
|
||||
# Create temporary directory for conversion
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
|
||||
@@ -70,6 +70,17 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- System Dependencies Card -->
|
||||
<div class="card management-card" style="background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);">
|
||||
<h2>🔧 System Dependencies</h2>
|
||||
<p>Check and install required software dependencies</p>
|
||||
<div class="card-actions">
|
||||
<a href="{{ url_for('admin.dependencies') }}" class="btn btn-primary">
|
||||
View Dependencies
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Quick Actions Card -->
|
||||
<div class="card">
|
||||
<h2>⚡ Quick Actions</h2>
|
||||
|
||||
141
app/templates/admin/dependencies.html
Normal file
141
app/templates/admin/dependencies.html
Normal file
@@ -0,0 +1,141 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}System Dependencies - DigiServer v2{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container" style="max-width: 1000px;">
|
||||
<h1 style="margin-bottom: 25px;">🔧 System Dependencies</h1>
|
||||
|
||||
<div class="card" style="margin-bottom: 20px;">
|
||||
<h2 style="margin-bottom: 20px;">📦 Installed Dependencies</h2>
|
||||
|
||||
<!-- LibreOffice -->
|
||||
<div class="dependency-card" style="background: {% if libreoffice_installed %}#d4edda{% else %}#f8d7da{% endif %}; padding: 20px; border-radius: 8px; margin-bottom: 15px; border-left: 4px solid {% if libreoffice_installed %}#28a745{% else %}#dc3545{% endif %};">
|
||||
<div style="display: flex; justify-content: space-between; align-items: start;">
|
||||
<div style="flex: 1;">
|
||||
<h3 style="margin: 0 0 10px 0; display: flex; align-items: center; gap: 10px;">
|
||||
{% if libreoffice_installed %}
|
||||
<span style="font-size: 24px;">✅</span>
|
||||
{% else %}
|
||||
<span style="font-size: 24px;">❌</span>
|
||||
{% endif %}
|
||||
LibreOffice
|
||||
</h3>
|
||||
<p style="margin: 5px 0; color: #555;">
|
||||
<strong>Purpose:</strong> Required for PowerPoint (PPTX/PPT) to image conversion
|
||||
</p>
|
||||
<p style="margin: 5px 0; color: #555;">
|
||||
<strong>Status:</strong> {{ libreoffice_version }}
|
||||
</p>
|
||||
{% if not libreoffice_installed %}
|
||||
<p style="margin: 10px 0 0 0; color: #721c24;">
|
||||
⚠️ Without LibreOffice, you cannot upload or convert PowerPoint presentations.
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if not libreoffice_installed %}
|
||||
<form method="POST" action="{{ url_for('admin.install_libreoffice') }}" style="margin-left: 20px;">
|
||||
<button type="submit" class="btn btn-success" onclick="return confirm('Install LibreOffice? This may take 2-5 minutes.');">
|
||||
📥 Install LibreOffice
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Poppler Utils -->
|
||||
<div class="dependency-card" style="background: {% if poppler_installed %}#d4edda{% else %}#fff3cd{% endif %}; padding: 20px; border-radius: 8px; margin-bottom: 15px; border-left: 4px solid {% if poppler_installed %}#28a745{% else %}#ffc107{% endif %};">
|
||||
<div style="display: flex; justify-content: space-between; align-items: start;">
|
||||
<div style="flex: 1;">
|
||||
<h3 style="margin: 0 0 10px 0; display: flex; align-items: center; gap: 10px;">
|
||||
{% if poppler_installed %}
|
||||
<span style="font-size: 24px;">✅</span>
|
||||
{% else %}
|
||||
<span style="font-size: 24px;">⚠️</span>
|
||||
{% endif %}
|
||||
Poppler Utils
|
||||
</h3>
|
||||
<p style="margin: 5px 0; color: #555;">
|
||||
<strong>Purpose:</strong> Required for PDF to image conversion
|
||||
</p>
|
||||
<p style="margin: 5px 0; color: #555;">
|
||||
<strong>Status:</strong> {{ poppler_version }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- FFmpeg -->
|
||||
<div class="dependency-card" style="background: {% if ffmpeg_installed %}#d4edda{% else %}#fff3cd{% endif %}; padding: 20px; border-radius: 8px; margin-bottom: 15px; border-left: 4px solid {% if ffmpeg_installed %}#28a745{% else %}#ffc107{% endif %};">
|
||||
<div style="display: flex; justify-content: space-between; align-items: start;">
|
||||
<div style="flex: 1;">
|
||||
<h3 style="margin: 0 0 10px 0; display: flex; align-items: center; gap: 10px;">
|
||||
{% if ffmpeg_installed %}
|
||||
<span style="font-size: 24px;">✅</span>
|
||||
{% else %}
|
||||
<span style="font-size: 24px;">⚠️</span>
|
||||
{% endif %}
|
||||
FFmpeg
|
||||
</h3>
|
||||
<p style="margin: 5px 0; color: #555;">
|
||||
<strong>Purpose:</strong> Required for video processing and validation
|
||||
</p>
|
||||
<p style="margin: 5px 0; color: #555;">
|
||||
<strong>Status:</strong> {{ ffmpeg_version }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="margin-top: 25px; padding: 15px; background: #e7f3ff; border-radius: 8px; border-left: 4px solid #0066cc;">
|
||||
<h4 style="margin: 0 0 10px 0;">ℹ️ Installation Notes</h4>
|
||||
<ul style="margin: 5px 0; padding-left: 25px; color: #555;">
|
||||
<li>LibreOffice can be installed using the button above (requires sudo access)</li>
|
||||
<li>Installation may take 2-5 minutes depending on your internet connection</li>
|
||||
<li>After installation, refresh this page to verify the status</li>
|
||||
<li>Docker containers may require rebuilding to include dependencies</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="margin-top: 20px;">
|
||||
<a href="{{ url_for('admin.admin_panel') }}" class="btn btn-secondary">
|
||||
← Back to Admin Panel
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
body.dark-mode .dependency-card {
|
||||
color: #e2e8f0 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .dependency-card p {
|
||||
color: #cbd5e0 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .dependency-card[style*="#d4edda"] {
|
||||
background: #1e4620 !important;
|
||||
border-left-color: #48bb78 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .dependency-card[style*="#f8d7da"] {
|
||||
background: #5a1e1e !important;
|
||||
border-left-color: #ef5350 !important;
|
||||
}
|
||||
|
||||
body.dark-mode .dependency-card[style*="#fff3cd"] {
|
||||
background: #5a4a1e !important;
|
||||
border-left-color: #ffc107 !important;
|
||||
}
|
||||
|
||||
body.dark-mode div[style*="#e7f3ff"] {
|
||||
background: #1e3a5f !important;
|
||||
border-left-color: #64b5f6 !important;
|
||||
}
|
||||
|
||||
body.dark-mode div[style*="#e7f3ff"] ul {
|
||||
color: #cbd5e0 !important;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user