Update app.py
Browse files
app.py
CHANGED
|
@@ -415,14 +415,22 @@ HTML = """
|
|
| 415 |
--transition: all 0.3s ease;
|
| 416 |
}
|
| 417 |
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 426 |
|
| 427 |
/* ν€λ μ λͺ© μ κ±° λ° Home λ²νΌ λ μ΄μ΄ μ²λ¦¬ */
|
| 428 |
.floating-home {
|
|
@@ -803,7 +811,7 @@ HTML = """
|
|
| 803 |
/* ν€λ λ‘κ³ λ° νμ΄ν */
|
| 804 |
.library-header {
|
| 805 |
position: fixed;
|
| 806 |
-
top:
|
| 807 |
left: 0;
|
| 808 |
right: 0;
|
| 809 |
text-align: center;
|
|
@@ -811,21 +819,21 @@ HTML = """
|
|
| 811 |
pointer-events: none;
|
| 812 |
}
|
| 813 |
|
| 814 |
-
|
| 815 |
-
|
| 816 |
-
|
| 817 |
-
|
| 818 |
-
|
| 819 |
-
|
| 820 |
-
|
| 821 |
-
|
| 822 |
-
|
| 823 |
-
|
| 824 |
-
|
| 825 |
-
|
| 826 |
-
|
| 827 |
-
|
| 828 |
-
|
| 829 |
|
| 830 |
/* μ μ§μ λ‘λ© νμ */
|
| 831 |
.loading-pages {
|
|
@@ -884,14 +892,10 @@ HTML = """
|
|
| 884 |
|
| 885 |
<section id="home" class="fade-in">
|
| 886 |
<div class="upload-container">
|
| 887 |
-
<button class="upload" id="imageUploadBtn">
|
| 888 |
-
<i class="fas fa-images"></i> μ΄λ―Έμ§ μΆκ°
|
| 889 |
-
<input id="imgInput" type="file" accept="image/*" multiple hidden>
|
| 890 |
-
</button>
|
| 891 |
<button class="upload" id="pdfUploadBtn">
|
| 892 |
<i class="fas fa-file-pdf"></i> PDF μΆκ°
|
| 893 |
-
<input id="pdfInput" type="file" accept="application/pdf" hidden>
|
| 894 |
</button>
|
|
|
|
| 895 |
</div>
|
| 896 |
|
| 897 |
<div class="section-title">λ΄ νλ‘μ νΈ</div>
|
|
@@ -899,7 +903,7 @@ HTML = """
|
|
| 899 |
<!-- μΉ΄λκ° μ¬κΈ°μ λμ μΌλ‘ μΆκ°λ©λλ€ -->
|
| 900 |
</div>
|
| 901 |
<div id="noProjects" class="no-projects" style="display: none;">
|
| 902 |
-
νλ‘μ νΈκ° μμ΅λλ€.
|
| 903 |
</div>
|
| 904 |
</section>
|
| 905 |
|
|
@@ -910,7 +914,7 @@ HTML = """
|
|
| 910 |
|
| 911 |
<script>
|
| 912 |
let projects=[], fb=null;
|
| 913 |
-
const grid=
|
| 914 |
pdfjsLib.GlobalWorkerOptions.workerSrc='/static/pdf.worker.js';
|
| 915 |
|
| 916 |
// μλ²μμ 미리 λ‘λλ PDF νλ‘μ νΈ
|
|
@@ -927,51 +931,86 @@ HTML = """
|
|
| 927 |
{once:true,capture:true});
|
| 928 |
});
|
| 929 |
|
| 930 |
-
// μ
λ‘λ λ²νΌ μ΄λ²€νΈ μ°κ²° ν¨μ
|
| 931 |
-
function setupUploadButtons() {
|
| 932 |
-
// λͺ¨λ μ
λ‘λ λ²νΌμ μ΄λ²€νΈ 리μ€λ μΆκ°
|
| 933 |
-
document.querySelectorAll('.upload').forEach(button => {
|
| 934 |
-
button.addEventListener('click', function(e) {
|
| 935 |
-
// λ²νΌ λ΄λΆμ input μμ μ°ΎκΈ°
|
| 936 |
-
const inputElement = this.querySelector('input[type="file"]');
|
| 937 |
-
if (inputElement) {
|
| 938 |
-
// input μμ ν΄λ¦ (νμΌ μ ν λ€μ΄μΌλ‘κ·Έ μ΄κΈ°)
|
| 939 |
-
inputElement.click();
|
| 940 |
-
e.preventDefault(); // λ²νΌ κΈ°λ³Έ λμ λ°©μ§
|
| 941 |
-
}
|
| 942 |
-
});
|
| 943 |
-
});
|
| 944 |
-
}
|
| 945 |
-
|
| 946 |
/* ββ μ νΈ ββ */
|
| 947 |
function $id(id){return document.getElementById(id)}
|
| 948 |
|
| 949 |
-
//
|
| 950 |
-
|
| 951 |
-
|
| 952 |
-
const imageBtn = $id('imageUploadBtn');
|
| 953 |
-
const imageInput = $id('imgInput');
|
| 954 |
-
if (imageBtn && imageInput) {
|
| 955 |
-
console.log('μ΄λ―Έμ§ μ
λ‘λ λ²νΌ μ΄λ²€νΈ μ€μ ');
|
| 956 |
-
imageBtn.onclick = function(e) {
|
| 957 |
-
e.preventDefault();
|
| 958 |
-
e.stopPropagation();
|
| 959 |
-
imageInput.click();
|
| 960 |
-
};
|
| 961 |
-
}
|
| 962 |
|
| 963 |
// PDF μ
λ‘λ λ²νΌ
|
| 964 |
-
const pdfBtn =
|
| 965 |
-
const pdfInput =
|
|
|
|
| 966 |
if (pdfBtn && pdfInput) {
|
| 967 |
-
console.log(
|
| 968 |
-
|
| 969 |
-
|
| 970 |
-
|
|
|
|
| 971 |
pdfInput.click();
|
| 972 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 973 |
}
|
| 974 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 975 |
|
| 976 |
function addCard(i, thumb, title, isCached = false) {
|
| 977 |
const d = document.createElement('div');
|
|
@@ -1000,54 +1039,6 @@ HTML = """
|
|
| 1000 |
$id('noProjects').style.display = 'none';
|
| 1001 |
}
|
| 1002 |
|
| 1003 |
-
/* ββ μ΄λ―Έμ§ μ
λ‘λ ββ */
|
| 1004 |
-
$id('imgInput').onchange=e=>{
|
| 1005 |
-
const files=[...e.target.files]; if(!files.length) return;
|
| 1006 |
-
|
| 1007 |
-
// λ‘λ© νμ μΆκ°
|
| 1008 |
-
showLoading("μ΄λ―Έμ§ λ‘λ© μ€...");
|
| 1009 |
-
|
| 1010 |
-
const pages=[],tot=files.length;let done=0;
|
| 1011 |
-
files.forEach((f,i)=>{const r=new FileReader();r.onload=x=>{pages[i]={src:x.target.result,thumb:x.target.result};
|
| 1012 |
-
if(++done===tot) {
|
| 1013 |
-
save(pages, 'μ΄λ―Έμ§ 컬λ μ
');
|
| 1014 |
-
hideLoading();
|
| 1015 |
-
}
|
| 1016 |
-
};r.readAsDataURL(f);});
|
| 1017 |
-
};
|
| 1018 |
-
|
| 1019 |
-
/* ββ PDF μ
λ‘λ ββ */
|
| 1020 |
-
$id('pdfInput').onchange=e=>{
|
| 1021 |
-
const file=e.target.files[0]; if(!file) return;
|
| 1022 |
-
|
| 1023 |
-
// λ‘λ© νμ μΆκ°
|
| 1024 |
-
showLoading("PDF λ‘λ© μ€...");
|
| 1025 |
-
|
| 1026 |
-
const fr=new FileReader();
|
| 1027 |
-
fr.onload=v=>{
|
| 1028 |
-
pdfjsLib.getDocument({data:v.target.result}).promise.then(async pdf=>{
|
| 1029 |
-
const pages=[];
|
| 1030 |
-
|
| 1031 |
-
for(let p=1;p<=pdf.numPages;p++){
|
| 1032 |
-
// λ‘λ© μν μ
λ°μ΄νΈ
|
| 1033 |
-
updateLoading(`PDF νμ΄μ§ λ‘λ© μ€... (${p}/${pdf.numPages})`);
|
| 1034 |
-
|
| 1035 |
-
const pg=await pdf.getPage(p), vp=pg.getViewport({scale:1});
|
| 1036 |
-
const c=document.createElement('canvas');c.width=vp.width;c.height=vp.height;
|
| 1037 |
-
await pg.render({canvasContext:c.getContext('2d'),viewport:vp}).promise;
|
| 1038 |
-
pages.push({src:c.toDataURL(),thumb:c.toDataURL()});
|
| 1039 |
-
}
|
| 1040 |
-
|
| 1041 |
-
hideLoading();
|
| 1042 |
-
save(pages, file.name.replace('.pdf', ''));
|
| 1043 |
-
}).catch(error => {
|
| 1044 |
-
console.error("PDF λ‘λ© μ€λ₯:", error);
|
| 1045 |
-
hideLoading();
|
| 1046 |
-
showError("PDF λ‘λ© μ€ μ€λ₯κ° λ°μνμ΅λλ€.");
|
| 1047 |
-
});
|
| 1048 |
-
};fr.readAsArrayBuffer(file);
|
| 1049 |
-
};
|
| 1050 |
-
|
| 1051 |
/* ββ νλ‘μ νΈ μ μ₯ ββ */
|
| 1052 |
function save(pages, title, isCached = false){
|
| 1053 |
const id=projects.push(pages)-1;
|
|
@@ -1641,17 +1632,6 @@ HTML = """
|
|
| 1641 |
}
|
| 1642 |
}, 5000);
|
| 1643 |
}
|
| 1644 |
-
|
| 1645 |
-
// νμ΄μ§ λ‘λ μ μλ² PDF λ‘λ
|
| 1646 |
-
window.addEventListener('DOMContentLoaded', () => {
|
| 1647 |
-
// μ§μ μ΄λ²€νΈ 리μ€λ μ€μ (λ νμ€ν λ°©λ²)
|
| 1648 |
-
setupDirectEvents();
|
| 1649 |
-
|
| 1650 |
-
loadServerPDFs();
|
| 1651 |
-
|
| 1652 |
-
// μΊμ μνλ₯Ό μ£ΌκΈ°μ μΌλ‘ νμΈ (3μ΄λ§λ€)
|
| 1653 |
-
setInterval(checkCacheStatus, 3000);
|
| 1654 |
-
});
|
| 1655 |
</script>
|
| 1656 |
</body>
|
| 1657 |
</html>
|
|
|
|
| 415 |
--transition: all 0.3s ease;
|
| 416 |
}
|
| 417 |
|
| 418 |
+
|
| 419 |
+
body {
|
| 420 |
+
margin: 0;
|
| 421 |
+
background: var(--bg-color);
|
| 422 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 423 |
+
color: var(--text-color);
|
| 424 |
+
/* μλ‘μ΄ νΌν κ³ν΅ κ³ κΈμ€λ¬μ΄ κ·ΈλΌλμμ΄μ
λ°°κ²½ */
|
| 425 |
+
background-image: linear-gradient(135deg, #2a0845 0%, #6441a5 50%, #c9a8ff 100%);
|
| 426 |
+
background-attachment: fixed;
|
| 427 |
+
}
|
| 428 |
+
|
| 429 |
+
/* λ·°μ΄ λͺ¨λμΌ λ λ°°κ²½ λ³κ²½ */
|
| 430 |
+
.viewer-mode {
|
| 431 |
+
background-image: linear-gradient(135deg, #30154e 0%, #6b47ad 50%, #d5b8ff 100%) !important;
|
| 432 |
+
}
|
| 433 |
+
|
| 434 |
|
| 435 |
/* ν€λ μ λͺ© μ κ±° λ° Home λ²νΌ λ μ΄μ΄ μ²λ¦¬ */
|
| 436 |
.floating-home {
|
|
|
|
| 811 |
/* ν€λ λ‘κ³ λ° νμ΄ν */
|
| 812 |
.library-header {
|
| 813 |
position: fixed;
|
| 814 |
+
top: 12px;
|
| 815 |
left: 0;
|
| 816 |
right: 0;
|
| 817 |
text-align: center;
|
|
|
|
| 819 |
pointer-events: none;
|
| 820 |
}
|
| 821 |
|
| 822 |
+
.library-header .title {
|
| 823 |
+
display: inline-block;
|
| 824 |
+
padding: 8px 24px; /* ν¨λ© μΆμ */
|
| 825 |
+
background: rgba(255, 255, 255, 0.85);
|
| 826 |
+
backdrop-filter: blur(10px);
|
| 827 |
+
border-radius: 25px; /* ν
λ리 λͺ¨μ리 μΆμ */
|
| 828 |
+
box-shadow: var(--shadow-md);
|
| 829 |
+
font-size: 1.25rem; /* κΈμ ν¬κΈ° μΆμ (1.5remμμ 1.25remμΌλ‘) */
|
| 830 |
+
font-weight: 600;
|
| 831 |
+
background-image: linear-gradient(120deg, #8e74eb 0%, #9d66ff 100%); /* μ λͺ© μμλ λ°ννλ©΄κ³Ό μ΄μΈλ¦¬κ² λ³κ²½ */
|
| 832 |
+
-webkit-background-clip: text;
|
| 833 |
+
background-clip: text;
|
| 834 |
+
color: transparent;
|
| 835 |
+
pointer-events: all;
|
| 836 |
+
}
|
| 837 |
|
| 838 |
/* μ μ§μ λ‘λ© νμ */
|
| 839 |
.loading-pages {
|
|
|
|
| 892 |
|
| 893 |
<section id="home" class="fade-in">
|
| 894 |
<div class="upload-container">
|
|
|
|
|
|
|
|
|
|
|
|
|
| 895 |
<button class="upload" id="pdfUploadBtn">
|
| 896 |
<i class="fas fa-file-pdf"></i> PDF μΆκ°
|
|
|
|
| 897 |
</button>
|
| 898 |
+
<input id="pdfInput" type="file" accept="application/pdf" style="display:none">
|
| 899 |
</div>
|
| 900 |
|
| 901 |
<div class="section-title">λ΄ νλ‘μ νΈ</div>
|
|
|
|
| 903 |
<!-- μΉ΄λκ° μ¬κΈ°μ λμ μΌλ‘ μΆκ°λ©λλ€ -->
|
| 904 |
</div>
|
| 905 |
<div id="noProjects" class="no-projects" style="display: none;">
|
| 906 |
+
νλ‘μ νΈκ° μμ΅λλ€. PDFλ₯Ό μΆκ°νμ¬ μμνμΈμ.
|
| 907 |
</div>
|
| 908 |
</section>
|
| 909 |
|
|
|
|
| 914 |
|
| 915 |
<script>
|
| 916 |
let projects=[], fb=null;
|
| 917 |
+
const grid=document.getElementById('grid'), viewer=document.getElementById('viewer');
|
| 918 |
pdfjsLib.GlobalWorkerOptions.workerSrc='/static/pdf.worker.js';
|
| 919 |
|
| 920 |
// μλ²μμ 미리 λ‘λλ PDF νλ‘μ νΈ
|
|
|
|
| 931 |
{once:true,capture:true});
|
| 932 |
});
|
| 933 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 934 |
/* ββ μ νΈ ββ */
|
| 935 |
function $id(id){return document.getElementById(id)}
|
| 936 |
|
| 937 |
+
// νμΌ μ
λ‘λ μ΄οΏ½οΏ½νΈ μ²λ¦¬
|
| 938 |
+
document.addEventListener("DOMContentLoaded", function() {
|
| 939 |
+
console.log("DOM λ‘λ μλ£, μ΄λ²€νΈ μ€μ μμ");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 940 |
|
| 941 |
// PDF μ
λ‘λ λ²νΌ
|
| 942 |
+
const pdfBtn = document.getElementById('pdfUploadBtn');
|
| 943 |
+
const pdfInput = document.getElementById('pdfInput');
|
| 944 |
+
|
| 945 |
if (pdfBtn && pdfInput) {
|
| 946 |
+
console.log("PDF μ
λ‘λ λ²νΌ μ°Ύμ");
|
| 947 |
+
|
| 948 |
+
// λ²νΌ ν΄λ¦ μ νμΌ μ
λ ₯ νΈλ¦¬κ±°
|
| 949 |
+
pdfBtn.addEventListener('click', function() {
|
| 950 |
+
console.log("PDF λ²νΌ ν΄λ¦λ¨");
|
| 951 |
pdfInput.click();
|
| 952 |
+
});
|
| 953 |
+
|
| 954 |
+
// νμΌ μ ν μ μ²λ¦¬
|
| 955 |
+
pdfInput.addEventListener('change', function(e) {
|
| 956 |
+
console.log("PDF νμΌ μ νλ¨:", e.target.files.length);
|
| 957 |
+
const file = e.target.files[0];
|
| 958 |
+
if (!file) return;
|
| 959 |
+
|
| 960 |
+
showLoading("PDF λ‘λ© μ€...");
|
| 961 |
+
|
| 962 |
+
const reader = new FileReader();
|
| 963 |
+
reader.onload = function(event) {
|
| 964 |
+
pdfjsLib.getDocument({data: event.target.result}).promise.then(async function(pdf) {
|
| 965 |
+
const pages = [];
|
| 966 |
+
|
| 967 |
+
for (let pageNum = 1; pageNum <= pdf.numPages; pageNum++) {
|
| 968 |
+
updateLoading(`PDF νμ΄μ§ λ‘λ© μ€... (${pageNum}/${pdf.numPages})`);
|
| 969 |
+
|
| 970 |
+
const page = await pdf.getPage(pageNum);
|
| 971 |
+
const viewport = page.getViewport({scale: 1});
|
| 972 |
+
const canvas = document.createElement('canvas');
|
| 973 |
+
canvas.width = viewport.width;
|
| 974 |
+
canvas.height = viewport.height;
|
| 975 |
+
|
| 976 |
+
await page.render({
|
| 977 |
+
canvasContext: canvas.getContext('2d'),
|
| 978 |
+
viewport: viewport
|
| 979 |
+
}).promise;
|
| 980 |
+
|
| 981 |
+
pages.push({
|
| 982 |
+
src: canvas.toDataURL(),
|
| 983 |
+
thumb: canvas.toDataURL()
|
| 984 |
+
});
|
| 985 |
+
}
|
| 986 |
+
|
| 987 |
+
hideLoading();
|
| 988 |
+
save(pages, file.name.replace('.pdf', ''));
|
| 989 |
+
}).catch(function(error) {
|
| 990 |
+
console.error("PDF λ‘λ© μ€λ₯:", error);
|
| 991 |
+
hideLoading();
|
| 992 |
+
showError("PDF λ‘λ© μ€ μ€λ₯κ° λ°μνμ΅λλ€: " + error.message);
|
| 993 |
+
});
|
| 994 |
+
};
|
| 995 |
+
|
| 996 |
+
reader.onerror = function(error) {
|
| 997 |
+
console.error("νμΌ μ½κΈ° μ€λ₯:", error);
|
| 998 |
+
hideLoading();
|
| 999 |
+
showError("νμΌμ μ½λ μ€ μ€λ₯κ° λ°μνμ΅λλ€.");
|
| 1000 |
+
};
|
| 1001 |
+
|
| 1002 |
+
reader.readAsArrayBuffer(file);
|
| 1003 |
+
});
|
| 1004 |
+
} else {
|
| 1005 |
+
console.error("PDF μ
λ‘λ μμλ₯Ό μ°Ύμ μ μμ");
|
| 1006 |
}
|
| 1007 |
+
|
| 1008 |
+
// μλ² PDF λ‘λ λ° μΊμ μν νμΈ
|
| 1009 |
+
loadServerPDFs();
|
| 1010 |
+
|
| 1011 |
+
// μΊμ μνλ₯Ό μ£ΌκΈ°μ μΌλ‘ νμΈ
|
| 1012 |
+
setInterval(checkCacheStatus, 3000);
|
| 1013 |
+
});
|
| 1014 |
|
| 1015 |
function addCard(i, thumb, title, isCached = false) {
|
| 1016 |
const d = document.createElement('div');
|
|
|
|
| 1039 |
$id('noProjects').style.display = 'none';
|
| 1040 |
}
|
| 1041 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1042 |
/* ββ νλ‘μ νΈ μ μ₯ ββ */
|
| 1043 |
function save(pages, title, isCached = false){
|
| 1044 |
const id=projects.push(pages)-1;
|
|
|
|
| 1632 |
}
|
| 1633 |
}, 5000);
|
| 1634 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1635 |
</script>
|
| 1636 |
</body>
|
| 1637 |
</html>
|