Spaces:
Runtime error
Runtime error
Commit ·
1fb0a63
1
Parent(s): 2352ba6
feat: add note preview template with dynamic content and media handling
Browse files
app/templates/note_preview.html
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% extends "base.html" %}
|
| 2 |
+
|
| 3 |
+
{% block content %}
|
| 4 |
+
<div class="max-w-7xl mx-auto px-4 sm:px-6">
|
| 5 |
+
<div class="mb-8 text-center">
|
| 6 |
+
<a href="{{ url_for('notes.list') }}" class="inline-flex items-center gap-2 font-mono text-sm text-gray-400 hover:text-blue-400 transition mb-6">
|
| 7 |
+
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 8 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"/>
|
| 9 |
+
</svg>
|
| 10 |
+
Back to Notes
|
| 11 |
+
</a>
|
| 12 |
+
|
| 13 |
+
<h1 class="font-display text-5xl font-bold tracking-tight mb-4">
|
| 14 |
+
{{ note.title }}
|
| 15 |
+
</h1>
|
| 16 |
+
|
| 17 |
+
<div class="flex flex-wrap gap-3 mb-6 justify-center">
|
| 18 |
+
<span class="px-4 py-2 bg-blue-500/20 border border-blue-500/50 rounded-lg font-mono text-sm">
|
| 19 |
+
{{ note.subject.name }}
|
| 20 |
+
</span>
|
| 21 |
+
<span class="px-4 py-2 bg-purple-500/20 border border-purple-500/50 rounded-lg font-mono text-sm">
|
| 22 |
+
{{ note.note_type.name }}
|
| 23 |
+
</span>
|
| 24 |
+
<span class="glass rounded-lg font-mono text-sm text-gray-400 flex items-center gap-2 px-3 py-2">
|
| 25 |
+
<img src="https://api.dicebear.com/9.x/thumbs/svg?seed={{ note.user.email }}" alt="{{ note.user.name }} Avatar" class="w-6 h-6 rounded-full">
|
| 26 |
+
by {{ note.user.name }}
|
| 27 |
+
</span>
|
| 28 |
+
<span class="px-4 py-2 glass rounded-lg font-mono text-sm text-gray-400">
|
| 29 |
+
{{ note.created_at.strftime('%b %d, %Y') }}
|
| 30 |
+
</span>
|
| 31 |
+
</div>
|
| 32 |
+
|
| 33 |
+
{% if note.description %}
|
| 34 |
+
<p class="font-mono text-gray-300 mb-6">{{ note.description }}</p>
|
| 35 |
+
{% endif %}
|
| 36 |
+
</div>
|
| 37 |
+
|
| 38 |
+
<!-- Preview Area -->
|
| 39 |
+
<div class="glass p-8 rounded-2xl mb-8">
|
| 40 |
+
{% if note.original_link %}
|
| 41 |
+
<div class="text-center">
|
| 42 |
+
<p class="font-mono text-sm text-gray-400 mb-4">External Link</p>
|
| 43 |
+
<a href="{{ note.presigned_url }}" target="_blank" class="inline-flex items-center gap-2 font-mono text-blue-400 hover:text-blue-300 transition break-all">
|
| 44 |
+
{{ note.presigned_url }}
|
| 45 |
+
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 46 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"/>
|
| 47 |
+
</svg>
|
| 48 |
+
</a>
|
| 49 |
+
</div>
|
| 50 |
+
{% else %}
|
| 51 |
+
{% set ext = note.link.split('.')[-1].lower() %}
|
| 52 |
+
|
| 53 |
+
{% if ext in ['jpg', 'jpeg', 'png', 'gif', 'webp'] %}
|
| 54 |
+
<img src="{{ note.presigned_url }}" class="w-full rounded-xl" alt="{{ note.title }}">
|
| 55 |
+
{% elif ext == 'pdf' %}
|
| 56 |
+
<iframe src="{{ note.presigned_url }}" class="w-full h-[600px] rounded-xl bg-white/5"></iframe>
|
| 57 |
+
{% elif ext in ['mp4', 'webm', 'ogg'] %}
|
| 58 |
+
<video controls class="w-full rounded-xl">
|
| 59 |
+
<source src="{{ note.presigned_url }}" type="video/{{ ext }}">
|
| 60 |
+
</video>
|
| 61 |
+
{% elif ext in ['mp3', 'wav', 'ogg'] %}
|
| 62 |
+
<audio controls class="w-full">
|
| 63 |
+
<source src="{{ note.presigned_url }}" type="audio/{{ ext }}">
|
| 64 |
+
</audio>
|
| 65 |
+
{% elif ext in ['txt', 'md'] %}
|
| 66 |
+
<iframe src="{{ note.presigned_url }}" class="w-full h-[600px] rounded-xl bg-white/5"></iframe>
|
| 67 |
+
{% else %}
|
| 68 |
+
<div class="text-center py-12">
|
| 69 |
+
<p class="font-mono text-gray-400 mb-4">Preview not available for this file type</p>
|
| 70 |
+
<p class="font-mono text-sm text-gray-500">{{ note.link.split('/')[-1] }}</p>
|
| 71 |
+
</div>
|
| 72 |
+
{% endif %}
|
| 73 |
+
{% endif %}
|
| 74 |
+
</div>
|
| 75 |
+
|
| 76 |
+
<!-- Actions -->
|
| 77 |
+
<div class="flex gap-4 justify-center">
|
| 78 |
+
{% if note.presigned_url %}
|
| 79 |
+
<a href="{{ note.presigned_url }}" download class="btn-magnetic glass px-8 py-4 rounded-xl font-mono font-semibold border-2 border-blue-500/50 hover:border-blue-400 animate-glow">
|
| 80 |
+
Download
|
| 81 |
+
</a>
|
| 82 |
+
{% endif %}
|
| 83 |
+
<a href="{{ url_for('notes.share', id=note.id) }}" class="btn-magnetic glass px-8 py-4 rounded-xl font-mono font-semibold hover:bg-white/5">
|
| 84 |
+
Share
|
| 85 |
+
</a>
|
| 86 |
+
</div>
|
| 87 |
+
</div>
|
| 88 |
+
{% endblock %}
|