Skip to content

Commit ec0f833

Browse files
committed
UI Implementation for doc operations
Signed-off-by: Skye <[email protected]>
1 parent 7a204e5 commit ec0f833

File tree

8 files changed

+697
-38
lines changed

8 files changed

+697
-38
lines changed

filemac/main.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
SUPPORTED_AUDIO_FORMATS_SHOW,
1515
SUPPORTED_DOC_FORMATS,
1616
SUPPORTED_IMAGE_FORMATS_SHOW,
17+
SUPPORTED_VIDEO_FORMATS_SHOW,
1718
)
1819
from . import warnings_handler
1920
from .audiopy.audio import AudioConverter
@@ -503,6 +504,7 @@ def __init__(self, parser, args, remaining_args) -> None:
503504
self.SUPPORTED_DOC_FORMATS = SUPPORTED_DOC_FORMATS
504505
self.SUPPORTED_AUDIO_FORMATS_SHOW = SUPPORTED_AUDIO_FORMATS_SHOW
505506
self.SUPPORTED_AUDIO_FORMATS_DIRECT = SUPPORTED_AUDIO_FORMATS_DIRECT
507+
self.SUPPORTED_VIDEO_FORMATS_SHOW = SUPPORTED_VIDEO_FORMATS_SHOW
506508
self.Argsmain = Argsmain
507509
self.VideoConverter = VideoConverter
508510
self.AudioConverter = AudioConverter
@@ -537,12 +539,12 @@ def pdfjoin(self):
537539
init.controller()
538540

539541
def image_converter(self):
540-
if self.args.target_format is None:
541-
self.ensure_target_format()
542-
return
543542
if self.args.convert_image == "help":
544543
print(self.SUPPORTED_IMAGE_FORMATS_SHOW)
545544
return
545+
if self.args.target_format is None:
546+
self.ensure_target_format()
547+
return
546548
if self.args.target_format is None:
547549
print(
548550
f"{fcl.RED_FG}Please provide output format specified by{fcl.CYAN_FG} '-tf'{RESET}"
@@ -604,7 +606,7 @@ def handle_video_conversion_help(self):
604606
return
605607

606608
def handle_video_conversion(self):
607-
if self.agrs.target_format is None:
609+
if hasattr(self, "agrs") and self.agrs.target_format is None:
608610
self.ensure_target_format()
609611
return
610612
ev = self.VideoConverter(self.args.convert_video, self.args.target_format)

fweb/core/config.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@
3737
"id": "extract_pages",
3838
"name": "Extract PDF Pages",
3939
"icon": """M128.5 64C93.2 64 64.5 92.7 64.5 128L64.5 512C64.5 547.3 93.2 576 128.5 576L384.5 576C419.8 576 448.5 547.3 448.5 512L448.5 416L526.6 416L495.6 447C486.2 456.4 486.2 471.6 495.6 480.9C505 490.2 520.2 490.3 529.5 480.9L601.5 408.9C610.9 399.5 610.9 384.3 601.5 375L529.5 303C520.1 293.6 504.9 293.6 495.6 303C486.3 312.4 486.2 327.6 495.6 336.9L526.6 367.9L448.5 367.9L448.5 234.4C448.5 217.4 441.8 201.1 429.8 189.1L323.2 82.7C311.2 70.7 295 64 278 64L128.5 64zM390 240L296.5 240C283.2 240 272.5 229.3 272.5 216L272.5 122.5L390 240zM256.5 392C256.5 378.7 267.2 368 280.5 368L384.5 368L384.5 416L280.5 416C267.2 416 256.5 405.3 256.5 392z""",
40-
"color": "yellow",
40+
"color": "orange",
4141
"description": "Extract specific pages from PDF documents",
4242
},
43-
{
44-
"id": "Atext2word",
45-
"name": "Advanced Text to Word",
46-
"icon": """M72 96C49.9 96 32 113.9 32 136L32 192C32 209.7 46.3 224 64 224C81.7 224 96 209.7 96 192L96 160L160 160L160 480L128 480C110.3 480 96 494.3 96 512C96 529.7 110.3 544 128 544L256 544C273.7 544 288 529.7 288 512C288 494.3 273.7 480 256 480L224 480L224 160L288 160L288 192C288 209.7 302.3 224 320 224C337.7 224 352 209.7 352 192L352 136C352 113.9 334.1 96 312 96L72 96zM470.6 425.4C458.1 412.9 437.8 412.9 425.3 425.4C412.8 437.9 412.8 458.2 425.3 470.7L489.3 534.7C501.8 547.2 522.1 547.2 534.6 534.7L598.6 470.7C611.1 458.2 611.1 437.9 598.6 425.4C586.1 412.9 565.8 412.9 553.3 425.4L543.9 434.8L543.9 205.3L553.3 214.7C565.8 227.2 586.1 227.2 598.6 214.7C611.1 202.2 611.1 181.9 598.6 169.4L534.6 105.4C528.6 99.4 520.5 96 512 96C503.5 96 495.4 99.4 489.4 105.4L425.4 169.4C412.9 181.9 412.9 202.2 425.4 214.7C437.9 227.2 458.2 227.2 470.7 214.7L480.1 205.3L480.1 434.8L470.7 425.4z""",
47-
"color": "indigo",
48-
"description": "Convert text files to Word documents with formatting",
49-
},
43+
# { no-longer viable
44+
# "id": "Atext2word",
45+
# "name": "Advanced Text to Word",
46+
# "icon": """M72 96C49.9 96 32 113.9 32 136L32 192C32 209.7 46.3 224 64 224C81.7 224 96 209.7 96 192L96 160L160 160L160 480L128 480C110.3 480 96 494.3 96 512C96 529.7 110.3 544 128 544L256 544C273.7 544 288 529.7 288 512C288 494.3 273.7 480 256 480L224 480L224 160L288 160L288 192C288 209.7 302.3 224 320 224C337.7 224 352 209.7 352 192L352 136C352 113.9 334.1 96 312 96L72 96zM470.6 425.4C458.1 412.9 437.8 412.9 425.3 425.4C412.8 437.9 412.8 458.2 425.3 470.7L489.3 534.7C501.8 547.2 522.1 547.2 534.6 534.7L598.6 470.7C611.1 458.2 611.1 437.9 598.6 425.4C586.1 412.9 565.8 412.9 553.3 425.4L543.9 434.8L543.9 205.3L553.3 214.7C565.8 227.2 586.1 227.2 598.6 214.7C611.1 202.2 611.1 181.9 598.6 169.4L534.6 105.4C528.6 99.4 520.5 96 512 96C503.5 96 495.4 99.4 489.4 105.4L425.4 169.4C412.9 181.9 412.9 202.2 425.4 214.7C437.9 227.2 458.2 227.2 470.7 214.7L480.1 205.3L480.1 434.8L470.7 425.4z""",
47+
# "color": "indigo",
48+
# "description": "Convert text files to Word documents with formatting",
49+
# },
5050
{
5151
"id": "doc2image",
5252
"name": "Document to Images",

fweb/core/static/css/styles.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fweb/core/static/js/FileHandler.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ class FileHandler {
2323
});
2424
}
2525

