diff --git a/.dockerignore b/.dockerignore index 8a0fadb..50677da 100644 --- a/.dockerignore +++ b/.dockerignore @@ -20,6 +20,7 @@ ENV/ *.sh !docker-entrypoint.sh !install_libreoffice.sh +!install_emoji_fonts.sh # Database (will be created in volume) instance/ diff --git a/Dockerfile b/Dockerfile index a5e8148..a07e3ad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,7 +42,8 @@ EXPOSE 5000 RUN useradd -m -u 1000 appuser && \ chown -R appuser:appuser /app /docker-entrypoint.sh && \ echo "appuser ALL=(ALL) NOPASSWD: /app/install_libreoffice.sh" >> /etc/sudoers && \ - chmod +x /app/install_libreoffice.sh + echo "appuser ALL=(ALL) NOPASSWD: /app/install_emoji_fonts.sh" >> /etc/sudoers && \ + chmod +x /app/install_libreoffice.sh /app/install_emoji_fonts.sh USER appuser diff --git a/app/blueprints/admin.py b/app/blueprints/admin.py index c77cb49..ac75d14 100644 --- a/app/blueprints/admin.py +++ b/app/blueprints/admin.py @@ -567,6 +567,27 @@ def dependencies(): except Exception: pass + # Check Emoji Fonts + emoji_installed = False + emoji_version = 'Not installed' + try: + result = subprocess.run(['dpkg', '-l', 'fonts-noto-color-emoji'], + capture_output=True, + text=True, + timeout=5) + if result.returncode == 0 and 'ii' in result.stdout: + emoji_installed = True + # Get version from dpkg output + lines = result.stdout.split('\n') + for line in lines: + if 'fonts-noto-color-emoji' in line and line.startswith('ii'): + parts = line.split() + if len(parts) >= 3: + emoji_version = f'Noto Color Emoji {parts[2]}' + break + except Exception: + pass + return render_template('admin/dependencies.html', libreoffice_installed=libreoffice_installed, libreoffice_version=libreoffice_version, @@ -613,3 +634,111 @@ def install_libreoffice(): flash(f'Error: {str(e)}', 'danger') return redirect(url_for('admin.dependencies')) + + +@admin_bp.route('/install-emoji-fonts', methods=['POST']) +@login_required +@admin_required +def install_emoji_fonts(): + """Install Emoji Fonts for better UI display.""" + import subprocess + + try: + # Run installation script + script_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), + 'install_emoji_fonts.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=180) + + if result.returncode == 0: + log_action('info', 'Emoji fonts installed successfully') + flash('Emoji fonts installed successfully! Please restart your browser to see changes.', 'success') + else: + log_action('error', f'Emoji fonts 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 emoji fonts: {str(e)}') + flash(f'Error: {str(e)}', 'danger') + + return redirect(url_for('admin.dependencies')) + + +@admin_bp.route('/customize-logos') +@login_required +@admin_required +def customize_logos(): + """Logo customization page.""" + import time + return render_template('admin/customize_logos.html', version=int(time.time())) + + +@admin_bp.route('/upload-header-logo', methods=['POST']) +@login_required +@admin_required +def upload_header_logo(): + """Upload header logo.""" + try: + if 'header_logo' not in request.files: + flash('No file selected', 'warning') + return redirect(url_for('admin.customize_logos')) + + file = request.files['header_logo'] + if file.filename == '': + flash('No file selected', 'warning') + return redirect(url_for('admin.customize_logos')) + + if file: + # Save as header_logo.png + filename = 'header_logo.png' + filepath = os.path.join(current_app.config['UPLOAD_FOLDER'], filename) + file.save(filepath) + + log_action('info', f'Header logo uploaded: {filename}') + flash('Header logo uploaded successfully!', 'success') + + except Exception as e: + log_action('error', f'Error uploading header logo: {str(e)}') + flash(f'Error uploading logo: {str(e)}', 'danger') + + return redirect(url_for('admin.customize_logos')) + + +@admin_bp.route('/upload-login-logo', methods=['POST']) +@login_required +@admin_required +def upload_login_logo(): + """Upload login page logo.""" + try: + if 'login_logo' not in request.files: + flash('No file selected', 'warning') + return redirect(url_for('admin.customize_logos')) + + file = request.files['login_logo'] + if file.filename == '': + flash('No file selected', 'warning') + return redirect(url_for('admin.customize_logos')) + + if file: + # Save as login_logo.png + filename = 'login_logo.png' + filepath = os.path.join(current_app.config['UPLOAD_FOLDER'], filename) + file.save(filepath) + + log_action('info', f'Login logo uploaded: {filename}') + flash('Login logo uploaded successfully!', 'success') + + except Exception as e: + log_action('error', f'Error uploading login logo: {str(e)}') + flash(f'Error uploading logo: {str(e)}', 'danger') + + return redirect(url_for('admin.customize_logos')) diff --git a/app/config.py b/app/config.py index 93713cd..c94bea0 100644 --- a/app/config.py +++ b/app/config.py @@ -18,7 +18,7 @@ class Config: # File Upload - use absolute paths MAX_CONTENT_LENGTH = 2048 * 1024 * 1024 # 2GB - _basedir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) + _basedir = os.path.abspath(os.path.dirname(__file__)) UPLOAD_FOLDER = os.path.join(_basedir, 'static', 'uploads') UPLOAD_FOLDERLOGO = os.path.join(_basedir, 'static', 'resurse') ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif', 'bmp', 'mp4', 'avi', 'mkv', 'mov', 'webm', 'pdf', 'ppt', 'pptx'} diff --git a/app/templates/admin/admin.html b/app/templates/admin/admin.html index c91cdf4..d23409a 100644 --- a/app/templates/admin/admin.html +++ b/app/templates/admin/admin.html @@ -81,6 +81,17 @@ + +
Upload custom logos for header and login page
+ +
+ This logo appears in the top header next to "DigiServer" text.
+ Recommended: 150x40 pixels (or similar aspect ratio), transparent background PNG
+
+ Current Header Logo
+
+ This logo appears on the left side of the login page (2/3 of screen).
+ Recommended: 800x600 pixels (or similar), transparent background PNG
+
+
+ + Purpose: Better emoji display in UI (optional, mainly for Raspberry Pi) +
++ Status: {{ emoji_version }} +
+ {% if not emoji_installed %} ++ âšī¸ Optional: Improves emoji rendering on systems without native emoji support. +
+ {% endif %} +