-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_files_fullview.py
More file actions
51 lines (45 loc) · 2.59 KB
/
Copy pathadd_files_fullview.py
File metadata and controls
51 lines (45 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python3
"""Add files type support to renderFullview"""
with open('saveit.html', 'r', encoding='utf-8') as f:
content = f.read()
# Update renderFullview to add files type support
old_section = """ } else if(item.type==='link'){
const box=document.createElement('div');box.className='fv-link-box';
box.innerHTML=`
${item.title?`<div class="fv-link-title">${escHTML(item.title)}</div>`:''}
<a class="fv-link-url" href="${escHTML(item.url)}" target="_blank" rel="noopener">${escHTML(item.url)}</a>
<a href="${escHTML(item.url)}" target="_blank" rel="noopener" style="display:inline-block;margin-top:6px;padding:6px 14px;background:var(--accent);color:#fff;border-radius:6px;font-size:13px;text-decoration:none">Open ↗</a>`;
fvContent.appendChild(box);
} else {"""
new_section = """ } else if(item.type==='link'){
const box=document.createElement('div');box.className='fv-link-box';
box.innerHTML=`
${item.title?`<div class="fv-link-title">${escHTML(item.title)}</div>`:''}
<a class="fv-link-url" href="${escHTML(item.url)}" target="_blank" rel="noopener">${escHTML(item.url)}</a>
<a href="${escHTML(item.url)}" target="_blank" rel="noopener" style="display:inline-block;margin-top:6px;padding:6px 14px;background:var(--accent);color:#fff;border-radius:6px;font-size:13px;text-decoration:none">Open ↗</a>`;
fvContent.appendChild(box);
} else if(item.type==='files'){
const box=document.createElement('div');box.className='fv-link-box';
const filename=item.filename||item.path.split('\\\\').pop()||'File';
box.innerHTML=`
<div class="fv-link-title">📁 ${escHTML(filename)}</div>
<div class="fv-link-url" style="font-size:12px;color:var(--text-dim);margin-bottom:8px">${escHTML(item.path||'')}</div>`;
const openBtn=document.createElement('button');
openBtn.textContent='Open File';
openBtn.style.cssText='display:inline-block;padding:6px 14px;background:var(--accent);color:#fff;border:none;border-radius:6px;font-size:13px;cursor:pointer';
openBtn.addEventListener('click',async()=>{
try{
await invoke('open_file',{storagePath,path:item.path});
}catch(e){toast(`Failed to open file: ${e}`,'error')}
});
box.appendChild(openBtn);
fvContent.appendChild(box);
} else {"""
if old_section in content:
content = content.replace(old_section, new_section)
print("✅ Updated renderFullview for files type")
else:
print("⚠️ renderFullview section not found")
with open('saveit.html', 'w', encoding='utf-8') as f:
f.write(content)
print("✅ saveit.html updated successfully")