Extract slideshow into a plugin (blueprint-only display plugin)
Second core feature pulled into a plugin. Slides is the minimal plugin shape: a blueprint only - no model, no AssetType, no nav (it is purely an API surface consumed by the TV dashboard). - plugins/slides/: manifest (api_prefix /api/slides, no deps), api/ (moved blueprint, contract-pure imports via shopdb.api, same /api/slides route so the TV dashboard is unchanged), plugin.py (get_blueprint, get_models -> []). - Fixed a latent bug in the move: error path used ErrorCodes.SERVER_ERROR which does not exist -> ErrorCodes.INTERNAL_ERROR. - De-cored: deleted shopdb/core/api/slides.py, removed from CORE_BLUEPRINT_NAMES + core/api/__init__ import/__all__. Registered in instance/plugins.json. Pinned with a characterization test first; passes unchanged against the plugin blueprint. 174 tests pass, naming green, app boots 8 bundled plugins, /api/slides verified live. Note: the shopfloor dashboard is NOT extractable - it is a frontend-only Vue view aggregating the businessunits + notifications APIs, with no backend to move and no frontend plugin system. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -106,7 +106,6 @@ CORE_BLUEPRINT_NAMES = (
|
||||
'reports',
|
||||
'collector',
|
||||
'employees',
|
||||
'slides',
|
||||
'settings',
|
||||
'auditlogs',
|
||||
'users',
|
||||
|
||||
@@ -15,7 +15,6 @@ from .search import search_bp
|
||||
from .reports import reports_bp
|
||||
from .collector import collector_bp
|
||||
from .employees import employees_bp
|
||||
from .slides import slides_bp
|
||||
from .settings import settings_bp
|
||||
from .auditlogs import auditlogs_bp
|
||||
from .users import users_bp
|
||||
@@ -36,7 +35,6 @@ __all__ = [
|
||||
'reports_bp',
|
||||
'collector_bp',
|
||||
'employees_bp',
|
||||
'slides_bp',
|
||||
'settings_bp',
|
||||
'auditlogs_bp',
|
||||
'users_bp',
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
"""Slides API for TV dashboard slideshow."""
|
||||
|
||||
import os
|
||||
from flask import Blueprint, current_app
|
||||
from shopdb.utils.responses import success_response, error_response, ErrorCodes
|
||||
|
||||
slides_bp = Blueprint('slides', __name__)
|
||||
|
||||
# Valid image extensions
|
||||
VALID_EXTENSIONS = {'.jpg', '.jpeg', '.png', '.gif', '.bmp', '.webp'}
|
||||
|
||||
|
||||
@slides_bp.route('', methods=['GET'])
|
||||
def get_slides():
|
||||
"""
|
||||
Get list of slides for TV dashboard.
|
||||
|
||||
Returns image files from the static/slides directory.
|
||||
"""
|
||||
# Look for slides in static folder
|
||||
static_folder = current_app.static_folder
|
||||
if not static_folder:
|
||||
static_folder = os.path.join(current_app.root_path, 'static')
|
||||
|
||||
slides_folder = os.path.join(static_folder, 'slides')
|
||||
|
||||
# Also check frontend public folder
|
||||
frontend_slides = os.path.join(
|
||||
os.path.dirname(os.path.dirname(os.path.dirname(current_app.root_path))),
|
||||
'frontend', 'public', 'slides'
|
||||
)
|
||||
|
||||
# Try multiple possible locations
|
||||
possible_paths = [
|
||||
slides_folder,
|
||||
frontend_slides,
|
||||
'/home/camp/projects/shopdb-flask/shopdb/static/slides',
|
||||
'/home/camp/projects/shopdb-flask/frontend/public/slides',
|
||||
]
|
||||
|
||||
slides_path = None
|
||||
for path in possible_paths:
|
||||
if os.path.isdir(path):
|
||||
slides_path = path
|
||||
break
|
||||
|
||||
if not slides_path:
|
||||
return success_response({
|
||||
'slides': [],
|
||||
'basepath': '/static/slides/',
|
||||
'message': 'Slides folder not found'
|
||||
})
|
||||
|
||||
# Get list of image files
|
||||
slides = []
|
||||
try:
|
||||
for filename in sorted(os.listdir(slides_path)):
|
||||
ext = os.path.splitext(filename)[1].lower()
|
||||
if ext in VALID_EXTENSIONS:
|
||||
slides.append({'filename': filename})
|
||||
except Exception as e:
|
||||
return error_response(
|
||||
ErrorCodes.SERVER_ERROR,
|
||||
f'Error reading slides: {str(e)}',
|
||||
http_code=500
|
||||
)
|
||||
|
||||
# Determine base path for serving files
|
||||
basepath = '/static/slides/'
|
||||
|
||||
return success_response({
|
||||
'slides': slides,
|
||||
'basepath': basepath
|
||||
})
|
||||
Reference in New Issue
Block a user