Skip to content

Commit e90cbb1

Browse files
committed
fix copy directory structure button
1 parent 6c052e7 commit e90cbb1

File tree

2 files changed

+102
-83
lines changed

2 files changed

+102
-83
lines changed

src/server/templates/components/result.jinja

Lines changed: 85 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -29,102 +29,108 @@
2929
}
3030
</script>
3131
{% if result %}
32-
<div class="mt-10" data-results>
33-
<div class="relative">
34-
<div class="w-full h-full absolute inset-0 bg-gray-900 rounded-xl translate-y-2 translate-x-2"></div>
35-
<div class="bg-[#fafafa] rounded-xl border-[3px] border-gray-900 p-6 relative z-20 space-y-6">
36-
<!-- Summary and Directory Structure -->
37-
<div class="grid grid-cols-1 md:grid-cols-12 gap-6">
38-
<!-- Summary Column -->
39-
<div class="md:col-span-5">
40-
<div class="flex justify-between items-center mb-4 py-2">
41-
<h3 class="text-lg font-bold text-gray-900">Summary</h3>
42-
</div>
43-
<div class="relative">
44-
<div class="w-full h-full rounded bg-gray-900 translate-y-1 translate-x-1 absolute inset-0"></div>
45-
<textarea class="w-full h-[160px] p-4 bg-[#fff4da] border-[3px] border-gray-900 rounded font-mono text-sm resize-none focus:outline-none relative z-10"
46-
readonly>{{ summary }}</textarea>
32+
<div class="mt-10" data-results>
33+
<div class="relative">
34+
<div class="w-full h-full absolute inset-0 bg-gray-900 rounded-xl translate-y-2 translate-x-2"></div>
35+
<div class="bg-[#fafafa] rounded-xl border-[3px] border-gray-900 p-6 relative z-20 space-y-6">
36+
<!-- Summary and Directory Structure -->
37+
<div class="grid grid-cols-1 md:grid-cols-12 gap-6">
38+
<!-- Summary Column -->
39+
<div class="md:col-span-5">
40+
<div class="flex justify-between items-center mb-4 py-2">
41+
<h3 class="text-lg font-bold text-gray-900">Summary</h3>
42+
</div>
43+
<div class="relative">
44+
<div class="w-full h-full rounded bg-gray-900 translate-y-1 translate-x-1 absolute inset-0">
4745
</div>
48-
{% if ingest_id %}
49-
<div class="relative mt-4 inline-block group">
50-
<div class="w-full h-full rounded bg-gray-900 translate-y-1 translate-x-1 absolute inset-0"></div>
51-
<a href="/download/{{ ingest_id }}"
52-
class="inline-flex items-center px-4 py-2 bg-[#ffc480] border-[3px] border-gray-900 text-gray-900 rounded group-hover:-translate-y-px group-hover:-translate-x-px transition-transform relative z-10">
53-
<svg class="w-4 h-4 mr-2"
54-
fill="none"
55-
stroke="currentColor"
56-
viewBox="0 0 24 24">
57-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" />
58-
</svg>
59-
Download
60-
</a>
61-
</div>
62-
<div class="relative mt-4 inline-block group ml-4">
63-
<div class="w-full h-full rounded bg-gray-900 translate-y-1 translate-x-1 absolute inset-0"></div>
64-
<button onclick="copyFullDigest()"
65-
class="inline-flex items-center px-4 py-2 bg-[#ffc480] border-[3px] border-gray-900 text-gray-900 rounded group-hover:-translate-y-px group-hover:-translate-x-px transition-transform relative z-10">
66-
<svg class="w-4 h-4 mr-2"
67-
fill="none"
68-
stroke="currentColor"
69-
viewBox="0 0 24 24">
70-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3" />
71-
</svg>
72-
Copy all
73-
</button>
74-
</div>
75-
{% endif %}
46+
<textarea
47+
class="w-full h-[160px] p-4 bg-[#fff4da] border-[3px] border-gray-900 rounded font-mono text-sm resize-none focus:outline-none relative z-10"
48+
readonly>{{ summary }}</textarea>
7649
</div>
77-
<!-- Directory Structure Column -->
78-
<div class="md:col-span-7">
79-
<div class="flex justify-between items-center mb-4">
80-
<h3 class="text-lg font-bold text-gray-900">Directory Structure</h3>
81-
<div class="relative group">
82-
<div class="w-full h-full rounded bg-gray-900 translate-y-1 translate-x-1 absolute inset-0"></div>
83-
<button onclick="copyText('directory-structure')"
84-
class="px-4 py-2 bg-[#ffc480] border-[3px] border-gray-900 text-gray-900 rounded group-hover:-translate-y-px group-hover:-translate-x-px transition-transform relative z-10 flex items-center gap-2">
85-
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
86-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3" />
87-
</svg>
88-
Copy
89-
</button>
90-
</div>
50+
{% if ingest_id %}
51+
<div class="relative mt-4 inline-block group">
52+
<div class="w-full h-full rounded bg-gray-900 translate-y-1 translate-x-1 absolute inset-0">
9153
</div>
92-
<div class="relative">
93-
<div class="w-full h-full rounded bg-gray-900 translate-y-1 translate-x-1 absolute inset-0"></div>
94-
<div class="directory-structure w-full p-4 bg-[#fff4da] border-[3px] border-gray-900 rounded font-mono text-sm resize-y focus:outline-none relative z-10 h-[215px] overflow-auto"
95-
readonly>
96-
{% for line in tree.splitlines() %}
97-
<div name="tree-line"
98-
class="cursor-pointer hover:line-through hover:text-gray-500"
99-
onclick="toggleFile(this)">{{ line }}</div>
100-
{% endfor %}
101-
</div>
54+
<a href="/download/{{ ingest_id }}"
55+
class="inline-flex items-center px-4 py-2 bg-[#ffc480] border-[3px] border-gray-900 text-gray-900 rounded group-hover:-translate-y-px group-hover:-translate-x-px transition-transform relative z-10">
56+
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
57+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
58+
d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" />
59+
</svg>
60+
Download
61+
</a>
62+
</div>
63+
<div class="relative mt-4 inline-block group ml-4">
64+
<div class="w-full h-full rounded bg-gray-900 translate-y-1 translate-x-1 absolute inset-0">
10265
</div>
66+
<button onclick="copyFullDigest()"
67+
class="inline-flex items-center px-4 py-2 bg-[#ffc480] border-[3px] border-gray-900 text-gray-900 rounded group-hover:-translate-y-px group-hover:-translate-x-px transition-transform relative z-10">
68+
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
69+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
70+
d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3" />
71+
</svg>
72+
Copy all
73+
</button>
10374
</div>
75+
{% endif %}
10476
</div>
105-
<!-- Full Digest -->
106-
<div>
77+
<!-- Directory Structure Column -->
78+
<div class="md:col-span-7">
10779
<div class="flex justify-between items-center mb-4">
108-
<h3 class="text-lg font-bold text-gray-900">Files Content</h3>
80+
<h3 class="text-lg font-bold text-gray-900">Directory Structure</h3>
10981
<div class="relative group">
110-
<div class="w-full h-full rounded bg-gray-900 translate-y-1 translate-x-1 absolute inset-0"></div>
111-
<button onclick="copyText('result-text')"
112-
class="px-4 py-2 bg-[#ffc480] border-[3px] border-gray-900 text-gray-900 rounded group-hover:-translate-y-px group-hover:-translate-x-px transition-transform relative z-10 flex items-center gap-2">
82+
<div class="w-full h-full rounded bg-gray-900 translate-y-1 translate-x-1 absolute inset-0">
83+
</div>
84+
<button onclick="copyText('directory-structure')"
85+
class="px-4 py-2 bg-[#ffc480] border-[3px] border-gray-900 text-gray-900 rounded group-hover:-translate-y-px group-hover:-translate-x-px transition-transform relative z-10 flex items-center gap-2">
11386
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
114-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3" />
87+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
88+
d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3" />
11589
</svg>
11690
Copy
11791
</button>
11892
</div>
11993
</div>
12094
<div class="relative">
121-
<div class="w-full h-full rounded bg-gray-900 translate-y-1 translate-x-1 absolute inset-0"></div>
122-
<textarea class="result-text w-full p-4 bg-[#fff4da] border-[3px] border-gray-900 rounded font-mono text-sm resize-y focus:outline-none relative z-10"
123-
style="min-height: {{ '600px' if content else 'calc(100vh-800px)' }}"
124-
readonly>{{ content }}</textarea>
95+
<div class="w-full h-full rounded bg-gray-900 translate-y-1 translate-x-1 absolute inset-0">
96+
</div>
97+
<div class="directory-structure w-full p-4 bg-[#fff4da] border-[3px] border-gray-900 rounded font-mono text-sm resize-y focus:outline-none relative z-10 h-[215px] overflow-auto"
98+
id="directory-structure-container" readonly>
99+
<input type="hidden" id="directory-structure-content" value="{{ tree }}" />
100+
{% for line in tree.splitlines() %}
101+
<div name="tree-line" class="cursor-pointer hover:line-through hover:text-gray-500"
102+
onclick="toggleFile(this)">{{ line }}</div>
103+
{% endfor %}
104+
</div>
105+
</div>
106+
</div>
107+
</div>
108+
<!-- Full Digest -->
109+
<div>
110+
<div class="flex justify-between items-center mb-4">
111+
<h3 class="text-lg font-bold text-gray-900">Files Content</h3>
112+
<div class="relative group">
113+
<div class="w-full h-full rounded bg-gray-900 translate-y-1 translate-x-1 absolute inset-0">
114+
</div>
115+
<button onclick="copyText('result-text')"
116+
class="px-4 py-2 bg-[#ffc480] border-[3px] border-gray-900 text-gray-900 rounded group-hover:-translate-y-px group-hover:-translate-x-px transition-transform relative z-10 flex items-center gap-2">
117+
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
118+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
119+
d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3" />
120+
</svg>
121+
Copy
122+
</button>
125123
</div>
126124
</div>
125+
<div class="relative">
126+
<div class="w-full h-full rounded bg-gray-900 translate-y-1 translate-x-1 absolute inset-0"></div>
127+
<textarea
128+
class="result-text w-full p-4 bg-[#fff4da] border-[3px] border-gray-900 rounded font-mono text-sm resize-y focus:outline-none relative z-10"
129+
style="min-height: {{ '600px' if content else 'calc(100vh-800px)' }}"
130+
readonly>{{ content }}</textarea>
131+
</div>
127132
</div>
128133
</div>
129134
</div>
130-
{% endif %}
135+
</div>
136+
{% endif %}

