Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -246,7 +246,7 @@ def display_bookmarks():
|
|
246 |
summary = bookmark.get('summary', '')
|
247 |
category = bookmark.get('category', 'Uncategorized')
|
248 |
|
249 |
-
# Apply inline styles
|
250 |
if bookmark.get('dead_link'):
|
251 |
card_style = "border: 2px solid var(--error-color);"
|
252 |
text_style = "color: var(--error-color);"
|
@@ -453,105 +453,197 @@ Please identify the most relevant bookmarks that match the user's query. Provide
|
|
453 |
def build_app():
|
454 |
try:
|
455 |
logger.info("Building Gradio app")
|
456 |
-
with gr.Blocks(
|
457 |
-
|
458 |
-
:root {
|
459 |
-
--background-color: #FFFFFF;
|
460 |
-
--text-color: #000000;
|
461 |
-
--success-color: #4CAF50;
|
462 |
-
--error-color: #D32F2F;
|
463 |
-
--card-shadow: rgba(0, 0, 0, 0.2);
|
464 |
-
}
|
465 |
-
|
466 |
-
.dark-theme {
|
467 |
-
--background-color: #121212;
|
468 |
-
--text-color: #FFFFFF;
|
469 |
-
--success-color: #81C784;
|
470 |
-
--error-color: #E57373;
|
471 |
-
--card-shadow: rgba(255, 255, 255, 0.2);
|
472 |
-
}
|
473 |
-
|
474 |
-
body {
|
475 |
-
background-color: var(--background-color);
|
476 |
-
color: var(--text-color);
|
477 |
-
}
|
478 |
-
|
479 |
-
.card {
|
480 |
-
box-shadow: 0 4px 8px 0 var(--card-shadow);
|
481 |
-
transition: 0.3s;
|
482 |
-
background-color: var(--background-color);
|
483 |
-
}
|
484 |
-
.card:hover {
|
485 |
-
box-shadow: 0 8px 16px 0 var(--card-shadow);
|
486 |
-
}
|
487 |
-
|
488 |
-
/* Toggle Switch Styles */
|
489 |
-
.theme-toggle {
|
490 |
-
display: flex;
|
491 |
-
align-items: center;
|
492 |
-
justify-content: flex-end;
|
493 |
-
padding: 10px;
|
494 |
-
}
|
495 |
-
|
496 |
-
.switch {
|
497 |
-
position: relative;
|
498 |
-
display: inline-block;
|
499 |
-
width: 60px;
|
500 |
-
height: 34px;
|
501 |
-
}
|
502 |
-
|
503 |
-
.switch input {
|
504 |
-
opacity: 0;
|
505 |
-
width: 0;
|
506 |
-
height: 0;
|
507 |
-
}
|
508 |
-
|
509 |
-
.slider {
|
510 |
-
position: absolute;
|
511 |
-
cursor: pointer;
|
512 |
-
top: 0;
|
513 |
-
left: 0;
|
514 |
-
right: 0;
|
515 |
-
bottom: 0;
|
516 |
-
background-color: #ccc;
|
517 |
-
transition: .4s;
|
518 |
-
border-radius: 34px;
|
519 |
-
}
|
520 |
-
|
521 |
-
.slider:before {
|
522 |
-
position: absolute;
|
523 |
-
content: "";
|
524 |
-
height: 26px;
|
525 |
-
width: 26px;
|
526 |
-
left: 4px;
|
527 |
-
bottom: 4px;
|
528 |
-
background-color: white;
|
529 |
-
transition: .4s;
|
530 |
-
border-radius: 50%;
|
531 |
-
}
|
532 |
-
|
533 |
-
input:checked + .slider {
|
534 |
-
background-color: #2196F3;
|
535 |
-
}
|
536 |
-
|
537 |
-
input:checked + .slider:before {
|
538 |
-
transform: translateX(26px);
|
539 |
-
}
|
540 |
-
|
541 |
-
/* Gradio Components Styling */
|
542 |
-
.gradio-container {
|
543 |
-
background-color: var(--background-color);
|
544 |
-
color: var(--text-color);
|
545 |
-
}
|
546 |
-
|
547 |
-
a {
|
548 |
-
color: var(--text-color);
|
549 |
-
}
|
550 |
-
|
551 |
-
""") as demo:
|
552 |
-
# Add Theme Toggle Switch
|
553 |
gr.HTML(
|
554 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
555 |
<div class="theme-toggle">
|
556 |
<label class="switch">
|
557 |
<input type="checkbox" id="theme-checkbox">
|
@@ -560,12 +652,20 @@ def build_app():
|
|
560 |
<span style="margin-left: 10px;">Dark Mode</span>
|
561 |
</div>
|
562 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
563 |
const toggleSwitch = document.getElementById('theme-checkbox');
|
564 |
toggleSwitch.addEventListener('change', function() {
|
565 |
if(this.checked) {
|
566 |
document.body.classList.add('dark-theme');
|
|
|
567 |
} else {
|
568 |
document.body.classList.remove('dark-theme');
|
|
|
569 |
}
|
570 |
});
|
571 |
</script>
|
|
|
246 |
summary = bookmark.get('summary', '')
|
247 |
category = bookmark.get('category', 'Uncategorized')
|
248 |
|
249 |
+
# Apply inline styles using CSS variables
|
250 |
if bookmark.get('dead_link'):
|
251 |
card_style = "border: 2px solid var(--error-color);"
|
252 |
text_style = "color: var(--error-color);"
|
|
|
453 |
def build_app():
|
454 |
try:
|
455 |
logger.info("Building Gradio app")
|
456 |
+
with gr.Blocks() as demo:
|
457 |
+
# Embed the CSS and Theme Toggle Switch
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
458 |
gr.HTML(
|
459 |
"""
|
460 |
+
<style>
|
461 |
+
/* Define CSS Variables for Themes */
|
462 |
+
:root {
|
463 |
+
--background-color: #FFFFFF;
|
464 |
+
--text-color: #000000;
|
465 |
+
--success-color: #4CAF50;
|
466 |
+
--error-color: #D32F2F;
|
467 |
+
--card-shadow: rgba(0, 0, 0, 0.2);
|
468 |
+
}
|
469 |
+
|
470 |
+
.dark-theme {
|
471 |
+
--background-color: #121212;
|
472 |
+
--text-color: #FFFFFF;
|
473 |
+
--success-color: #81C784;
|
474 |
+
--error-color: #E57373;
|
475 |
+
--card-shadow: rgba(255, 255, 255, 0.2);
|
476 |
+
}
|
477 |
+
|
478 |
+
/* Apply Background and Text Colors */
|
479 |
+
body {
|
480 |
+
background-color: var(--background-color);
|
481 |
+
color: var(--text-color);
|
482 |
+
transition: background-color 0.3s, color 0.3s;
|
483 |
+
}
|
484 |
+
|
485 |
+
/* Card Styles */
|
486 |
+
.card {
|
487 |
+
box-shadow: 0 4px 8px 0 var(--card-shadow);
|
488 |
+
transition: box-shadow 0.3s, background-color 0.3s;
|
489 |
+
background-color: var(--background-color);
|
490 |
+
padding: 10px;
|
491 |
+
margin: 10px;
|
492 |
+
border-radius: 5px;
|
493 |
+
}
|
494 |
+
|
495 |
+
.card:hover {
|
496 |
+
box-shadow: 0 8px 16px 0 var(--card-shadow);
|
497 |
+
}
|
498 |
+
|
499 |
+
/* Toggle Switch Styles */
|
500 |
+
.theme-toggle {
|
501 |
+
display: flex;
|
502 |
+
align-items: center;
|
503 |
+
justify-content: flex-end;
|
504 |
+
padding: 10px;
|
505 |
+
}
|
506 |
+
|
507 |
+
.switch {
|
508 |
+
position: relative;
|
509 |
+
display: inline-block;
|
510 |
+
width: 60px;
|
511 |
+
height: 34px;
|
512 |
+
}
|
513 |
+
|
514 |
+
.switch input {
|
515 |
+
opacity: 0;
|
516 |
+
width: 0;
|
517 |
+
height: 0;
|
518 |
+
}
|
519 |
+
|
520 |
+
.slider {
|
521 |
+
position: absolute;
|
522 |
+
cursor: pointer;
|
523 |
+
top: 0;
|
524 |
+
left: 0;
|
525 |
+
right: 0;
|
526 |
+
bottom: 0;
|
527 |
+
background-color: #ccc;
|
528 |
+
transition: .4s;
|
529 |
+
border-radius: 34px;
|
530 |
+
}
|
531 |
+
|
532 |
+
.slider:before {
|
533 |
+
position: absolute;
|
534 |
+
content: "";
|
535 |
+
height: 26px;
|
536 |
+
width: 26px;
|
537 |
+
left: 4px;
|
538 |
+
bottom: 4px;
|
539 |
+
background-color: white;
|
540 |
+
transition: .4s;
|
541 |
+
border-radius: 50%;
|
542 |
+
}
|
543 |
+
|
544 |
+
input:checked + .slider {
|
545 |
+
background-color: #2196F3;
|
546 |
+
}
|
547 |
+
|
548 |
+
input:checked + .slider:before {
|
549 |
+
transform: translateX(26px);
|
550 |
+
}
|
551 |
+
|
552 |
+
/* Gradio Components Styling */
|
553 |
+
.gradio-container {
|
554 |
+
background-color: var(--background-color);
|
555 |
+
color: var(--text-color);
|
556 |
+
transition: background-color 0.3s, color 0.3s;
|
557 |
+
}
|
558 |
+
|
559 |
+
/* Ensure All Text Elements Use var(--text-color) */
|
560 |
+
body, p, h1, h2, h3, h4, h5, h6, span, a, label, button, input, textarea, select {
|
561 |
+
color: var(--text-color);
|
562 |
+
transition: color 0.3s, background-color 0.3s;
|
563 |
+
}
|
564 |
+
|
565 |
+
/* Links Styling */
|
566 |
+
a {
|
567 |
+
color: var(--text-color);
|
568 |
+
text-decoration: underline;
|
569 |
+
}
|
570 |
+
|
571 |
+
a:hover {
|
572 |
+
color: var(--success-color);
|
573 |
+
}
|
574 |
+
|
575 |
+
/* Buttons Styling */
|
576 |
+
button, .gr-button {
|
577 |
+
background-color: var(--success-color);
|
578 |
+
color: var(--background-color);
|
579 |
+
border: none;
|
580 |
+
padding: 10px 20px;
|
581 |
+
text-align: center;
|
582 |
+
text-decoration: none;
|
583 |
+
display: inline-block;
|
584 |
+
font-size: 16px;
|
585 |
+
margin: 4px 2px;
|
586 |
+
cursor: pointer;
|
587 |
+
border-radius: 4px;
|
588 |
+
transition: background-color 0.3s, color 0.3s;
|
589 |
+
}
|
590 |
+
|
591 |
+
button:hover, .gr-button:hover {
|
592 |
+
background-color: var(--error-color);
|
593 |
+
}
|
594 |
+
|
595 |
+
/* Inputs and Selects Styling */
|
596 |
+
input, textarea, select, .gr-textbox, .gr-dropdown, .gr-file {
|
597 |
+
background-color: var(--background-color);
|
598 |
+
color: var(--text-color);
|
599 |
+
border: 1px solid var(--text-color);
|
600 |
+
border-radius: 4px;
|
601 |
+
padding: 8px;
|
602 |
+
transition: background-color 0.3s, color 0.3s, border-color 0.3s;
|
603 |
+
}
|
604 |
+
|
605 |
+
/* Checkbox and Radio Buttons Styling */
|
606 |
+
input[type="checkbox"], input[type="radio"] {
|
607 |
+
accent-color: var(--success-color);
|
608 |
+
}
|
609 |
+
|
610 |
+
/* Gradio-specific Class Overrides */
|
611 |
+
.gradio-container .gradio-block,
|
612 |
+
.gradio-container .gradio-row,
|
613 |
+
.gradio-container .gradio-column {
|
614 |
+
background-color: var(--background-color);
|
615 |
+
color: var(--text-color);
|
616 |
+
}
|
617 |
+
|
618 |
+
/* Ensure Gradio Tabs Respect the Theme */
|
619 |
+
.gradio-container .tab-title {
|
620 |
+
color: var(--text-color);
|
621 |
+
}
|
622 |
+
|
623 |
+
.gradio-container .tab-title.selected {
|
624 |
+
border-bottom: 2px solid var(--success-color);
|
625 |
+
}
|
626 |
+
|
627 |
+
/* Additional Styling for HTML Components within Gradio */
|
628 |
+
.gradio-container .markdown p,
|
629 |
+
.gradio-container .markdown h1,
|
630 |
+
.gradio-container .markdown h2,
|
631 |
+
.gradio-container .markdown h3,
|
632 |
+
.gradio-container .markdown h4,
|
633 |
+
.gradio-container .markdown h5,
|
634 |
+
.gradio-container .markdown h6 {
|
635 |
+
color: var(--text-color);
|
636 |
+
}
|
637 |
+
|
638 |
+
.gradio-container .html-content a {
|
639 |
+
color: var(--text-color);
|
640 |
+
}
|
641 |
+
|
642 |
+
.gradio-container .html-content a:hover {
|
643 |
+
color: var(--success-color);
|
644 |
+
}
|
645 |
+
</style>
|
646 |
+
|
647 |
<div class="theme-toggle">
|
648 |
<label class="switch">
|
649 |
<input type="checkbox" id="theme-checkbox">
|
|
|
652 |
<span style="margin-left: 10px;">Dark Mode</span>
|
653 |
</div>
|
654 |
<script>
|
655 |
+
// Check for saved user preference on load
|
656 |
+
if (localStorage.getItem('theme') === 'dark') {
|
657 |
+
document.getElementById('theme-checkbox').checked = true;
|
658 |
+
document.body.classList.add('dark-theme');
|
659 |
+
}
|
660 |
+
|
661 |
const toggleSwitch = document.getElementById('theme-checkbox');
|
662 |
toggleSwitch.addEventListener('change', function() {
|
663 |
if(this.checked) {
|
664 |
document.body.classList.add('dark-theme');
|
665 |
+
localStorage.setItem('theme', 'dark');
|
666 |
} else {
|
667 |
document.body.classList.remove('dark-theme');
|
668 |
+
localStorage.setItem('theme', 'light');
|
669 |
}
|
670 |
});
|
671 |
</script>
|