updated to see help page
This commit is contained in:
@@ -3515,6 +3515,63 @@ def api_daily_mirror_history_data():
|
||||
"""Redirect to new Daily Mirror API history data route"""
|
||||
return redirect(url_for('daily_mirror.api_daily_mirror_history_data') + '?' + request.query_string.decode())
|
||||
|
||||
# Help/Documentation Routes
|
||||
@bp.route('/help')
|
||||
@bp.route('/help/<page>')
|
||||
def help(page='index'):
|
||||
"""Display help documentation from Markdown files"""
|
||||
import markdown
|
||||
import os
|
||||
|
||||
# Map page names to markdown files
|
||||
doc_files = {
|
||||
'index': 'index.md',
|
||||
'dashboard': 'dashboard.md',
|
||||
'print_module': 'print_module.md',
|
||||
'upload_data': 'upload_data.md',
|
||||
'view_orders': 'view_orders.md',
|
||||
'print_lost_labels': 'print_lost_labels.md'
|
||||
}
|
||||
|
||||
# Get the markdown file path
|
||||
if page not in doc_files:
|
||||
return render_template('docs/help_viewer.html',
|
||||
error=f"Documentația pentru '{page}' nu a fost găsită.")
|
||||
|
||||
doc_path = os.path.join(current_app.static_folder, 'docs', doc_files[page])
|
||||
|
||||
try:
|
||||
# Read and convert markdown to HTML
|
||||
with open(doc_path, 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
# Convert markdown to HTML with extensions
|
||||
html_content = markdown.markdown(content, extensions=[
|
||||
'markdown.extensions.tables',
|
||||
'markdown.extensions.fenced_code',
|
||||
'markdown.extensions.toc'
|
||||
])
|
||||
|
||||
# Fix image paths to work with Flask static files
|
||||
import re
|
||||
from flask import url_for
|
||||
html_content = re.sub(
|
||||
r'src="images/([^"]+)"',
|
||||
lambda m: f'src="{url_for("static", filename=f"docs/images/{m.group(1)}")}"',
|
||||
html_content
|
||||
)
|
||||
|
||||
return render_template('docs/help_viewer.html',
|
||||
content=html_content,
|
||||
page=page)
|
||||
|
||||
except FileNotFoundError:
|
||||
return render_template('docs/help_viewer.html',
|
||||
error=f"Fișierul de documentație '{doc_files[page]}' nu a fost găsit.")
|
||||
except Exception as e:
|
||||
return render_template('docs/help_viewer.html',
|
||||
error=f"Eroare la încărcarea documentației: {str(e)}")
|
||||
|
||||
# NOTE for frontend/extension developers:
|
||||
# To print labels, call the Chrome extension and pass the PDF URL:
|
||||
# /generate_labels_pdf/<order_id>
|
||||
|
||||
Reference in New Issue
Block a user