Spaces:
Runtime error
Runtime error
Update app.py
Browse filesupdated the interface to be more clear and readable
app.py
CHANGED
@@ -669,14 +669,14 @@ def create_ranking_history_chart(keyword_history):
|
|
669 |
def generate_serp_html(keyword, serp_results):
|
670 |
"""Generate HTML for SERP results"""
|
671 |
if not serp_results:
|
672 |
-
return
|
673 |
|
674 |
html = f"""
|
675 |
-
<div style="font-family:
|
676 |
-
<h2 style="margin-top: 0;">SERP Results for "{keyword}"</h2>
|
677 |
|
678 |
-
<div style="background
|
679 |
-
<div style="color: #
|
680 |
</div>
|
681 |
|
682 |
<div class="serp-results" style="display: flex; flex-direction: column; gap: 16px;">
|
@@ -692,19 +692,25 @@ def generate_serp_html(keyword, serp_results):
|
|
692 |
impressions = result["impressions_estimate"]
|
693 |
|
694 |
html += f"""
|
695 |
-
<div class="serp-result" style="padding:
|
696 |
-
<div style="position: absolute; top: -
|
697 |
{position}
|
698 |
</div>
|
699 |
-
<div style="margin-bottom:
|
700 |
-
<a href="#" style="font-size: 18px; color: #
|
701 |
</div>
|
702 |
-
<div style="margin-bottom:
|
703 |
-
<div style="color: #
|
704 |
|
705 |
-
<div style="display: flex;
|
706 |
-
<div style="
|
707 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
708 |
</div>
|
709 |
</div>
|
710 |
"""
|
@@ -719,18 +725,20 @@ def generate_serp_html(keyword, serp_results):
|
|
719 |
def generate_token_visualization_html(token_analysis, full_analysis):
|
720 |
"""Generate HTML for token visualization"""
|
721 |
html = """
|
722 |
-
<div style="font-family:
|
723 |
-
<h2 style="margin-top: 0;"
|
724 |
|
725 |
-
<div style="margin-bottom:
|
726 |
-
<div style="margin-bottom:
|
727 |
-
|
|
|
|
|
728 |
"""
|
729 |
|
730 |
# Add human view tokens
|
731 |
for token in token_analysis:
|
732 |
html += f"""
|
733 |
-
<div style="padding:
|
734 |
{token['text']}
|
735 |
</div>
|
736 |
"""
|
@@ -739,22 +747,33 @@ def generate_token_visualization_html(token_analysis, full_analysis):
|
|
739 |
</div>
|
740 |
</div>
|
741 |
|
742 |
-
<div style="text-align: center; margin:
|
743 |
-
<span style="font-size:
|
744 |
</div>
|
745 |
|
746 |
-
<div style="padding:
|
747 |
-
<div style="margin-bottom:
|
748 |
-
|
|
|
|
|
749 |
"""
|
750 |
|
751 |
-
# Add machine view tokens
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
752 |
for token in full_analysis:
|
753 |
-
|
754 |
html += f"""
|
755 |
-
<div style="padding:
|
756 |
-
{token['token']}
|
757 |
-
<
|
758 |
</div>
|
759 |
"""
|
760 |
|
@@ -762,28 +781,28 @@ def generate_token_visualization_html(token_analysis, full_analysis):
|
|
762 |
</div>
|
763 |
</div>
|
764 |
|
765 |
-
<div style="margin-top:
|
766 |
"""
|
767 |
|
768 |
-
# Add stats
|
769 |
word_count = len(token_analysis)
|
770 |
token_count = len(full_analysis)
|
771 |
ratio = round(token_count / max(1, word_count), 2)
|
772 |
|
773 |
html += f"""
|
774 |
-
<div style="background
|
775 |
-
<div style="font-size:
|
776 |
-
<div style="font-size: 14px;
|
777 |
</div>
|
778 |
|
779 |
-
<div style="background
|
780 |
-
<div style="font-size:
|
781 |
-
<div style="font-size: 14px;
|
782 |
</div>
|
783 |
|
784 |
-
<div style="background
|
785 |
-
<div style="font-size:
|
786 |
-
<div style="font-size: 14px;
|
787 |
</div>
|
788 |
"""
|
789 |
|
@@ -797,38 +816,51 @@ def generate_token_visualization_html(token_analysis, full_analysis):
|
|
797 |
def generate_full_analysis_html(keyword, token_analysis, intent_analysis, evolution_potential, trends):
|
798 |
"""Generate HTML for full keyword analysis"""
|
799 |
html = f"""
|
800 |
-
<div style="font-family:
|
801 |
-
<h2 style="margin-top: 0;"
|
802 |
-
|
803 |
-
<div style="display: grid; grid-template-columns: 1fr 1fr; gap:
|
804 |
-
<div style="padding:
|
805 |
-
<h3 style="margin-top: 0; font-size: 16px;">
|
806 |
-
|
807 |
-
|
808 |
-
|
|
|
|
|
809 |
</div>
|
810 |
<div style="display: flex; justify-content: space-between; align-items: center;">
|
811 |
-
<span>Strength:</span>
|
812 |
-
<div style="width: 120px; height:
|
813 |
-
<div style="height: 100%; background
|
|
|
814 |
</div>
|
815 |
</div>
|
816 |
</div>
|
817 |
|
818 |
-
<div style="padding:
|
819 |
-
<h3 style="margin-top: 0; font-size: 16px;">
|
820 |
-
|
821 |
-
|
|
|
|
|
822 |
<div style="position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;">
|
823 |
-
<span style="font-size: 24px; font-weight:
|
824 |
</div>
|
825 |
-
<svg width="
|
826 |
<path
|
827 |
d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"
|
828 |
fill="none"
|
829 |
-
stroke="
|
|
|
|
|
|
|
|
|
|
|
|
|
830 |
stroke-width="3"
|
831 |
stroke-dasharray="{evolution_potential}, 100"
|
|
|
|
|
832 |
/>
|
833 |
</svg>
|
834 |
</div>
|
@@ -836,17 +868,19 @@ def generate_full_analysis_html(keyword, token_analysis, intent_analysis, evolut
|
|
836 |
</div>
|
837 |
</div>
|
838 |
|
839 |
-
<div style="padding:
|
840 |
-
<h3 style="margin-top: 0; font-size: 16px;">
|
841 |
-
|
|
|
|
|
842 |
"""
|
843 |
|
844 |
-
# Add trends
|
845 |
for trend in trends:
|
846 |
html += f"""
|
847 |
-
<div style="display: flex; align-items: center; gap: 8px;">
|
848 |
-
<span style="color: #
|
849 |
-
<span>{trend}</span>
|
850 |
</div>
|
851 |
"""
|
852 |
|
@@ -854,58 +888,81 @@ def generate_full_analysis_html(keyword, token_analysis, intent_analysis, evolut
|
|
854 |
</div>
|
855 |
</div>
|
856 |
|
857 |
-
<h3 style="margin-bottom:
|
|
|
|
|
858 |
"""
|
859 |
|
860 |
-
# Add token details
|
861 |
-
for token in token_analysis:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
862 |
html += f"""
|
863 |
-
<div style="padding:
|
864 |
-
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom:
|
865 |
-
<div style="display: flex; align-items: center; gap:
|
866 |
-
<span style="font-size:
|
867 |
-
|
|
|
|
|
|
|
|
|
868 |
"""
|
869 |
|
870 |
if token['entityType']:
|
871 |
html += f"""
|
872 |
-
<span style="padding:
|
873 |
-
|
874 |
</span>
|
875 |
"""
|
876 |
|
877 |
html += f"""
|
878 |
</div>
|
879 |
-
<div style="display: flex; align-items: center; gap:
|
880 |
-
<span style="font-size: 12px; color: #
|
881 |
-
<div style="width:
|
882 |
-
<div style="height: 100%; background
|
883 |
</div>
|
|
|
884 |
</div>
|
885 |
</div>
|
886 |
|
887 |
-
<div style="margin-top:
|
888 |
-
<div style="font-size:
|
889 |
-
<div style="border: 1px solid #
|
890 |
-
<div style="font-size:
|
891 |
-
<span style="font-weight:
|
892 |
-
<span>{token['origin']['era']}
|
893 |
-
<span style="
|
|
|
894 |
</div>
|
895 |
-
<div style="font-size: 12px; margin-bottom:
|
896 |
|
897 |
-
<div style="display: flex; align-items: flex-end; height:
|
898 |
"""
|
899 |
|
900 |
-
# Add historical data bars
|
901 |
for period, value in token['historicalData']:
|
902 |
-
|
|
|
|
|
|
|
903 |
html += f"""
|
904 |
-
<div style="display: flex; flex-direction: column; align-items: center; flex: 1;">
|
905 |
-
<div style="width: 100%; background
|
906 |
-
<div style="font-size:
|
907 |
{period}
|
908 |
</div>
|
|
|
|
|
|
|
909 |
</div>
|
910 |
"""
|
911 |
|
|
|
669 |
def generate_serp_html(keyword, serp_results):
|
670 |
"""Generate HTML for SERP results"""
|
671 |
if not serp_results:
|
672 |
+
return '<div style="color: #e2e8f0; text-align: center; padding: 2rem;">No SERP results available</div>'
|
673 |
|
674 |
html = f"""
|
675 |
+
<div style="font-family: 'Inter', sans-serif; padding: 20px; background: linear-gradient(135deg, #1e293b 0%, #334155 100%); border: 1px solid #475569; border-radius: 16px; color: #ffffff;">
|
676 |
+
<h2 style="margin-top: 0; color: #ffffff; background: linear-gradient(135deg, #06b6d4, #3b82f6, #8b5cf6); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;">SERP Results for "{keyword}"</h2>
|
677 |
|
678 |
+
<div style="background: rgba(6, 182, 212, 0.1); border: 1px solid #06b6d4; padding: 12px; border-radius: 8px; margin-bottom: 20px;">
|
679 |
+
<div style="color: #06b6d4; font-size: 12px; font-weight: 500;">๐ This is a simulated SERP. In a real application, this would use the Google API.</div>
|
680 |
</div>
|
681 |
|
682 |
<div class="serp-results" style="display: flex; flex-direction: column; gap: 16px;">
|
|
|
692 |
impressions = result["impressions_estimate"]
|
693 |
|
694 |
html += f"""
|
695 |
+
<div class="serp-result" style="padding: 18px; background: linear-gradient(135deg, #1e293b 0%, #334155 100%); border: 1px solid #475569; border-radius: 12px; position: relative; transition: all 0.3s ease;">
|
696 |
+
<div style="position: absolute; top: -12px; left: -12px; background: linear-gradient(135deg, #06b6d4, #3b82f6); color: white; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; box-shadow: 0 4px 8px rgba(6, 182, 212, 0.3);">
|
697 |
{position}
|
698 |
</div>
|
699 |
+
<div style="margin-bottom: 8px;">
|
700 |
+
<a href="#" style="font-size: 18px; color: #06b6d4; text-decoration: none; font-weight: 600; line-height: 1.4;">{title}</a>
|
701 |
</div>
|
702 |
+
<div style="margin-bottom: 10px; color: #14b8a6; font-size: 14px; font-weight: 500;">{url}</div>
|
703 |
+
<div style="color: #e2e8f0; font-size: 14px; line-height: 1.5; margin-bottom: 12px;">{snippet}</div>
|
704 |
|
705 |
+
<div style="display: flex; gap: 20px; font-size: 12px; color: #94a3b8; padding-top: 8px; border-top: 1px solid #475569;">
|
706 |
+
<div style="display: flex; align-items: center; gap: 4px;">
|
707 |
+
<span style="font-weight: 600; color: #06b6d4;">CTR:</span>
|
708 |
+
<span>{ctr:.2%}</span>
|
709 |
+
</div>
|
710 |
+
<div style="display: flex; align-items: center; gap: 4px;">
|
711 |
+
<span style="font-weight: 600; color: #06b6d4;">Est. Impressions:</span>
|
712 |
+
<span>{impressions:,}</span>
|
713 |
+
</div>
|
714 |
</div>
|
715 |
</div>
|
716 |
"""
|
|
|
725 |
def generate_token_visualization_html(token_analysis, full_analysis):
|
726 |
"""Generate HTML for token visualization"""
|
727 |
html = """
|
728 |
+
<div style="font-family: 'Inter', sans-serif; padding: 24px; background: linear-gradient(135deg, #1e293b 0%, #334155 100%); border: 1px solid #475569; border-radius: 16px; color: #ffffff;">
|
729 |
+
<h2 style="margin-top: 0; color: #ffffff; background: linear-gradient(135deg, #06b6d4, #3b82f6, #8b5cf6); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;">๐ฌ Token Visualization</h2>
|
730 |
|
731 |
+
<div style="margin-bottom: 24px; padding: 20px; background: rgba(6, 182, 212, 0.1); border: 1px solid #06b6d4; border-radius: 12px;">
|
732 |
+
<div style="margin-bottom: 12px; font-weight: 600; color: #06b6d4; display: flex; align-items: center; gap: 8px;">
|
733 |
+
<span>๐๏ธ</span> Human View:
|
734 |
+
</div>
|
735 |
+
<div style="display: flex; flex-wrap: wrap; gap: 10px;">
|
736 |
"""
|
737 |
|
738 |
# Add human view tokens
|
739 |
for token in token_analysis:
|
740 |
html += f"""
|
741 |
+
<div style="padding: 8px 16px; background: linear-gradient(135deg, #1e293b, #334155); border: 1px solid #475569; border-radius: 8px; color: #e2e8f0; font-weight: 500; transition: all 0.3s ease;">
|
742 |
{token['text']}
|
743 |
</div>
|
744 |
"""
|
|
|
747 |
</div>
|
748 |
</div>
|
749 |
|
750 |
+
<div style="text-align: center; margin: 20px 0;">
|
751 |
+
<span style="font-size: 24px; color: #06b6d4;">โ</span>
|
752 |
</div>
|
753 |
|
754 |
+
<div style="padding: 20px; background: rgba(20, 184, 166, 0.1); border: 1px solid #14b8a6; border-radius: 12px;">
|
755 |
+
<div style="margin-bottom: 12px; font-weight: 600; color: #14b8a6; display: flex; align-items: center; gap: 8px;">
|
756 |
+
<span>๐ค</span> Machine View:
|
757 |
+
</div>
|
758 |
+
<div style="display: flex; flex-wrap: wrap; gap: 10px;">
|
759 |
"""
|
760 |
|
761 |
+
# Add machine view tokens with enhanced styling
|
762 |
+
color_map = {
|
763 |
+
"prefix": "linear-gradient(135deg, #8b5cf6, #a855f7)",
|
764 |
+
"suffix": "linear-gradient(135deg, #10b981, #14b8a6)",
|
765 |
+
"stem": "linear-gradient(135deg, #3b82f6, #06b6d4)",
|
766 |
+
"compound_first": "linear-gradient(135deg, #f59e0b, #d97706)",
|
767 |
+
"compound_second": "linear-gradient(135deg, #f59e0b, #d97706)",
|
768 |
+
"word": "linear-gradient(135deg, #6b7280, #4b5563)"
|
769 |
+
}
|
770 |
+
|
771 |
for token in full_analysis:
|
772 |
+
bg_gradient = color_map.get(token["type"], color_map["word"])
|
773 |
html += f"""
|
774 |
+
<div style="padding: 10px 14px; background: {bg_gradient}; border: 1px solid rgba(255,255,255,0.2); border-radius: 8px; font-family: 'Fira Code', monospace; color: #ffffff; font-weight: 500; box-shadow: 0 2px 4px rgba(0,0,0,0.3); transition: all 0.3s ease;">
|
775 |
+
<div style="font-size: 14px;">{token['token']}</div>
|
776 |
+
<div style="font-size: 10px; opacity: 0.8; margin-top: 2px; text-transform: uppercase; letter-spacing: 0.5px;">{token['type']}</div>
|
777 |
</div>
|
778 |
"""
|
779 |
|
|
|
781 |
</div>
|
782 |
</div>
|
783 |
|
784 |
+
<div style="margin-top: 24px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;">
|
785 |
"""
|
786 |
|
787 |
+
# Add stats with improved styling
|
788 |
word_count = len(token_analysis)
|
789 |
token_count = len(full_analysis)
|
790 |
ratio = round(token_count / max(1, word_count), 2)
|
791 |
|
792 |
html += f"""
|
793 |
+
<div style="background: linear-gradient(135deg, #06b6d4, #0891b2); padding: 20px; border-radius: 12px; text-align: center; color: #ffffff; box-shadow: 0 4px 8px rgba(6, 182, 212, 0.3);">
|
794 |
+
<div style="font-size: 28px; font-weight: 700; margin-bottom: 4px;">{word_count}</div>
|
795 |
+
<div style="font-size: 14px; opacity: 0.9; font-weight: 500;">Words</div>
|
796 |
</div>
|
797 |
|
798 |
+
<div style="background: linear-gradient(135deg, #14b8a6, #0d9488); padding: 20px; border-radius: 12px; text-align: center; color: #ffffff; box-shadow: 0 4px 8px rgba(20, 184, 166, 0.3);">
|
799 |
+
<div style="font-size: 28px; font-weight: 700; margin-bottom: 4px;">{token_count}</div>
|
800 |
+
<div style="font-size: 14px; opacity: 0.9; font-weight: 500;">Tokens</div>
|
801 |
</div>
|
802 |
|
803 |
+
<div style="background: linear-gradient(135deg, #8b5cf6, #7c3aed); padding: 20px; border-radius: 12px; text-align: center; color: #ffffff; box-shadow: 0 4px 8px rgba(139, 92, 246, 0.3);">
|
804 |
+
<div style="font-size: 28px; font-weight: 700; margin-bottom: 4px;">{ratio}</div>
|
805 |
+
<div style="font-size: 14px; opacity: 0.9; font-weight: 500;">Tokens/Word</div>
|
806 |
</div>
|
807 |
"""
|
808 |
|
|
|
816 |
def generate_full_analysis_html(keyword, token_analysis, intent_analysis, evolution_potential, trends):
|
817 |
"""Generate HTML for full keyword analysis"""
|
818 |
html = f"""
|
819 |
+
<div style="font-family: 'Inter', sans-serif; padding: 24px; background: linear-gradient(135deg, #1e293b 0%, #334155 100%); border: 1px solid #475569; border-radius: 16px; color: #ffffff;">
|
820 |
+
<h2 style="margin-top: 0; margin-bottom: 24px; color: #ffffff; background: linear-gradient(135deg, #06b6d4, #3b82f6, #8b5cf6); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;">๐งฌ Keyword DNA Analysis for: {keyword}</h2>
|
821 |
+
|
822 |
+
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px;">
|
823 |
+
<div style="padding: 20px; background: rgba(6, 182, 212, 0.1); border: 1px solid #06b6d4; border-radius: 12px;">
|
824 |
+
<h3 style="margin-top: 0; font-size: 18px; color: #06b6d4; display: flex; align-items: center; gap: 8px; margin-bottom: 16px;">
|
825 |
+
<span>๐ฏ</span> Intent Gene
|
826 |
+
</h3>
|
827 |
+
<div style="display: flex; justify-content: space-between; margin-bottom: 12px; color: #e2e8f0;">
|
828 |
+
<span style="font-weight: 500;">Type:</span>
|
829 |
+
<span style="font-weight: 600; color: #06b6d4;">{intent_analysis['type']}</span>
|
830 |
</div>
|
831 |
<div style="display: flex; justify-content: space-between; align-items: center;">
|
832 |
+
<span style="font-weight: 500; color: #e2e8f0;">Strength:</span>
|
833 |
+
<div style="width: 120px; height: 10px; background: rgba(255,255,255,0.1); border-radius: 5px; overflow: hidden; position: relative;">
|
834 |
+
<div style="height: 100%; background: linear-gradient(90deg, #06b6d4, #14b8a6); width: {intent_analysis['strength']}%; border-radius: 5px; box-shadow: 0 0 8px rgba(6, 182, 212, 0.4);"></div>
|
835 |
+
<div style="position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: 10px; color: #ffffff; font-weight: 600;">{intent_analysis['strength']}%</div>
|
836 |
</div>
|
837 |
</div>
|
838 |
</div>
|
839 |
|
840 |
+
<div style="padding: 20px; background: rgba(139, 92, 246, 0.1); border: 1px solid #8b5cf6; border-radius: 12px;">
|
841 |
+
<h3 style="margin-top: 0; font-size: 18px; color: #8b5cf6; display: flex; align-items: center; gap: 8px; margin-bottom: 16px;">
|
842 |
+
<span>โก</span> Evolution Potential
|
843 |
+
</h3>
|
844 |
+
<div style="display: flex; justify-content: center; align-items: center; height: 80px;">
|
845 |
+
<div style="position: relative; width: 80px; height: 80px;">
|
846 |
<div style="position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;">
|
847 |
+
<span style="font-size: 24px; font-weight: 700; color: #8b5cf6;">{evolution_potential}%</span>
|
848 |
</div>
|
849 |
+
<svg width="80" height="80" viewBox="0 0 36 36">
|
850 |
<path
|
851 |
d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"
|
852 |
fill="none"
|
853 |
+
stroke="rgba(139, 92, 246, 0.3)"
|
854 |
+
stroke-width="3"
|
855 |
+
/>
|
856 |
+
<path
|
857 |
+
d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"
|
858 |
+
fill="none"
|
859 |
+
stroke="#8b5cf6"
|
860 |
stroke-width="3"
|
861 |
stroke-dasharray="{evolution_potential}, 100"
|
862 |
+
stroke-linecap="round"
|
863 |
+
style="filter: drop-shadow(0 0 6px rgba(139, 92, 246, 0.5));"
|
864 |
/>
|
865 |
</svg>
|
866 |
</div>
|
|
|
868 |
</div>
|
869 |
</div>
|
870 |
|
871 |
+
<div style="padding: 20px; background: rgba(20, 184, 166, 0.1); border: 1px solid #14b8a6; border-radius: 12px; margin-bottom: 24px;">
|
872 |
+
<h3 style="margin-top: 0; font-size: 18px; color: #14b8a6; display: flex; align-items: center; gap: 8px; margin-bottom: 16px;">
|
873 |
+
<span>๐ฎ</span> Future Mutations
|
874 |
+
</h3>
|
875 |
+
<div style="display: flex; flex-direction: column; gap: 10px;">
|
876 |
"""
|
877 |
|
878 |
+
# Add trends with enhanced styling
|
879 |
for trend in trends:
|
880 |
html += f"""
|
881 |
+
<div style="display: flex; align-items: center; gap: 12px; padding: 8px 0;">
|
882 |
+
<span style="color: #14b8a6; font-size: 16px;">โ</span>
|
883 |
+
<span style="color: #e2e8f0; font-weight: 500;">{trend}</span>
|
884 |
</div>
|
885 |
"""
|
886 |
|
|
|
888 |
</div>
|
889 |
</div>
|
890 |
|
891 |
+
<h3 style="margin-bottom: 16px; color: #ffffff; display: flex; align-items: center; gap: 8px;">
|
892 |
+
<span>๐</span> Token Details & Historical Analysis
|
893 |
+
</h3>
|
894 |
"""
|
895 |
|
896 |
+
# Add token details with enhanced styling
|
897 |
+
for i, token in enumerate(token_analysis):
|
898 |
+
gradient_colors = [
|
899 |
+
"linear-gradient(135deg, #06b6d4, #0891b2)",
|
900 |
+
"linear-gradient(135deg, #14b8a6, #0d9488)",
|
901 |
+
"linear-gradient(135deg, #8b5cf6, #7c3aed)",
|
902 |
+
"linear-gradient(135deg, #3b82f6, #1e40af)",
|
903 |
+
"linear-gradient(135deg, #f59e0b, #d97706)"
|
904 |
+
]
|
905 |
+
token_gradient = gradient_colors[i % len(gradient_colors)]
|
906 |
+
|
907 |
html += f"""
|
908 |
+
<div style="padding: 20px; background: rgba(30, 41, 59, 0.8); border: 1px solid #475569; border-radius: 12px; margin-bottom: 16px; backdrop-filter: blur(10px);">
|
909 |
+
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px;">
|
910 |
+
<div style="display: flex; align-items: center; gap: 12px;">
|
911 |
+
<span style="font-size: 20px; font-weight: 600; color: #ffffff; padding: 8px 16px; background: {token_gradient}; border-radius: 8px; box-shadow: 0 4px 8px rgba(0,0,0,0.3);">
|
912 |
+
{token['token']}
|
913 |
+
</span>
|
914 |
+
<span style="padding: 4px 12px; background: rgba(6, 182, 212, 0.2); color: #06b6d4; border: 1px solid #06b6d4; border-radius: 6px; font-size: 12px; font-weight: 600; text-transform: uppercase;">
|
915 |
+
{token['posTag']}
|
916 |
+
</span>
|
917 |
"""
|
918 |
|
919 |
if token['entityType']:
|
920 |
html += f"""
|
921 |
+
<span style="padding: 4px 12px; background: rgba(139, 92, 246, 0.2); color: #8b5cf6; border: 1px solid #8b5cf6; border-radius: 6px; font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 4px;">
|
922 |
+
<span>โ</span> {token['entityType']}
|
923 |
</span>
|
924 |
"""
|
925 |
|
926 |
html += f"""
|
927 |
</div>
|
928 |
+
<div style="display: flex; align-items: center; gap: 8px;">
|
929 |
+
<span style="font-size: 12px; color: #94a3b8; font-weight: 500;">Importance:</span>
|
930 |
+
<div style="width: 80px; height: 8px; background: rgba(255,255,255,0.1); border-radius: 4px; overflow: hidden;">
|
931 |
+
<div style="height: 100%; background: linear-gradient(90deg, #06b6d4, #14b8a6); width: {token['importance']}%; border-radius: 4px;"></div>
|
932 |
</div>
|
933 |
+
<span style="font-size: 11px; color: #06b6d4; font-weight: 600;">{token['importance']}%</span>
|
934 |
</div>
|
935 |
</div>
|
936 |
|
937 |
+
<div style="margin-top: 16px;">
|
938 |
+
<div style="font-size: 14px; color: #94a3b8; margin-bottom: 8px; font-weight: 500;">๐ Historical Relevance:</div>
|
939 |
+
<div style="border: 1px solid #475569; border-radius: 8px; padding: 16px; background: rgba(15, 23, 42, 0.8);">
|
940 |
+
<div style="font-size: 13px; margin-bottom: 8px; color: #e2e8f0;">
|
941 |
+
<span style="font-weight: 600; color: #06b6d4;">Origin:</span>
|
942 |
+
<span style="margin-left: 8px;">{token['origin']['era']}</span>
|
943 |
+
<span style="margin-left: 4px; color: #94a3b8;">โข</span>
|
944 |
+
<span style="font-style: italic; margin-left: 4px; color: #14b8a6;">{token['origin']['language']}</span>
|
945 |
</div>
|
946 |
+
<div style="font-size: 12px; margin-bottom: 16px; color: #94a3b8; line-height: 1.4;">{token['origin']['note']}</div>
|
947 |
|
948 |
+
<div style="display: flex; align-items: flex-end; height: 60px; gap: 6px; margin-top: 12px; padding: 8px; background: rgba(6, 182, 212, 0.05); border-radius: 6px;">
|
949 |
"""
|
950 |
|
951 |
+
# Add enhanced historical data bars
|
952 |
for period, value in token['historicalData']:
|
953 |
+
period_index = token['historicalData'].index((period, value))
|
954 |
+
opacity = 0.4 + (period_index * 0.1)
|
955 |
+
bar_height = max(8, (value / 100) * 40)
|
956 |
+
|
957 |
html += f"""
|
958 |
+
<div style="display: flex; flex-direction: column; align-items: center; flex: 1; position: relative;">
|
959 |
+
<div style="width: 100%; background: linear-gradient(to top, rgba(6, 182, 212, {opacity}), rgba(20, 184, 166, {opacity + 0.2})); border-radius: 3px 3px 0 0; height: {bar_height}px; transition: all 0.3s ease; box-shadow: 0 2px 4px rgba(0,0,0,0.2);"></div>
|
960 |
+
<div style="font-size: 8px; margin-top: 6px; color: #94a3b8; transform: rotate(45deg); transform-origin: top center; white-space: nowrap; font-weight: 500;">
|
961 |
{period}
|
962 |
</div>
|
963 |
+
<div style="position: absolute; top: -20px; left: 50%; transform: translateX(-50%); font-size: 8px; color: #06b6d4; font-weight: 600; opacity: 0; transition: opacity 0.3s ease;">
|
964 |
+
{int(value)}%
|
965 |
+
</div>
|
966 |
</div>
|
967 |
"""
|
968 |
|