Spaces:
Paused
Paused
Fix(UX/AI): implement popstate listener to handle Android hardware back button closing modals instead of the app, and replace AI-generated inline image URLs with real Tavily web images via placeholders to completely eliminate Markdown parser errors
Browse files- index.html +1 -1
- server/news-service.js +14 -7
- src/views/news/news-view.js +14 -2
index.html
CHANGED
|
@@ -51,7 +51,7 @@
|
|
| 51 |
</head>
|
| 52 |
<body class="dark-theme in-chat-view">
|
| 53 |
|
| 54 |
-
<div id="live-version-badge" style="position: fixed; top: 50px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--text-secondary); opacity: 0.6; z-index: 99999; pointer-events: none; font-weight: 500; font-family: monospace; letter-spacing: 1px; background: rgba(0,0,0,0.2); padding: 2px 8px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.05);">BUILD 1.3.
|
| 55 |
|
| 56 |
<!-- SVG Filters for Liquid Glass Refraction -->
|
| 57 |
<svg width="0" height="0" style="position: absolute; pointer-events: none;">
|
|
|
|
| 51 |
</head>
|
| 52 |
<body class="dark-theme in-chat-view">
|
| 53 |
|
| 54 |
+
<div id="live-version-badge" style="position: fixed; top: 50px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--text-secondary); opacity: 0.6; z-index: 99999; pointer-events: none; font-weight: 500; font-family: monospace; letter-spacing: 1px; background: rgba(0,0,0,0.2); padding: 2px 8px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.05);">BUILD 1.3.25</div>
|
| 55 |
|
| 56 |
<!-- SVG Filters for Liquid Glass Refraction -->
|
| 57 |
<svg width="0" height="0" style="position: absolute; pointer-events: none;">
|
server/news-service.js
CHANGED
|
@@ -140,9 +140,7 @@ WICHTIG:
|
|
| 140 |
1. Wenn das Thema völlig unsinnig ist, antworte EXAKT mit dem Wort "SKIP".
|
| 141 |
2. Verweise auf Quellen im Text mit [1], [2] etc., FALLS Suchergebnisse geliefert wurden.
|
| 142 |
3. Schreibe sachlich und informativ.
|
| 143 |
-
4. BILDER
|
| 144 |
-

