results.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <!DOCTYPE html>
  2. <html lang="el">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>{{ query }} - WiSearch</title>
  7. <style>
  8. body { background-color: #121212; color: #e0e0e0; font-family: 'Segoe UI', Tahoma, sans-serif; margin: 0; padding: 0; }
  9. .top-bar { display: flex; align-items: center; padding: 20px 30px; background: #1e1e1e; border-bottom: 1px solid #333; }
  10. .logo { font-size: 24px; font-weight: bold; color: #bb86fc; text-decoration: none; margin-right: 30px; }
  11. .logo span { color: #03dac6; }
  12. .search-box { padding: 10px 20px; font-size: 16px; border-radius: 30px; border: 1px solid #444; background: #121212; color: #fff; width: 400px; outline: none; }
  13. .btn-search { padding: 10px 20px; font-size: 16px; background-color: #bb86fc; color: #000; border: none; border-radius: 30px; cursor: pointer; margin-left: 10px; font-weight: bold; }
  14. .main-tabs { padding: 0 30px; background: #1e1e1e; border-bottom: 1px solid #333; display: flex; gap: 20px; }
  15. .tab-link { color: #9e9e9e; text-decoration: none; padding: 15px 5px; font-size: 15px; font-weight: bold; border-bottom: 3px solid transparent; transition: 0.2s; }
  16. .tab-link:hover { color: #fff; }
  17. .tab-link.active { color: #03dac6; border-bottom-color: #03dac6; }
  18. .filters-bar { padding: 10px 30px; border-bottom: 1px solid #333; background: #1a1a1a; display: flex; gap: 15px; flex-wrap: wrap; }
  19. .filter-btn { color: #9e9e9e; text-decoration: none; font-size: 13px; padding: 5px 12px; border-radius: 15px; border: 1px solid #333; transition: 0.2s; white-space: nowrap; }
  20. .filter-btn:hover { background: #333; color: #fff; }
  21. .filter-btn.active { background: #03dac6; color: #000; border-color: #03dac6; font-weight: bold; }
  22. /* ΝΕΟ: Διάταξη Σελίδας για Sidebar */
  23. .page-layout { display: flex; gap: 30px; max-width: 1400px; margin: 0 auto; align-items: flex-start; padding: 20px 30px; }
  24. .results-column { flex: 1; max-width: 800px; }
  25. /* Στυλ του AI Box */
  26. .ai-sidebar { width: 360px; background: #1e1e1e; border: 1px solid #333; border-radius: 10px; display: flex; flex-direction: column; height: 600px; position: sticky; top: 20px; flex-shrink: 0; overflow: hidden; box-shadow: 0 4px 15px rgba(0,0,0,0.5); }
  27. .ai-header { background: #2d2d2d; padding: 15px; border-bottom: 1px solid #333; font-weight: bold; color: #bb86fc; display: flex; align-items: center; gap: 10px; }
  28. .ai-chat-window { flex: 1; padding: 15px; overflow-y: auto; display: flex; flex-direction: column; gap: 15px; font-size: 14px; }
  29. .ai-msg { background: #2d2d2d; padding: 12px 15px; border-radius: 10px 10px 10px 0; color: #e0e0e0; align-self: flex-start; max-width: 90%; line-height: 1.5; border: 1px solid #333; }
  30. .user-msg { background: rgba(3, 218, 198, 0.1); border: 1px solid rgba(3, 218, 198, 0.3); padding: 12px 15px; border-radius: 10px 10px 0 10px; color: #03dac6; align-self: flex-end; max-width: 90%; line-height: 1.5; }
  31. .ai-input-area { display: flex; padding: 15px; background: #1a1a1a; border-top: 1px solid #333; gap: 10px; }
  32. .ai-input { flex: 1; padding: 12px 15px; border-radius: 20px; border: 1px solid #444; background: #121212; color: #fff; outline: none; font-size: 13px; }
  33. .ai-input:focus { border-color: #bb86fc; }
  34. .ai-btn { background: #bb86fc; color: #000; border: none; border-radius: 50%; width: 42px; height: 42px; font-weight: bold; cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center; }
  35. .ai-btn:hover { background: #a36cf9; transform: scale(1.05); }
  36. .typing-indicator { color: #9e9e9e; font-size: 12px; font-style: italic; display: none; padding-left: 15px; margin-bottom: 10px; }
  37. .smart-query { font-size: 13px; color: #9e9e9e; margin-bottom: 20px; }
  38. .smart-query span { color: #bb86fc; }
  39. .result-item { margin-bottom: 30px; }
  40. .result-url { display: flex; align-items: center; gap: 10px; margin-bottom: 3px; max-width: 100%; overflow: hidden; }
  41. .url-text { font-size: 13px; color: #e0e0e0; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 550px; display: inline-block; }
  42. .url-text:hover { color: #fff; }
  43. .cached-btn { font-size: 11px; background: #333; color: #fff; padding: 2px 6px; border-radius: 3px; text-decoration: none; border: 1px solid #555; flex-shrink: 0; }
  44. .cached-btn:hover { background: #bb86fc; color: #000; }
  45. .result-title { font-size: 20px; color: #8ab4f8; text-decoration: none; display: block; margin: 4px 0; }
  46. .result-title:hover { text-decoration: underline; }
  47. .result-snippet { font-size: 14px; color: #bdc1c6; line-height: 1.5; margin: 0; }
  48. .result-meta { font-size: 12px; color: #03dac6; margin-top: 5px; }
  49. .sponsored-box { background: rgba(3, 218, 198, 0.05); border: 1px solid rgba(3, 218, 198, 0.2); padding: 15px; border-radius: 8px; margin-bottom: 30px; }
  50. .sponsored-label { font-size: 11px; font-weight: bold; color: #03dac6; text-transform: uppercase; margin-bottom: 5px; display: block; }
  51. .media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 15px; max-width: 1200px; padding: 20px 30px; }
  52. .media-card { background: #1e1e1e; border: 1px solid #333; border-radius: 8px; overflow: hidden; transition: 0.2s; text-decoration: none; display: flex; flex-direction: column; }
  53. .media-card:hover { transform: translateY(-3px); border-color: #bb86fc; box-shadow: 0 4px 10px rgba(0,0,0,0.5); }
  54. .media-card img, .media-card video { width: 100%; height: 160px; object-fit: cover; background: #000; }
  55. .media-info { padding: 10px; font-size: 12px; color: #9e9e9e; word-break: break-all; }
  56. .media-info span { display: block; color: #e0e0e0; font-weight: bold; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  57. .pagination { display: flex; gap: 10px; margin-top: 30px; padding-bottom: 30px; }
  58. .page-btn { padding: 8px 15px; background: #333; color: #fff; text-decoration: none; border-radius: 4px; }
  59. .page-btn:hover { background: #bb86fc; color: #000; }
  60. /* Responsive: Κρύβουμε το Sidebar σε μικρές οθόνες (κινητά) */
  61. @media (max-width: 1000px) {
  62. .page-layout { flex-direction: column; }
  63. .ai-sidebar { width: 100%; position: static; height: 500px; margin-top: 30px; }
  64. }
  65. </style>
  66. </head>
  67. <body>
  68. <div class="top-bar">
  69. <a href="/" class="logo">Wi<span>Search</span></a>
  70. <form action="/search" method="GET" style="display: flex;">
  71. <input type="text" name="q" value="{{ query }}" class="search-box" autocomplete="off">
  72. <input type="hidden" name="tab" value="{{ tab }}">
  73. <input type="hidden" name="category" value="{{ category }}">
  74. <button type="submit" class="btn-search">🔍</button>
  75. </form>
  76. </div>
  77. <div class="main-tabs">
  78. <a href="/search?q={{ query | urlencode }}&tab=web" class="tab-link {% if tab == 'web' %}active{% endif %}">🌐 Web</a>
  79. <a href="/search?q={{ query | urlencode }}&tab=images" class="tab-link {% if tab == 'images' %}active{% endif %}">🖼️ Εικόνες</a>
  80. <a href="/search?q={{ query | urlencode }}&tab=videos" class="tab-link {% if tab == 'videos' %}active{% endif %}">🎥 Βίντεο</a>
  81. </div>
  82. {% if tab == 'web' %}
  83. <div class="filters-bar">
  84. <a href="/search?q={{ query | urlencode }}&tab=web" class="filter-btn {% if not category %}active{% endif %}">Όλα τα Αποτελέσματα</a>
  85. {% set emojis = { 'Media & Streaming': '🎬', 'P2P & Torrents': '⬇️', 'Forums & Communities': '💬', 'Gaming': '🎮', 'Network Tools & Stats': '📊', 'Router & Admin': '⚙️', 'Storage & FTP': '📁', 'Communication & VoIP': '📞', 'IoT & Sensors': '🌡️', 'Web Services & Blogs': '🌐', 'Core Services': '⭐', 'Default Page': '📄', 'Other': '📌' } %}
  86. {% for cat in available_categories %}
  87. <a href="/search?q={{ query | urlencode }}&tab=web&category={{ cat | urlencode }}" class="filter-btn {% if category == cat %}active{% endif %}">
  88. {{ emojis.get(cat, '🔹') }} {{ cat }}
  89. </a>
  90. {% endfor %}
  91. </div>
  92. <div class="page-layout">
  93. <div class="results-column">
  94. {% if smart_query %}
  95. <div class="smart-query">AI Διευρυμένη Αναζήτηση. Βρέθηκαν αποτελέσματα και για: <span>{{ smart_query }}</span></div>
  96. {% endif %}
  97. {% if sponsored %}
  98. <div class="sponsored-box">
  99. <span class="sponsored-label">Διαφήμιση (Sponsored)</span>
  100. {% for ad in sponsored %}
  101. <div style="margin-bottom: 15px;">
  102. <a href="/go?url={{ ad.url }}&id=0" class="result-title" style="color: #03dac6;">{{ ad.title }}</a>
  103. <p class="result-snippet">{{ ad.description }}</p>
  104. <a href="{{ ad.url }}" target="_blank" class="url-text" style="font-size: 12px; color: #9e9e9e;">{{ ad.url }}</a>
  105. </div>
  106. {% endfor %}
  107. </div>
  108. {% endif %}
  109. {% if results %}
  110. {% for result in results %}
  111. <div class="result-item">
  112. <div class="result-url">
  113. <a href="{{ result.url }}" target="_blank" class="url-text" title="{{ result.url }}">{{ result.url }}</a>
  114. <a href="/cached/{{ result.id }}" target="_blank" class="cached-btn" title="Δείτε το αντίγραφο αν το site είναι πεσμένο">Cached</a>
  115. </div>
  116. <a href="/go?url={{ result.url }}&id={{ result.id }}" class="result-title">{{ result.page_title }}</a>
  117. <p class="result-snippet">{{ result.snippet }}...</p>
  118. <div class="result-meta">
  119. [ {{ result.category }} ] - {{ result.ai_summary }}
  120. <span style="color: #666; margin-left: 10px;">(Score: {{ "%.2f"|format(result.total_score) }})</span>
  121. </div>
  122. </div>
  123. {% endfor %}
  124. {% else %}
  125. <p>Δεν βρέθηκαν αποτελέσματα στο Web για <b>{{ query }}</b> {% if category %}στην κατηγορία <b>{{ category }}</b>{% endif %}.</p>
  126. {% endif %}
  127. <div class="pagination">
  128. {% if page > 1 %}
  129. <a href="/search?q={{ query | urlencode }}&tab={{ tab }}&category={{ category | urlencode }}&page={{ page - 1 }}" class="page-btn">« Προηγούμενη</a>
  130. {% endif %}
  131. {% if has_next %}
  132. <a href="/search?q={{ query | urlencode }}&tab={{ tab }}&category={{ category | urlencode }}&page={{ page + 1 }}" class="page-btn">Επόμενη Σελίδα »</a>
  133. {% endif %}
  134. </div>
  135. </div>
  136. <div class="ai-sidebar">
  137. <div class="ai-header">✨ AI Assistant</div>
  138. <div class="ai-chat-window" id="aiChat">
  139. <div class="ai-msg" id="aiInitMsg">Διαβάζω τα αποτελέσματα... ⏳</div>
  140. </div>
  141. <div class="typing-indicator" id="aiTyping">Το AI πληκτρολογεί...</div>
  142. <div class="ai-input-area">
  143. <input type="text" id="aiInput" class="ai-input" placeholder="Ρώτα κάτι..." onkeypress="if(event.key === 'Enter') sendAIMsg()">
  144. <button onclick="sendAIMsg()" class="ai-btn">➤</button>
  145. </div>
  146. </div>
  147. </div>
  148. <script>
  149. const aiChat = document.getElementById('aiChat');
  150. const aiInput = document.getElementById('aiInput');
  151. const aiTyping = document.getElementById('aiTyping');
  152. // Μαζεύουμε τα Top 5 αποτελέσματα σε JSON για να τα δώσουμε στο AI
  153. const searchContext = [
  154. {% for r in results[:5] %}
  155. { title: {{ r.page_title | tojson }}, snippet: {{ r.snippet | tojson }} },
  156. {% endfor %}
  157. ];
  158. const currentQuery = {{ query | tojson }};
  159. async function fetchAI(message, isInitial = false) {
  160. aiTyping.style.display = 'block';
  161. try {
  162. const response = await fetch('/api/ai_chat', {
  163. method: 'POST',
  164. headers: { 'Content-Type': 'application/json' },
  165. body: JSON.stringify({ query: currentQuery, context: searchContext, message: message })
  166. });
  167. const data = await response.json();
  168. aiTyping.style.display = 'none';
  169. if(isInitial) { aiChat.innerHTML = ''; } // Σβήνει το "Διαβάζω..."
  170. const aiDiv = document.createElement('div');
  171. aiDiv.className = 'ai-msg';
  172. aiDiv.innerText = data.response || "Δεν μπόρεσα να απαντήσω.";
  173. aiChat.appendChild(aiDiv);
  174. aiChat.scrollTop = aiChat.scrollHeight;
  175. } catch(e) {
  176. aiTyping.style.display = 'none';
  177. if(isInitial) aiChat.innerHTML = '';
  178. const aiDiv = document.createElement('div');
  179. aiDiv.className = 'ai-msg';
  180. aiDiv.innerText = "Σφάλμα επικοινωνίας με τον server AI.";
  181. aiChat.appendChild(aiDiv);
  182. }
  183. }
  184. function sendAIMsg() {
  185. const text = aiInput.value.trim();
  186. if(!text) return;
  187. // Εμφανίζουμε το μήνυμα του χρήστη
  188. const uDiv = document.createElement('div');
  189. uDiv.className = 'user-msg';
  190. uDiv.innerText = text;
  191. aiChat.appendChild(uDiv);
  192. aiChat.scrollTop = aiChat.scrollHeight;
  193. aiInput.value = '';
  194. fetchAI(text); // Στέλνουμε το ερώτημα στο AI
  195. }
  196. // Μόλις φορτώσει η σελίδα, το AI κάνει αυτόματα μια περίληψη των αποτελεσμάτων
  197. window.addEventListener('DOMContentLoaded', () => {
  198. if (searchContext.length > 0) {
  199. fetchAI("Φτιάξε μου μια πολύ σύντομη περίληψη (2-3 προτάσεις) στα Ελληνικά και Αγγλικα (διαχωρισε το με τιτλο Ελληνικά,English) για το τι αφορούν αυτά τα αποτελέσματα.", true);
  200. } else {
  201. document.getElementById('aiInitMsg').innerText = "Δεν υπάρχουν αποτελέσματα για να αναλύσω.";
  202. }
  203. });
  204. </script>
  205. {% endif %}
  206. {% if tab == 'images' %}
  207. <div class="media-grid">
  208. {% if image_results %}
  209. {% for img in image_results %}
  210. <a href="{{ img.source_url }}" target="_blank" class="media-card">
  211. <img src="/proxy_media?url={{ img.media_url | urlencode }}" alt="{{ img.alt_text }}" loading="lazy" onerror="this.src='https://via.placeholder.com/300x150/1e1e1e/333333?text=SSL+Error'">
  212. <div class="media-info">
  213. <span>{{ img.alt_text if img.alt_text else 'Χωρίς Τίτλο' }}</span>
  214. {{ img.source_url }}
  215. </div>
  216. </a>
  217. {% endfor %}
  218. {% else %}
  219. <p style="padding-left: 30px;">Δεν βρέθηκαν εικόνες.</p>
  220. {% endif %}
  221. </div>
  222. {% endif %}
  223. {% if tab == 'videos' %}
  224. <div class="media-grid">
  225. {% if video_results %}
  226. {% for vid in video_results %}
  227. <a href="{{ vid.source_url }}" target="_blank" class="media-card">
  228. <video controls preload="metadata">
  229. <source src="{{ vid.media_url }}" type="video/mp4">
  230. </video>
  231. <div class="media-info">
  232. <span>Βίντεο</span>
  233. {{ vid.source_url }}
  234. </div>
  235. </a>
  236. {% endfor %}
  237. {% else %}
  238. <p style="padding-left: 30px;">Δεν βρέθηκαν βίντεο.</p>
  239. {% endif %}
  240. </div>
  241. {% endif %}
  242. </body>
  243. </html>