mirror of
https://gitea.baerentsen.space/FrederikBaerentsen/BrickTracker.git
synced 2026-01-05 16:20:03 -06:00
fix(inst): fixed folder path for instructions
This commit is contained in:
@@ -230,10 +230,16 @@ class BrickInstructions(object):
|
||||
|
||||
folder: str = current_app.config['INSTRUCTIONS_FOLDER']
|
||||
|
||||
# Compute the path
|
||||
path = os.path.join(folder, self.filename)
|
||||
|
||||
return url_for('static', filename=path)
|
||||
# Determine which route to use based on folder path
|
||||
# If folder contains 'data' (new structure), use data route
|
||||
# Otherwise use static route (legacy)
|
||||
if 'data' in folder:
|
||||
return url_for('data.serve_data_file', folder='instructions', filename=self.filename)
|
||||
else:
|
||||
# Legacy: folder is relative to static/
|
||||
folder_clean = folder.removeprefix('static/')
|
||||
path = os.path.join(folder_clean, self.filename)
|
||||
return url_for('static', filename=path)
|
||||
|
||||
# Return the icon depending on the extension
|
||||
def icon(self, /) -> str:
|
||||
|
||||
@@ -36,11 +36,14 @@ class BrickInstructionsList(object):
|
||||
|
||||
# Try to list the files in the instruction folder
|
||||
try:
|
||||
# Make a folder relative to static
|
||||
folder: str = os.path.join(
|
||||
current_app.static_folder, # type: ignore
|
||||
current_app.config['INSTRUCTIONS_FOLDER'],
|
||||
)
|
||||
folder_config: str = current_app.config['INSTRUCTIONS_FOLDER']
|
||||
|
||||
# If folder is absolute, use it directly
|
||||
# Otherwise, make it relative to app root (not static folder)
|
||||
if os.path.isabs(folder_config):
|
||||
folder = folder_config
|
||||
else:
|
||||
folder = os.path.join(current_app.root_path, folder_config)
|
||||
|
||||
for file in os.scandir(folder):
|
||||
instruction = BrickInstructions(file)
|
||||
|
||||
Reference in New Issue
Block a user