fix: embed style/script in article, remove top positioning
This commit is contained in:
+3
-6
@@ -172,6 +172,7 @@ class SXNGPlugin(Plugin):
|
|||||||
js_q = json.dumps(q_clean)
|
js_q = json.dumps(q_clean)
|
||||||
|
|
||||||
html_payload = f'''
|
html_payload = f'''
|
||||||
|
<article id="sxng-stream-box" class="answer" style="display:none; margin-bottom: 1rem;">
|
||||||
<style>
|
<style>
|
||||||
@keyframes sxng-blink {{ 0%, 100% {{ opacity: 1; }} 50% {{ opacity: 0; }} }}
|
@keyframes sxng-blink {{ 0%, 100% {{ opacity: 1; }} 50% {{ opacity: 0; }} }}
|
||||||
.sxng-cursor {{
|
.sxng-cursor {{
|
||||||
@@ -181,9 +182,7 @@ class SXNGPlugin(Plugin):
|
|||||||
animation: sxng-blink 1s step-end infinite;
|
animation: sxng-blink 1s step-end infinite;
|
||||||
}}
|
}}
|
||||||
</style>
|
</style>
|
||||||
<article id="sxng-stream-box" class="answer" style="display:none; margin-bottom: 1rem;">
|
|
||||||
<p id="sxng-stream-data" style="white-space: pre-wrap; color: var(--color-result-description); font-size: 0.95rem;"></p>
|
<p id="sxng-stream-data" style="white-space: pre-wrap; color: var(--color-result-description); font-size: 0.95rem;"></p>
|
||||||
</article>
|
|
||||||
<script>
|
<script>
|
||||||
(async () => {{
|
(async () => {{
|
||||||
const q = {js_q};
|
const q = {js_q};
|
||||||
@@ -192,9 +191,6 @@ class SXNGPlugin(Plugin):
|
|||||||
const box = document.getElementById('sxng-stream-box');
|
const box = document.getElementById('sxng-stream-box');
|
||||||
const data = document.getElementById('sxng-stream-data');
|
const data = document.getElementById('sxng-stream-data');
|
||||||
|
|
||||||
const container = document.getElementById('urls') || document.getElementById('main_results');
|
|
||||||
if (container && box) {{ container.prepend(box); }}
|
|
||||||
|
|
||||||
try {{
|
try {{
|
||||||
const ctx = new TextDecoder().decode(Uint8Array.from(atob(b64), c => c.charCodeAt(0)));
|
const ctx = new TextDecoder().decode(Uint8Array.from(atob(b64), c => c.charCodeAt(0)));
|
||||||
const res = await fetch('/gemini-stream', {{
|
const res = await fetch('/gemini-stream', {{
|
||||||
@@ -219,7 +215,7 @@ class SXNGPlugin(Plugin):
|
|||||||
if (chunk) {{
|
if (chunk) {{
|
||||||
let text = chunk;
|
let text = chunk;
|
||||||
if (!started) {{
|
if (!started) {{
|
||||||
text = text.replace(/^[\s.,;:!?]+/, '');
|
text = text.replace(/^[\\s.,;:!?]+/, '');
|
||||||
if (!text) continue;
|
if (!text) continue;
|
||||||
data.appendChild(cursor);
|
data.appendChild(cursor);
|
||||||
box.style.display = 'block';
|
box.style.display = 'block';
|
||||||
@@ -233,6 +229,7 @@ class SXNGPlugin(Plugin):
|
|||||||
}} catch (e) {{ console.error(e); box.remove(); }}
|
}} catch (e) {{ console.error(e); box.remove(); }}
|
||||||
}})();
|
}})();
|
||||||
</script>
|
</script>
|
||||||
|
</article>
|
||||||
'''
|
'''
|
||||||
search.result_container.answers.add(results.types.Answer(answer=Markup(html_payload)))
|
search.result_container.answers.add(results.types.Answer(answer=Markup(html_payload)))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user