FossilRepo

fossilrepo / templates / fossil / technote_form.html
1
{% extends "base.html" %}
2
{% block title %}{{ form_title }} — {{ project.name }} — Fossilrepo{% endblock %}
3
4
{% block extra_head %}
5
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
6
{% endblock %}
7
8
{% block content %}
9
<h1 class="text-2xl font-bold text-gray-100 mb-2">{{ project.name }}</h1>
10
{% include "fossil/_project_nav.html" %}
11
12
<div class="mb-4">
13
<a href="{% url 'fossil:technotes' slug=project.slug %}" class="text-sm text-brand-light hover:text-brand">&larr; Back to Technotes</a>
14
</div>
15
16
<div class="mx-auto max-w-6xl" x-data="{ tab: 'write' }">
17
<div class="flex items-center justify-between mb-4">
18
<h2 class="text-xl font-bold text-gray-100">{{ form_title }}</h2>
19
<div class="flex items-center gap-1 text-xs">
20
<button @click="tab = 'write'" :class="tab === 'write' ? 'bg-brand text-white' : 'text-gray-500 hover:text-white'" class="px-3 py-1 rounded">Write</button>
21
<button @click="tab = 'preview'; document.getElementById('preview-pane').innerHTML = DOMPurify.sanitize(marked.parse(document.getElementById('content-input').value))" :class="tab === 'preview' ? 'bg-brand text-white' : 'text-gray-500 hover:text-white'" class="px-3 py-1 rounded">Preview</button>
22
</div>
23
</div>
24
25
<form method="post" class="space-y-4 rounded-lg bg-gray-800 p-6 shadow border border-gray-700">
26
{% csrf_token %}
27
28
{% if not note %}
29
<div>
30
<label class="block text-sm font-medium text-gray-300 mb-1">Title <span class="text-red-400">*</span></label>
31
<input type="text" name="title" required placeholder="Technote title"
32
class="w-full rounded-md border-gray-700 bg-gray-800 text-gray-100 shadow-sm focus:border-brand focus:ring-brand sm:text-sm">
33
</div>
34
35
<div>
36
<label class="block text-sm font-medium text-gray-300 mb-1">Timestamp</label>
37
<input type="datetime-local" name="timestamp"
38
class="w-full rounded-md border-gray-700 bg-gray-800 text-gray-100 shadow-sm focus:border-brand focus:ring-brand sm:text-sm">
39
<p class="mt-1 text-xs text-gray-500">Leave blank to use current time.</p>
40
</div>
41
{% endif %}
42
43
<div x-show="tab === 'write'">
44
<label class="block text-sm font-medium text-gray-300 mb-1">Body (Markdown)</label>
45
<textarea id="content-input" name="body" rows="20" placeholder="Write in Markdown..."
46
class="w-full rounded-md border-gray-700 bg-gray-800 text-gray-100 shadow-sm focus:border-brand focus:ring-brand sm:text-sm font-mono">{% if note %}{{ note.body }}{% endif %}</textarea>
47
</div>
48
49
<div x-show="tab === 'preview'" style="display:none">
50
<div id="preview-pane" class="prose prose-invert prose-gray max-w-none min-h-[20rem] p-4 rounded-md border border-gray-700 bg-gray-900">
51
<p class="text-gray-500 italic">Click Preview to render...</p>
52
</div>
53
</div>
54
55
<div class="flex justify-end gap-3 pt-2">
56
<a href="{% url 'fossil:technotes' slug=project.slug %}"
57
class="rounded-md bg-gray-700 px-4 py-2 text-sm font-semibold text-gray-100 shadow-sm ring-1 ring-inset ring-gray-600 hover:bg-gray-600">
58
Cancel
59
</a>
60
<button type="submit" class="rounded-md bg-brand px-4 py-2 text-sm font-semibold text-white shadow-sm hover:bg-brand-hover">
61
{% if note %}Update{% else %}Create Technote{% endif %}
62
</button>
63
</div>
64
</form>
65
</div>
66
{% endblock %}
67

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button