|
| 145 |
-
WICHTIG: Der Bild-Link darf KEINE Leerzeichen enthalten! Nutze Bindestriche (-) statt Leerzeichen im Link. Ersetze 12345 durch eine erfundene, 5-stellige Nummer (Zufallswert).
|
| 146 |
5. DIAGRAMME: Nutze bei Prozessen oder Daten gerne \`\`\`mermaid ... \`\`\` Diagramme. WICHTIG: Vermeide in Mermaid-Knoten Sonderzeichen wie ()[]{}"', nutze einfache Labels.
|
| 147 |
|
| 148 |
Antworte nur mit dem Markdown-Text des Artikels, oder "SKIP".`;
|
|
@@ -239,10 +237,19 @@ async function runGenerationCycle(simulateError = false) {
|
|
| 239 |
const content = await generateArticleWithGemini(topic, results, simulateError);
|
| 240 |
|
| 241 |
if (content && content !== 'SKIP' && !content.startsWith('SKIP')) {
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 246 |
|
| 247 |
const seed = Math.floor(Math.random() * 100000);
|
| 248 |
let imageUrl = `https://image.pollinations.ai/prompt/${encodeURIComponent(topic + ' high quality professional photo')}?width=800&height=600&nologo=true&seed=${seed}`; // Fallback pollinations image
|
|
|
|
| 140 |
1. Wenn das Thema völlig unsinnig ist, antworte EXAKT mit dem Wort "SKIP".
|
| 141 |
2. Verweise auf Quellen im Text mit [1], [2] etc., FALLS Suchergebnisse geliefert wurden.
|
| 142 |
3. Schreibe sachlich und informativ.
|
| 143 |
+
4. BILDER: Verschönere den Text, indem du an passenden Stellen exakt die Platzhalter [IMAGE_1] und [IMAGE_2] einfügst. Das System ersetzt diese später durch echte Fotos aus dem Web.
|
|
|
|
|
|
|
| 144 |
5. DIAGRAMME: Nutze bei Prozessen oder Daten gerne \`\`\`mermaid ... \`\`\` Diagramme. WICHTIG: Vermeide in Mermaid-Knoten Sonderzeichen wie ()[]{}"', nutze einfache Labels.
|
| 145 |
|
| 146 |
Antworte nur mit dem Markdown-Text des Artikels, oder "SKIP".`;
|
|
|
|
| 237 |
const content = await generateArticleWithGemini(topic, results, simulateError);
|
| 238 |
|
| 239 |
if (content && content !== 'SKIP' && !content.startsWith('SKIP')) {
|
| 240 |
+
let finalContent = content;
|
| 241 |
+
|
| 242 |
+
// Replace placeholders with real web images if available
|
| 243 |
+
if (webImages.length > 1) {
|
| 244 |
+
finalContent = finalContent.replace('[IMAGE_1]', `\n\n`);
|
| 245 |
+
} else {
|
| 246 |
+
finalContent = finalContent.replace('[IMAGE_1]', '');
|
| 247 |
+
}
|
| 248 |
+
if (webImages.length > 2) {
|
| 249 |
+
finalContent = finalContent.replace('[IMAGE_2]', `\n\n`);
|
| 250 |
+
} else {
|
| 251 |
+
finalContent = finalContent.replace('[IMAGE_2]', '');
|
| 252 |
+
}
|
| 253 |
|
| 254 |
const seed = Math.floor(Math.random() * 100000);
|
| 255 |
let imageUrl = `https://image.pollinations.ai/prompt/${encodeURIComponent(topic + ' high quality professional photo')}?width=800&height=600&nologo=true&seed=${seed}`; // Fallback pollinations image
|
src/views/news/news-view.js
CHANGED
|
@@ -11,6 +11,13 @@ export class NewsView {
|
|
| 11 |
this.activeArticle = null;
|
| 12 |
this.chatHistory = [];
|
| 13 |
this.activeTopic = 'Alle';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
}
|
| 15 |
|
| 16 |
async init() {
|
|
@@ -472,6 +479,7 @@ export class NewsView {
|
|
| 472 |
const id = e.currentTarget.dataset.id;
|
| 473 |
this.activeArticle = this.articles.find(a => a.id === id);
|
| 474 |
this.chatHistory = [];
|
|
|
|
| 475 |
this.render();
|
| 476 |
});
|
| 477 |
});
|
|
@@ -480,8 +488,12 @@ export class NewsView {
|
|
| 480 |
const closeArticleBtn = document.getElementById('close-article-btn');
|
| 481 |
if (closeArticleBtn) {
|
| 482 |
closeArticleBtn.addEventListener('click', () => {
|
| 483 |
-
|
| 484 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 485 |
});
|
| 486 |
}
|
| 487 |
|
|
|
|
| 11 |
this.activeArticle = null;
|
| 12 |
this.chatHistory = [];
|
| 13 |
this.activeTopic = 'Alle';
|
| 14 |
+
|
| 15 |
+
window.addEventListener('popstate', (e) => {
|
| 16 |
+
if (this.activeArticle) {
|
| 17 |
+
this.activeArticle = null;
|
| 18 |
+
this.render();
|
| 19 |
+
}
|
| 20 |
+
});
|
| 21 |
}
|
| 22 |
|
| 23 |
async init() {
|
|
|
|
| 479 |
const id = e.currentTarget.dataset.id;
|
| 480 |
this.activeArticle = this.articles.find(a => a.id === id);
|
| 481 |
this.chatHistory = [];
|
| 482 |
+
window.history.pushState({ modal: 'article' }, '');
|
| 483 |
this.render();
|
| 484 |
});
|
| 485 |
});
|
|
|
|
| 488 |
const closeArticleBtn = document.getElementById('close-article-btn');
|
| 489 |
if (closeArticleBtn) {
|
| 490 |
closeArticleBtn.addEventListener('click', () => {
|
| 491 |
+
if (window.history.state && window.history.state.modal === 'article') {
|
| 492 |
+
window.history.back();
|
| 493 |
+
} else {
|
| 494 |
+
this.activeArticle = null;
|
| 495 |
+
this.render();
|
| 496 |
+
}
|
| 497 |
});
|
| 498 |
}
|
| 499 |
|