26+
openFileSelector(dropZoneId) {
27+
const inputElement = document.getElementById(`${dropZoneId}-input`);
28+
inputElement?.click();
29+
}
30+
2631
setupDragAndDrop(dropZone, fileInput, multiple) {
2732
dropZone.addEventListener("dragover", (e) => {
2833
e.preventDefault();

fweb/core/static/js/ToolsHandler.js

Lines changed: 141 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ class ToolHandler {
8686
scan_pdf: () => this.initPDFScanning(),
8787
doc_long_image: () => this.initLongImageConversion(),
8888
extract_pages: () => this.initPageExtraction(),
89-
Atext2word: () => this.initTextToWord(),
90-
doc2image: () => this.initDocToImage(),
89+
//Atext2word: () => this.initTextToWord(),
90+
doc2image: () => this.initDocToImages(),
9191

9292
// Image Tools
9393
convert_image: () => this.initImageConversion(),
@@ -122,54 +122,166 @@ class ToolHandler {
122122
}
123123

124124
// Tool-specific initialization methods
125+
///=====Doc Operation==//
125126
initDocumentConversion() {
126127
fileHandler.setupFileDropZone("doc-drop-zone", "doc-file-input", true);
127128
this.setupFormatSelector("doc-target-format", [
128129
"pdf",
129130
"docx",
130131
"txt",
131132
"html",
133+
"xls",
134+
"xlsx",
135+
"ppt",
136+
"pptx",
137+
]);
138+
this.setupAcceptedFiles("doc", [
139+
"pdf",
140+
"docx",
141+
"txt",
142+
"html",
143+
"xls",
144+
"xlsx",
145+
"ppt",
146+
"pptx",
132147
]);
133148
}
134149

135-
initImageConversion() {
136-
fileHandler.setupFileDropZone("image-drop-zone", "image-file-input", true);
137-
this.setupFormatSelector("image-target-format", [
138-
"png",
139-
"jpg",
140-
"jpeg",
141-
"webp",
142-
"gif",
143-
]);
144-
this.setupQualitySlider();
150+
initPDFJoining() {
151+
fileHandler.setupFileDropZone(
152+
"ppf_join-drop-zone",
153+
"pdf_join-file-input",
154+
false,
155+
);
145156
}
146157

158+
initPDFScanning() {
159+
fileHandler.setupFileDropZone(
160+
"scan_pdf-drop-zone",
161+
"scan_pdf-file-input",
162+
false,
163+
);
164+
}
165+
166+
initPageExtraction() {
167+
fileHandler.setupFileDropZone(
168+
"extract_pages-drop-zone",
169+
"extract_pages-file-input",
170+
false,
171+
);
172+
}
173+
174+
initDocToImages() {
175+
fileHandler.setupFileDropZone(
176+
"doc2image-drop-zone",
177+
"doc2image-file-input",
178+
false,
179+
);
180+
}
181+
182+
initLongImageConversion() {
183+
fileHandler.setupFileDropZone(
184+
"doc_long_image-drop-zone",
185+
"doc_long_image-file-input",
186+
false,
187+
);
188+
}
189+
190+
///=====OCR Operation==//
191+
initOCR() {
192+
fileHandler.setupFileDropZone("ocr-drop-zone", "ocr-file-input", true);
193+
this.setupLanguageSelector();
194+
}
195+
196+
///=====Audio Operation==//
147197
initAudioConversion() {
148198
fileHandler.setupFileDropZone("audio-drop-zone", "audio-file-input", true);
149199
this.setupFormatSelector("audio-target-format", [
150200
"mp3",
151201
"wav",
152202
"flac",
153203
"m4a",
204+
"ogg",
205+
"aac",
206+
"raw",
207+
"aiff",
208+
"ogv",
209+
]);
210+
this.setupAcceptedFiles("audio", [
211+
"mp3",
212+
"wav",
213+
"flac",
214+
"m4a",
215+
"ogg",
216+
"aac",
217+
"raw",
218+
"aiff",
219+
"ogv",
154220
]);
155221
}
156222

223+
///=====Video Operation==//
157224
initVideoConversion() {
158-
fileHandler.setupFileDropZone("video-drop-zone", "video-file-input", false);
225+
fileHandler.setupFileDropZone("video-drop-zone", "video-file-input", true);
159226
this.setupFormatSelector("video-target-format", [
160227
"mp4",
161228
"mkv",
229+
"webm",
230+
"mov",
162231
"avi",
232+
"flv",
233+
"wmv",
234+
,
235+
]);
236+
this.setupAcceptedFiles("video", [
237+
"mp4",
238+
"mkv",
239+
"webm",
163240
"mov",
241+
"avi",
242+
"flv",
243+
"wmv",
244+
,
164245
]);
165246
}
166247

167-
initOCR() {
168-
fileHandler.setupFileDropZone("ocr-drop-zone", "ocr-file-input", true);
169-
this.setupLanguageSelector();
248+
///=====Image Operation==//
249+
initImageConversion() {
250+
fileHandler.setupFileDropZone("image-drop-zone", "image-file-input", true);
251+
this.setupFormatSelector("image-target-format", [
252+
"png",
253+
"jpg",
254+
"jpeg",
255+
"webp",
256+
"gif",
257+
"eps",
258+
"pic",
259+
"tiff",
260+
"dib",
261+
"bmp",
262+
]);
263+
this.setupAcceptedFiles("image", [
264+
"png",
265+
"jpg",
266+
"jpeg",
267+
"webp",
268+
"gif",
269+
"eps",
270+
"pic",
271+
"tiff",
272+
"dib",
273+
"bmp",
274+
]);
275+
this.setupQualitySlider();
170276
}
171277

172-
// Add more tool initialization methods as needed...
278+
initImageToPDF() {
279+
fileHandler.setupFileDropZone(
280+
"image2pdf-drop-zone",
281+
"image2pdf-file-input",
282+
false,
283+
);
284+
}
173285

174286
// Utility methods for tool setup
175287
setupFormatSelector(selectId, formats) {
@@ -184,6 +296,18 @@ class ToolHandler {
184296
}
185297
}
186298

299+
setupAcceptedFiles(inputId, accepts) {
300+
if (accepts) {
301+
const Finput = document.getElementById(`${inputId}-file-input`);
302+
Finput
303+
? Finput.setAttribute(
304+
"accept",
305+
accepts.map((format) => `.${format}`).join(","),
306+
)
307+
: "";
308+
}
309+
}
310+
187311
setupQualitySlider() {
188312
const slider = document.querySelector('input[name="quality"]');
189313
const valueDisplay = document.getElementById("quality-value");

fweb/core/static/js/uiManager.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,9 @@ class UIManager {
100100
if (section) {
101101
section.classList.toggle("hidden");
102102

103-
const icon = section.previousElementSibling?.querySelector("i");
104-
if (icon) {
105-
icon.classList.toggle("fa-chevron-up");
106-
icon.classList.toggle("fa-chevron-down");
103+
const svg = section.previousElementSibling?.querySelector("svg");
104+
if (svg) {
105+
svg.classList.toggle("rotate-180");
107106
}
108107
}
109108
}
@@ -114,10 +113,11 @@ class UIManager {
114113
if (loading) {
115114
submitButton.disabled = true;
116115
submitButton.innerHTML =
117-
'<i class="fas fa-spinner fa-spin mr-2"></i>Processing...';
116+
'<span class="h-5 w-5 fill-current fas fa-spinner spin mr-2"><svg><s/vg>Processing...</span';
118117
} else {
119118
submitButton.disabled = false;
120-
submitButton.innerHTML = '<i class="fas fa-cog mr-2"></i>Process Files';
119+
submitButton.innerHTML = `<span class="flex-justify-center items-center mr-2">
120+
<svg class="h-5 w-5 fill-current dark:fill-gray-200 mb-3" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640"><path d="M176 544C96.5 544 32 479.5 32 400C32 336.6 73 282.8 129.9 263.5C128.6 255.8 128 248 128 240C128 160.5 192.5 96 272 96C327.4 96 375.5 127.3 399.6 173.1C413.8 164.8 430.4 160 448 160C501 160 544 203 544 256C544 271.7 540.2 286.6 533.5 299.7C577.5 320 608 364.4 608 416C608 486.7 550.7 544 480 544L176 544zM337 255C327.6 245.6 312.4 245.6 303.1 255L231.1 327C221.7 336.4 221.7 351.6 231.1 360.9C240.5 370.2 255.7 370.3 265 360.9L296 329.9L296 432C296 445.3 306.7 456 320 456C333.3 456 344 445.3 344 432L344 329.9L375 360.9C384.4 370.3 399.6 370.3 408.9 360.9C418.2 351.5 418.3 336.3 408.9 327L336.9 255z"/></svg>Process Files</span>`;
121121
}
122122
}
123123
}

fweb/tailwind.config.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ module.exports = {
4747
h6: "200", // Adjust as needed
4848
},
4949
zIndex: {
50+
1: "1",
51+
5: "5",
52+
10: "10",
53+
15: "15",
54+
20: "20",
55+
25: "25",
56+
30: "30",
57+
35: "35",
58+
40: "40",
5059
41: "41",
5160
45: "45",
5261
51: "51",
@@ -61,7 +70,54 @@ module.exports = {
6170
95: "95",
6271
100: "100",
6372
},
73+
animation: {
74+
bounce: "bounce 0.5s infinite",
75+
"bounce-100": "bounce 0.5s 100ms infinite",
76+
"bounce-200": "bounce 0.5s 200ms infinite",
77+
"bounce-300": "bounce 0.5s 300ms infinite",
78+
"bounce-400": "bounce 0.5s 400ms infinite",
79+
"bounce-500": "bounce 0.5s 500ms infinite",
80+
"bounce-600": "bounce 0.5s 600ms infinite",
81+
heartpulse: "heartpulse 1s infinite",
82+
"spin-50": "spin 0.5s linear infinite",
83+
"reload-100": "spin 1s linear infinite",
84+
"spin-200": "spin 2s linear infinite",
85+
fadeIn: "fadeIn 2s cubic-bezier(0.25, 1, 0.5, 1)",
86+
},
87+
},
88+
keyframes: {
89+
fadeIn: {
90+
"0%": { opacity: 0, transform: "translateY(-300px)" },
91+
"10%": { opacity: 0.1 },
92+
"20%": { opacity: 0.2 },
93+
"30%": { opacity: 0.3 },
94+
"40%": { opacity: 0.4 },
95+
"50%": { opacity: 0.5, transform: "translateY(-150px)" },
96+
"60%": { opacity: 0.6 },
97+
"70%": { opacity: 0.7 },
98+
"80%": { opacity: 0.8 },
99+
"90%": { opacity: 0.9 },
100+
"100%": { opacity: 1, transform: "translateY(0)" },
101+
},
102+
bounce: {
103+
"0%": { opacity: 1 },
104+
"50%": { opacity: 0.5 },
105+
"100%": { opacity: 1 },
106+
},
107+
heartpulse: {
108+
"0%": { transform: "scale(1)" },
109+
"50%": { transform: "scale(1.2)" },
110+
"100%": { transform: "scale(1)" },
111+
},
112+
spin: {
113+
"0%": { transform: "rotate(0deg)" },
114+
"100%": { transform: "rotate(360deg)" },
115+
},
64116
},
117+
/*gradientColorStops: {
118+
* 'gradient-primary': '#00b4d8',
119+
* 'gradient-secondary': '#00ffcc',
120+
},*/
65121
},
66122
plugins: [],
67123
};

0 commit comments

Comments
 (0)