Initial commit: ap_ds Code Repository System v1.0.0

This commit is contained in:
dvs
2026-08-28 11:23:52 +08:00
commit 74a93c63f2
23 changed files with 5811 additions and 0 deletions
+59
View File
@@ -0,0 +1,59 @@
{% extends "base.html" %}
{% block title %}{{ metadata.name }} · ap_ds{% endblock %}
{% block content %}
<div class="repo-header">
<div class="repo-path">
<a href="/code">ap_ds</a>
<span class="separator">/</span>
<a href="{{ url_for('code_browser') }}?branch={{ branch }}">{{ branch }}</a>
<span class="separator">/</span>
<a href="{{ url_for('code_browser') }}?branch={{ branch }}&version={{ version }}">{{ version }}</a>
{% if branch and version %}
{# 将反斜杠替换为正斜杠 #}
{% set normalized_path = metadata.path.replace('\\', '/') %}
{% set relative_path = normalized_path.replace(branch + '/' + version + '/', '') %}
{% if relative_path and '/' in relative_path %}
{% set parts = relative_path.split('/') %}
{% for part in parts[:-1] %}
<span class="separator">/</span>
<a href="#">{{ part }}</a>
{% endfor %}
{% endif %}
{% endif %}
<span class="separator">/</span>
<span>{{ metadata.name }}</span>
</div>
</div>
<div class="code-header">
<div>
<span style="font-family: monospace;">{{ metadata.name }}</span>
<span style="margin-left: 12px; font-size: 12px; color: #848d97;">{{ metadata.size }} 字节</span>
</div>
<div style="display: flex; gap: 8px;">
<button class="copy-btn" onclick="copyCode(this)">复制代码</button>
<a href="{{ url_for('download_file', file_path=metadata.path.replace('\\', '/')) }}" class="copy-btn" style="text-decoration: none;">下载文件</a>
<a href="{{ url_for('code_browser') }}?branch={{ branch }}&version={{ version }}" class="copy-btn" style="text-decoration: none;">返回</a>
</div>
</div>
<div class="code-content">
<pre><code class="language-python" id="code-content">{{ content|escape }}</code></pre>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
hljs.highlightElement(document.querySelector('#code-content'));
});
function copyCode(btn) {
var code = document.getElementById('code-content').innerText;
navigator.clipboard.writeText(code).then(function() {
var originalText = btn.innerText;
btn.innerText = '已复制!';
setTimeout(function() { btn.innerText = originalText; }, 2000);
});
}
</script>
{% endblock %}