Spaces:
Running
Running
✅ Fix local upload, OUI calculation and UI enhancements
Browse files- app.py +7 -10
- static/css/style.css +84 -52
- static/js/script.js +1 -1
- templates/NORUS.html +6 -5
app.py
CHANGED
@@ -122,23 +122,20 @@ def validate():
|
|
122 |
filename = secure_filename(pdf_file.filename)
|
123 |
pdf_path = os.path.join(app.config["UPLOAD_FOLDER"], filename)
|
124 |
pdf_file.save(pdf_path)
|
125 |
-
|
126 |
results = []
|
127 |
|
128 |
if analysis_type == "local":
|
129 |
comparison_files = request.files.getlist("comparison_files")
|
130 |
-
if not comparison_files:
|
131 |
-
flash("Carica almeno un file di confronto.", "error")
|
132 |
-
return redirect(url_for("index"))
|
133 |
-
|
134 |
saved_paths = []
|
135 |
for file in comparison_files:
|
136 |
if file.filename.endswith(".pdf"):
|
137 |
-
|
138 |
-
|
139 |
-
file.save(
|
140 |
-
saved_paths.append(
|
141 |
-
|
|
|
|
|
142 |
results = validate_document(pdf_path, saved_paths, method="local")
|
143 |
|
144 |
elif analysis_type == "pubmed":
|
|
|
122 |
filename = secure_filename(pdf_file.filename)
|
123 |
pdf_path = os.path.join(app.config["UPLOAD_FOLDER"], filename)
|
124 |
pdf_file.save(pdf_path)
|
|
|
125 |
results = []
|
126 |
|
127 |
if analysis_type == "local":
|
128 |
comparison_files = request.files.getlist("comparison_files")
|
|
|
|
|
|
|
|
|
129 |
saved_paths = []
|
130 |
for file in comparison_files:
|
131 |
if file.filename.endswith(".pdf"):
|
132 |
+
comp_filename = secure_filename(file.filename)
|
133 |
+
comp_path = os.path.join(app.config["UPLOAD_FOLDER"], comp_filename)
|
134 |
+
file.save(comp_path)
|
135 |
+
saved_paths.append(comp_path)
|
136 |
+
if not saved_paths:
|
137 |
+
flash("Nessun file PDF di confronto selezionato.", "error")
|
138 |
+
return redirect(url_for("index"))
|
139 |
results = validate_document(pdf_path, saved_paths, method="local")
|
140 |
|
141 |
elif analysis_type == "pubmed":
|
static/css/style.css
CHANGED
@@ -1,11 +1,12 @@
|
|
1 |
-
/*
|
2 |
html, body {
|
3 |
height: 100%;
|
4 |
margin: 0;
|
5 |
padding: 0;
|
6 |
-
overflow-y: auto;
|
7 |
}
|
8 |
|
|
|
9 |
body {
|
10 |
font-family: Arial, sans-serif;
|
11 |
background-color: #f8f8f8;
|
@@ -17,7 +18,7 @@ body {
|
|
17 |
|
18 |
/* Header */
|
19 |
header {
|
20 |
-
background-color: rgba(42, 77, 111, 0.8);
|
21 |
color: #fff;
|
22 |
padding: 20px;
|
23 |
text-align: center;
|
@@ -36,54 +37,66 @@ header p {
|
|
36 |
|
37 |
/* Logo */
|
38 |
#logo {
|
|
|
|
|
39 |
max-width: 200px;
|
|
|
40 |
cursor: pointer;
|
41 |
transition: transform 0.3s ease;
|
|
|
|
|
42 |
}
|
43 |
|
44 |
#logo:hover {
|
45 |
transform: scale(1.2);
|
46 |
}
|
47 |
|
48 |
-
/*
|
49 |
-
.container {
|
50 |
-
flex: 1;
|
51 |
-
width: 100%;
|
52 |
-
display: flex;
|
53 |
-
flex-direction: column;
|
54 |
-
align-items: center;
|
55 |
-
padding: 20px;
|
56 |
-
}
|
57 |
-
|
58 |
-
/* Form */
|
59 |
form {
|
60 |
margin: 20px auto;
|
61 |
-
text-align:
|
62 |
-
width:
|
63 |
max-width: 800px;
|
64 |
padding: 25px;
|
65 |
background-color: #fff;
|
66 |
border-radius: 10px;
|
67 |
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
|
68 |
-
overflow-y: auto; /* Permette scrolling interno se necessario */
|
69 |
-
max-height: 90vh; /* Impedisce che il form esca dallo schermo */
|
70 |
}
|
71 |
|
72 |
-
/* Etichette e campi input */
|
73 |
label {
|
74 |
display: block;
|
75 |
-
font-size: 1.
|
76 |
-
margin
|
77 |
font-weight: bold;
|
|
|
78 |
}
|
79 |
|
80 |
-
input,
|
|
|
|
|
|
|
81 |
width: 100%;
|
82 |
padding: 10px;
|
83 |
-
margin-bottom:
|
84 |
border: 1px solid #ccc;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
border-radius: 5px;
|
86 |
-
|
|
|
|
|
|
|
|
|
87 |
}
|
88 |
|
89 |
/* Pulsanti */
|
@@ -91,11 +104,11 @@ button {
|
|
91 |
width: 100%;
|
92 |
background-color: #2a4d6f;
|
93 |
color: #fff;
|
94 |
-
padding: 12px
|
95 |
border: none;
|
96 |
-
border-radius:
|
|
|
97 |
cursor: pointer;
|
98 |
-
font-size: 1.2em;
|
99 |
transition: background-color 0.3s;
|
100 |
margin-top: 10px;
|
101 |
}
|
@@ -104,7 +117,7 @@ button:hover {
|
|
104 |
background-color: #1a3d56;
|
105 |
}
|
106 |
|
107 |
-
/*
|
108 |
.results {
|
109 |
padding: 25px;
|
110 |
background-color: #fff;
|
@@ -112,8 +125,7 @@ button:hover {
|
|
112 |
border-radius: 10px;
|
113 |
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
|
114 |
max-width: 1000px;
|
115 |
-
overflow-
|
116 |
-
max-height: 80vh;
|
117 |
}
|
118 |
|
119 |
/* Tabelle */
|
@@ -133,7 +145,7 @@ th {
|
|
133 |
td {
|
134 |
padding: 12px;
|
135 |
border-bottom: 1px solid #ddd;
|
136 |
-
background-color: #
|
137 |
}
|
138 |
|
139 |
table tr:hover {
|
@@ -141,16 +153,16 @@ table tr:hover {
|
|
141 |
}
|
142 |
|
143 |
table th, table td {
|
144 |
-
font-size:
|
|
|
145 |
}
|
146 |
|
147 |
-
/*
|
148 |
#chart-container {
|
149 |
-
width:
|
150 |
max-width: 1000px;
|
151 |
-
height:
|
152 |
margin: 40px auto;
|
153 |
-
padding-bottom: 20px;
|
154 |
}
|
155 |
|
156 |
canvas {
|
@@ -159,24 +171,13 @@ canvas {
|
|
159 |
display: block;
|
160 |
}
|
161 |
|
162 |
-
#logo {
|
163 |
-
display: block; /* Assicura che il logo sia trattato come un blocco */
|
164 |
-
margin: 0 auto; /* Lo centra orizzontalmente */
|
165 |
-
max-width: 200px;
|
166 |
-
height: auto;
|
167 |
-
cursor: pointer;
|
168 |
-
transition: transform 0.3s ease;
|
169 |
-
position: relative; /* Evita sovrapposizioni strane */
|
170 |
-
z-index: 10; /* Assicura che sia sopra altri elementi */
|
171 |
-
}
|
172 |
-
|
173 |
/* Barra di caricamento */
|
174 |
#progress-container {
|
175 |
width: 100%;
|
176 |
-
background-color: #
|
177 |
-
border-radius:
|
178 |
overflow: hidden;
|
179 |
-
margin: 20px
|
180 |
}
|
181 |
|
182 |
#progress-bar {
|
@@ -195,6 +196,37 @@ footer {
|
|
195 |
text-align: center;
|
196 |
padding: 15px;
|
197 |
width: 100%;
|
198 |
-
font-size:
|
199 |
-
margin-top: auto;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
}
|
|
|
1 |
+
/* Reset base */
|
2 |
html, body {
|
3 |
height: 100%;
|
4 |
margin: 0;
|
5 |
padding: 0;
|
6 |
+
overflow-y: auto;
|
7 |
}
|
8 |
|
9 |
+
/* Corpo */
|
10 |
body {
|
11 |
font-family: Arial, sans-serif;
|
12 |
background-color: #f8f8f8;
|
|
|
18 |
|
19 |
/* Header */
|
20 |
header {
|
21 |
+
background-color: rgba(42, 77, 111, 0.8);
|
22 |
color: #fff;
|
23 |
padding: 20px;
|
24 |
text-align: center;
|
|
|
37 |
|
38 |
/* Logo */
|
39 |
#logo {
|
40 |
+
display: block;
|
41 |
+
margin: 0 auto;
|
42 |
max-width: 200px;
|
43 |
+
height: auto;
|
44 |
cursor: pointer;
|
45 |
transition: transform 0.3s ease;
|
46 |
+
position: relative;
|
47 |
+
z-index: 10;
|
48 |
}
|
49 |
|
50 |
#logo:hover {
|
51 |
transform: scale(1.2);
|
52 |
}
|
53 |
|
54 |
+
/* Form principale */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
form {
|
56 |
margin: 20px auto;
|
57 |
+
text-align: left;
|
58 |
+
width: 90%;
|
59 |
max-width: 800px;
|
60 |
padding: 25px;
|
61 |
background-color: #fff;
|
62 |
border-radius: 10px;
|
63 |
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
|
|
|
|
|
64 |
}
|
65 |
|
|
|
66 |
label {
|
67 |
display: block;
|
68 |
+
font-size: 1.05em;
|
69 |
+
margin: 12px 0 5px;
|
70 |
font-weight: bold;
|
71 |
+
color: #2a4d6f;
|
72 |
}
|
73 |
|
74 |
+
input[type="file"],
|
75 |
+
input[type="text"],
|
76 |
+
input[type="number"],
|
77 |
+
select {
|
78 |
width: 100%;
|
79 |
padding: 10px;
|
80 |
+
margin-bottom: 12px;
|
81 |
border: 1px solid #ccc;
|
82 |
+
border-radius: 6px;
|
83 |
+
font-size: 1em;
|
84 |
+
box-sizing: border-box;
|
85 |
+
}
|
86 |
+
|
87 |
+
/* Input multiupload */
|
88 |
+
input[type="file"]::file-selector-button {
|
89 |
+
padding: 6px 12px;
|
90 |
+
margin-right: 10px;
|
91 |
+
background-color: #2a4d6f;
|
92 |
+
color: white;
|
93 |
+
border: none;
|
94 |
border-radius: 5px;
|
95 |
+
cursor: pointer;
|
96 |
+
}
|
97 |
+
|
98 |
+
input[type="file"]::file-selector-button:hover {
|
99 |
+
background-color: #1a3d56;
|
100 |
}
|
101 |
|
102 |
/* Pulsanti */
|
|
|
104 |
width: 100%;
|
105 |
background-color: #2a4d6f;
|
106 |
color: #fff;
|
107 |
+
padding: 12px;
|
108 |
border: none;
|
109 |
+
border-radius: 6px;
|
110 |
+
font-size: 1.1em;
|
111 |
cursor: pointer;
|
|
|
112 |
transition: background-color 0.3s;
|
113 |
margin-top: 10px;
|
114 |
}
|
|
|
117 |
background-color: #1a3d56;
|
118 |
}
|
119 |
|
120 |
+
/* Risultati */
|
121 |
.results {
|
122 |
padding: 25px;
|
123 |
background-color: #fff;
|
|
|
125 |
border-radius: 10px;
|
126 |
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
|
127 |
max-width: 1000px;
|
128 |
+
overflow-x: auto;
|
|
|
129 |
}
|
130 |
|
131 |
/* Tabelle */
|
|
|
145 |
td {
|
146 |
padding: 12px;
|
147 |
border-bottom: 1px solid #ddd;
|
148 |
+
background-color: #f9f9f9;
|
149 |
}
|
150 |
|
151 |
table tr:hover {
|
|
|
153 |
}
|
154 |
|
155 |
table th, table td {
|
156 |
+
font-size: 1em;
|
157 |
+
word-wrap: break-word;
|
158 |
}
|
159 |
|
160 |
+
/* Grafico */
|
161 |
#chart-container {
|
162 |
+
width: 100%;
|
163 |
max-width: 1000px;
|
164 |
+
height: 500px;
|
165 |
margin: 40px auto;
|
|
|
166 |
}
|
167 |
|
168 |
canvas {
|
|
|
171 |
display: block;
|
172 |
}
|
173 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
/* Barra di caricamento */
|
175 |
#progress-container {
|
176 |
width: 100%;
|
177 |
+
background-color: #e0e0e0;
|
178 |
+
border-radius: 20px;
|
179 |
overflow: hidden;
|
180 |
+
margin-top: 20px;
|
181 |
}
|
182 |
|
183 |
#progress-bar {
|
|
|
196 |
text-align: center;
|
197 |
padding: 15px;
|
198 |
width: 100%;
|
199 |
+
font-size: 1em;
|
200 |
+
margin-top: auto;
|
201 |
+
}
|
202 |
+
|
203 |
+
/* Responsive layout */
|
204 |
+
@media screen and (max-width: 600px) {
|
205 |
+
form, .results {
|
206 |
+
width: 95%;
|
207 |
+
padding: 15px;
|
208 |
+
}
|
209 |
+
|
210 |
+
header h1 {
|
211 |
+
font-size: 1.5em;
|
212 |
+
}
|
213 |
+
|
214 |
+
header p {
|
215 |
+
font-size: 1em;
|
216 |
+
}
|
217 |
+
}
|
218 |
+
|
219 |
+
/* Stile per il pulsante di selezione file (upload multiplo) */
|
220 |
+
input[type="file"]::file-selector-button {
|
221 |
+
background-color: #2a4d6f;
|
222 |
+
color: white;
|
223 |
+
border: none;
|
224 |
+
padding: 8px 12px;
|
225 |
+
border-radius: 5px;
|
226 |
+
margin-right: 10px;
|
227 |
+
cursor: pointer;
|
228 |
+
}
|
229 |
+
|
230 |
+
input[type="file"]::file-selector-button:hover {
|
231 |
+
background-color: #1a3d56;
|
232 |
}
|
static/js/script.js
CHANGED
@@ -116,7 +116,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
|
116 |
document.getElementById("local-options").style.display =
|
117 |
this.value === "local" ? "block" : "none";
|
118 |
});
|
119 |
-
|
120 |
analysisType.dispatchEvent(new Event("change"));
|
121 |
}
|
122 |
});
|
|
|
116 |
document.getElementById("local-options").style.display =
|
117 |
this.value === "local" ? "block" : "none";
|
118 |
});
|
119 |
+
|
120 |
analysisType.dispatchEvent(new Event("change"));
|
121 |
}
|
122 |
});
|
templates/NORUS.html
CHANGED
@@ -19,7 +19,7 @@
|
|
19 |
<p>Analyze your PDF and discover originality and similarity</p>
|
20 |
</header>
|
21 |
<main>
|
22 |
-
<form id="analysisForm" action="/validate" method="POST" enctype="multipart/form-data">
|
23 |
<label for="analysis_type">Choose Analysis Type:</label>
|
24 |
<select name="analysis_type" id="analysis_type" required>
|
25 |
<option value="local">Local Directory</option>
|
@@ -41,10 +41,11 @@
|
|
41 |
</div>
|
42 |
|
43 |
<div id="local-options" style="display: none;">
|
44 |
-
|
45 |
-
|
46 |
</div>
|
47 |
|
|
|
48 |
<label for="pdf_file">Upload PDF:</label>
|
49 |
<input type="file" name="pdf_file" id="pdf_file" required>
|
50 |
|
@@ -73,7 +74,7 @@
|
|
73 |
<td style="max-width: 400px; word-wrap: break-word;">{{ result.title }}</td>
|
74 |
<td>{{ "%.2f"|format(result.similarity) }}</td>
|
75 |
<td>{{ "%.2f"|format(result.token_overlap) }}</td>
|
76 |
-
<td>{{ "%.2f"|format(result.oui
|
77 |
</tr>
|
78 |
{% endfor %}
|
79 |
</tbody>
|
@@ -87,7 +88,7 @@
|
|
87 |
const labels = {{ results | map(attribute='title') | list | safe }};
|
88 |
const semanticData = {{ results | map(attribute='similarity') | list | safe }};
|
89 |
const tokenData = {{ results | map(attribute='token_overlap') | list | safe }};
|
90 |
-
const ouiData = {{ results | map(attribute='oui') | list | safe }}
|
91 |
|
92 |
new Chart(document.getElementById('similarityChart'), {
|
93 |
type: 'bar',
|
|
|
19 |
<p>Analyze your PDF and discover originality and similarity</p>
|
20 |
</header>
|
21 |
<main>
|
22 |
+
<form id="analysisForm" action="/validate" method="POST" enctype="multipart/form-data" onsubmit="startProgress()">
|
23 |
<label for="analysis_type">Choose Analysis Type:</label>
|
24 |
<select name="analysis_type" id="analysis_type" required>
|
25 |
<option value="local">Local Directory</option>
|
|
|
41 |
</div>
|
42 |
|
43 |
<div id="local-options" style="display: none;">
|
44 |
+
<label for="comparison_files">Upload comparison PDFs:</label>
|
45 |
+
<input type="file" name="comparison_files" id="comparison_files" webkitdirectory multiple>
|
46 |
</div>
|
47 |
|
48 |
+
|
49 |
<label for="pdf_file">Upload PDF:</label>
|
50 |
<input type="file" name="pdf_file" id="pdf_file" required>
|
51 |
|
|
|
74 |
<td style="max-width: 400px; word-wrap: break-word;">{{ result.title }}</td>
|
75 |
<td>{{ "%.2f"|format(result.similarity) }}</td>
|
76 |
<td>{{ "%.2f"|format(result.token_overlap) }}</td>
|
77 |
+
<td>{{ "%.2f"|format(result.oui) }}</td>
|
78 |
</tr>
|
79 |
{% endfor %}
|
80 |
</tbody>
|
|
|
88 |
const labels = {{ results | map(attribute='title') | list | safe }};
|
89 |
const semanticData = {{ results | map(attribute='similarity') | list | safe }};
|
90 |
const tokenData = {{ results | map(attribute='token_overlap') | list | safe }};
|
91 |
+
const ouiData = {{ results | map(attribute='oui') | list | safe }};
|
92 |
|
93 |
new Chart(document.getElementById('similarityChart'), {
|
94 |
type: 'bar',
|