This commit is contained in:
piecka 2025-03-21 11:19:20 +01:00
commit 42f1d1012f
18 changed files with 399 additions and 0 deletions

91
app/templates/index.html Normal file
View file

@ -0,0 +1,91 @@
<!DOCTYPE html>
<html>
<head>
<title>Markdown Viewer</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/digitallytailored/classless@latest/classless.min.css">
<style>
.file-list {
margin: 2em 0;
}
.file-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.75em;
border-bottom: 1px solid #eee;
}
.file-item:hover {
background-color: #f9f9f9;
}
.file-link {
font-weight: bold;
text-decoration: none;
}
.file-uri {
color: #666;
font-size: 0.9em;
}
.copy-button {
background: #f0f0f0;
border: 1px solid #ddd;
padding: 0.25em 0.5em;
border-radius: 4px;
cursor: pointer;
font-size: 0.8em;
}
.empty-state {
text-align: center;
padding: 3em;
background-color: #f9f9f9;
border-radius: 4px;
margin: 2em 0;
}
</style>
</head>
<body>
<h1>Markdown Viewer</h1>
<div class="actions">
<a href="{{ url_for('main.upload_file') }}" class="button">Upload New Document</a>
</div>
{% if documents %}
<div class="file-list">
<h2>Available Documents</h2>
{% for doc in documents %}
<div class="file-item">
<div>
<a href="{{ url_for('main.view_file', uri=doc.uri) }}" class="file-link">
{{ doc.filename }}
</a>
<span class="file-uri">URI: {{ doc.uri }}</span>
</div>
<div>
<a href="{{ url_for('main.view_file', uri=doc.uri) }}" class="button">View</a>
<button class="copy-button" onclick="copyToClipboard('{{ url_for('main.view_file', uri=doc.uri, _external=True) }}')">
Copy Link
</button>
</div>
</div>
{% endfor %}
</div>
{% else %}
<div class="empty-state">
<h3>No documents available</h3>
<p>Upload a markdown file to get started!</p>
<a href="{{ url_for('main.upload_file') }}" class="button">Upload Now</a>
</div>
{% endif %}
<script>
function copyToClipboard(text) {
navigator.clipboard.writeText(text).then(function() {
alert('Link copied to clipboard!');
}, function() {
alert('Failed to copy link');
});
}
</script>
</body>
</html>

39
app/templates/upload.html Normal file
View file

@ -0,0 +1,39 @@
<!DOCTYPE html>
<html>
<head>
<title>Upload Markdown File</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/digitallytailored/classless@latest/classless.min.css">
</head>
<body>
<h1>Upload Markdown File</h1>
{% with messages = get_flashed_messages() %}
{% if messages %}
<div class="messages">
{% for message in messages %}
<p class="alert">{{ message }}</p>
{% endfor %}
</div>
{% endif %}
{% endwith %}
<form method="post" enctype="multipart/form-data">
<div>
<label for="file">Select a markdown file:</label>
<input type="file" name="file" id="file" accept=".md">
</div>
<div>
<label for="custom_uri">Custom URI (optional):</label>
<input type="text" name="custom_uri" id="custom_uri" placeholder="e.g., my-document">
<small>Leave blank for an auto-generated URI</small>
</div>
<div>
<input type="submit" value="Upload">
</div>
</form>
<a href="{{ url_for('main.index') }}">Back to Home</a>
</body>
</html>

69
app/templates/viewer.html Normal file
View file

@ -0,0 +1,69 @@
<!DOCTYPE html>
<html>
<head>
<title>{{ filename }} - Markdown Viewer</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/digitallytailored/classless@latest/classless.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--<link rel="stylesheet" href="github-markdown.css">-->
<style>
pre {
background-color: #f5f5f5;
padding: 1em;
border-radius: 4px;
overflow-x: auto;
}
table {
border-collapse: collapse;
width: 100%;
margin: 1em 0;
}
table, th, td {
border: 1px solid #ddd;
}
th, td {
padding: 0.5em;
text-align: left;
}
.document-info {
margin-bottom: 2em;
padding: 1em;
background-color: #f9f9f9;
border-radius: 4px;
}
.markdown-body {
box-sizing: border-box;
min-width: 200px;
max-width: 980px;
margin: 0 auto;
padding: 45px;
}
@media (max-width: 767px) {
.markdown-body {
padding: 15px;
}
} </style>
</head>
<body>
<div class="document-info">
<h1>{{ filename }}</h1>
<p>
<strong>Permanent Link:</strong>
<code>{{ url_for('main.view_file', uri=uri, _external=True) }}</code>
</p>
</div>
<div class="content">
{{ content|safe }}
</div>
<div class="actions">
<a href="{{ url_for('main.upload_file') }}">Upload Another Document</a> |
<a href="{{ url_for('main.index') }}">Home</a>
</div>
</body>
</html>