src/static/js/utils.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
// Copy functionality
22
function copyText(className) {
3-
const textarea = document.querySelector('.' + className);
3+
let textToCopy;
4+
5+
if (className === 'directory-structure') {
6+
// For directory structure, get the hidden input value
7+
const hiddenInput = document.getElementById('directory-structure-content');
8+
if (!hiddenInput) return;
9+
textToCopy = hiddenInput.value;
10+
} else {
11+
// For other elements, get the textarea value
12+
const textarea = document.querySelector('.' + className);
13+
if (!textarea) return;
14+
textToCopy = textarea.value;
15+
}
16+
417
const button = document.querySelector(`button[onclick="copyText('${className}')"]`);
5-
if (!textarea || !button) return;
18+
if (!button) return;
619

720
// Copy text
8-
navigator.clipboard.writeText(textarea.value)
21+
navigator.clipboard.writeText(textToCopy)
922
.then(() => {
1023
// Store original content
1124
const originalContent = button.innerHTML;
@@ -110,7 +123,7 @@ function handleSubmit(event, showLoading = false) {
110123
}
111124

112125
function copyFullDigest() {
113-
const directoryStructure = document.querySelector('.directory-structure').value;
126+
const directoryStructure = document.getElementById('directory-structure-content').value;
114127
const filesContent = document.querySelector('.result-text').value;
115128
const fullDigest = `${directoryStructure}\n\nFiles Content:\n\n${filesContent}`;
116129
const button = document.querySelector('[onclick="copyFullDigest()"]');

0 commit comments

Comments
 (0)