Add YAML output on debug page.

This commit is contained in:
Edward Betts 2025-11-14 16:16:54 +00:00
parent 7e2b79c672
commit 91a74fd887
2 changed files with 15 additions and 8 deletions

View file

@ -4,7 +4,7 @@
{% block style %} {% block style %}
<style> <style>
.json-display { .data-display {
background-color: #f8f9fa; background-color: #f8f9fa;
border: 1px solid #dee2e6; border: 1px solid #dee2e6;
border-radius: 0.375rem; border-radius: 0.375rem;
@ -72,13 +72,18 @@
<h1>🐛 Trip Debug Information</h1> <h1>🐛 Trip Debug Information</h1>
<p>Raw trip object data for: <strong>{{ trip.title }}</strong></p> <p>Raw trip object data for: <strong>{{ trip.title }}</strong></p>
<a href="{{ url_for('trip_page', start=start) }}" class="btn btn-primary">← Back to Trip Page</a> <a href="{{ url_for('trip_page', start=start) }}" class="btn btn-primary">← Back to Trip Page</a>
<button onclick="copyToClipboard()" class="btn btn-secondary">📋 Copy JSON</button> <button onclick="copyToClipboard('jsonDisplay', event)" class="btn btn-secondary">📋 Copy JSON</button>
<button onclick="copyToClipboard('yamlDisplay', event)" class="btn btn-secondary">📋 Copy YAML</button>
</div> </div>
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<h3>Trip Object (JSON)</h3> <h3>Trip Object (JSON)</h3>
<div class="json-display" id="jsonDisplay">{{ trip_json }}</div> <div class="data-display json-display" id="jsonDisplay">{{ trip_json }}</div>
</div>
<div class="col-12 mt-4">
<h3>Trip Object (YAML)</h3>
<div class="data-display" id="yamlDisplay">{{ trip_yaml }}</div>
</div> </div>
</div> </div>
</div> </div>
@ -86,11 +91,11 @@
{% block scripts %} {% block scripts %}
<script> <script>
function copyToClipboard() { function copyToClipboard(elementId, evt) {
const jsonText = document.getElementById('jsonDisplay').textContent; const clipText = document.getElementById(elementId).textContent;
navigator.clipboard.writeText(jsonText).then(function() { navigator.clipboard.writeText(clipText).then(function() {
// Show a temporary notification // Show a temporary notification
const btn = event.target; const btn = evt.target;
const originalText = btn.textContent; const originalText = btn.textContent;
btn.textContent = '✅ Copied!'; btn.textContent = '✅ Copied!';
btn.classList.remove('btn-secondary'); btn.classList.remove('btn-secondary');
@ -125,4 +130,4 @@ function highlightJSON() {
// Apply highlighting when page loads // Apply highlighting when page loads
document.addEventListener('DOMContentLoaded', highlightJSON); document.addEventListener('DOMContentLoaded', highlightJSON);
</script> </script>
{% endblock %} {% endblock %}

View file

@ -760,11 +760,13 @@ def trip_debug_page(start: str) -> str:
# Convert to JSON for pretty printing # Convert to JSON for pretty printing
trip_json = json.dumps(trip_dict, indent=2, default=str) trip_json = json.dumps(trip_dict, indent=2, default=str)
trip_yaml = yaml.safe_dump(json.loads(trip_json), sort_keys=False)
return flask.render_template( return flask.render_template(
"trip_debug.html", "trip_debug.html",
trip=trip, trip=trip,
trip_json=trip_json, trip_json=trip_json,
trip_yaml=trip_yaml,
start=start, start=start,
) )