From d23327faeeb73ffcca8d299dd39bd817a5982083 Mon Sep 17 00:00:00 2001 From: qkral <61017598+qkral@users.noreply.github.com> Date: Sun, 19 Jan 2025 20:23:22 +0100 Subject: [PATCH 1/4] inclusion of summarizepaper toggle in arxiv-browse --- browse/static/js/summarizepaper.js | 231 +++++++++++++++++++++++++++++ browse/static/js/toggle-labs.js | 21 +++ 2 files changed, 252 insertions(+) create mode 100644 browse/static/js/summarizepaper.js diff --git a/browse/static/js/summarizepaper.js b/browse/static/js/summarizepaper.js new file mode 100644 index 000000000..d4bc16e0c --- /dev/null +++ b/browse/static/js/summarizepaper.js @@ -0,0 +1,231 @@ +(function () { + const container = document.getElementById("summarizepaper-output"); + const toggle = document.getElementById("summarizepaper-toggle"); + + // Preload logo for faster rendering + const logoLink = document.createElement('link'); + logoLink.rel = 'preload'; + logoLink.as = 'image'; + logoLink.href = 'https://summarizepaper.com/static/summarizer/images/logo.dd1579dd7c43.png'; + document.head.appendChild(logoLink); + + // Removed prefetch link to prevent CORB issues + + // If no container or toggle, exit early + if (!container || !toggle) { + console.error('SummarizePaper: Missing container or toggle'); + return; + } + + // Simple cache to prevent unnecessary regeneration + const contentCache = { + arxivId: null, + html: null + }; + + // Function to clear content + function clearContent() { + container.innerHTML = ""; + container.style.display = "none"; + container.setAttribute('aria-hidden', 'true'); + } + + // Function to show content + function showContent() { + // Get the arXiv paper ID from the URL + const currentUrl = window.location.href; + const arxivId = currentUrl.split('/').pop(); + const summarizepaperUrl = `https://summarizepaper.com/arxiv-id/${arxivId}/`; + const summarizepaperLogo = 'https://summarizepaper.com/static/summarizer/images/logo.dd1579dd7c43.png'; + + // Use cached content if available for the same arxiv ID + if (contentCache.arxivId === arxivId && contentCache.html) { + container.innerHTML = contentCache.html; + container.style.display = "block"; + container.setAttribute('aria-hidden', 'false'); + return; + } + + const html = ` +
+
+
+
+ SummarizePaper Logo: AI-powered paper summarization tool +
+

+ SummarizePaper.com +

+
+ +

+ Get instant access to AI-powered insights: +

+ +
+ ${[ + 'Comprehensive global summary of the paper', + 'Key points and main findings', + 'Layman\'s explanation for everyone', + 'Blog post-style summary with clear explanations' + ].map((feature, index) => ` +
+ ${index + 1} + ${feature} +
+ `).join('')} +
+ +
+
+ 💬 +
+
+

Interactive AI Chat

+

Ask questions and get instant answers about the paper

+
+
+
+ + + Read summaries and chat about this paper + +
+ `; + + // Cache the generated content + contentCache.arxivId = arxivId; + contentCache.html = window.DOMPurify.sanitize(html); + + container.innerHTML = contentCache.html; + container.style.display = "block"; + container.setAttribute('aria-hidden', 'false'); + + // Optional: Track usage (you could replace this with a more sophisticated tracking method) + try { + localStorage.setItem('summarizepaper_usage', + JSON.stringify({ + lastUsed: new Date().toISOString(), + arxivId: arxivId + }) + ); + } catch (error) { + console.warn('Could not track SummarizePaper usage', error); + } + } + + // Check initial state and handle accordingly + function handleToggleState() { + const isToggleOn = toggle.classList.contains('enabled'); + + if (isToggleOn) { + showContent(); + } else { + clearContent(); + } + } + + // Initial state check + handleToggleState(); + + // Add event listener for toggle changes + toggle.addEventListener('change', handleToggleState); +})(); diff --git a/browse/static/js/toggle-labs.js b/browse/static/js/toggle-labs.js index d32996f39..5cb24b9f6 100644 --- a/browse/static/js/toggle-labs.js +++ b/browse/static/js/toggle-labs.js @@ -27,6 +27,10 @@ $(document).ready(function() { "sciencecast": $('#sciencecast-toggle').data('script-url'), "gotitpub": $('#gotitpub-toggle').data('script-url'), "alphaxiv": $('#alphaxiv-toggle').data('script-url'), +<<<<<<< HEAD +======= + "summarizepaper": $('#summarizepaper-toggle').data('script-url'), +>>>>>>> Update SummarizePaper toggle functionality and improve UX across project "bibex": { "url": $('#bibex-toggle').data('script-url'), "container": "#bib-main" @@ -133,6 +137,15 @@ $(document).ready(function() { }).fail(function() { console.error("failed to load huggingface script (on cookie check)", arguments) }); +<<<<<<< HEAD +======= + } else if (key === "summarizepaper-toggle") { + $.cachedScript(scripts["summarizepaper"]).done(function(script, textStatus) { + console.log(textStatus); + }).fail(function() { + console.error("failed to load summarizepaper script (on cookie check)", arguments) + }); +>>>>>>> Update SummarizePaper toggle functionality and improve UX across project } } } @@ -247,6 +260,14 @@ $(document).ready(function() { }).fail(function() { console.error("failed to load huggingface script (on lab toggle)", arguments) }); +<<<<<<< HEAD +======= + } else if ($(this).attr("id") == "summarizepaper-toggle") { + $.cachedScript(scripts["summarizepaper"]).done(function(script, textStatus) { + }).fail(function() { + console.error("failed to load summarizepaper script (on lab toggle)", arguments) + }); +>>>>>>> Update SummarizePaper toggle functionality and improve UX across project } From 4b2eb854a41884dfbecd086af612d08d78c87a80 Mon Sep 17 00:00:00 2001 From: qkral <61017598+qkral@users.noreply.github.com> Date: Sun, 19 Jan 2025 20:24:25 +0100 Subject: [PATCH 2/4] adding summarizepaper toggle --- browse/templates/abs/labs_tabs.html | 40 ++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/browse/templates/abs/labs_tabs.html b/browse/templates/abs/labs_tabs.html index 1aa51130f..2fefb7dc5 100644 --- a/browse/templates/abs/labs_tabs.html +++ b/browse/templates/abs/labs_tabs.html @@ -267,18 +267,38 @@

Demos

data-script-url="{{ url_for('static', filename='js/txyz.js') }}" type="checkbox" class="lab-toggle" aria-labelledby="label-for-txyz"> - Spaces Toggle + TXYZ Toggle
- TXYZ.AI (What is TXYZ.AI?) + TXYZ.AI (What is TXYZ.AI?) +
+ +
+
+ +
+
+ SummarizePaper.com (What is SummarizePaper.com?)
+
+
@@ -314,11 +334,12 @@

Recommenders and Search Tools

@@ -328,7 +349,7 @@

Recommenders and Search Tools

(What is IArxiv?)
- {% endif -%} + {% endif %}
-

+

@@ -370,3 +391,4 @@

arXivLabs: experimental projects with community collaborators

+ From 21691b984dfef69ef3931b4ac076bc1092453755 Mon Sep 17 00:00:00 2001 From: qkral <61017598+qkral@users.noreply.github.com> Date: Tue, 26 Aug 2025 15:52:51 +0200 Subject: [PATCH 3/4] Update toggle-labs.js removed merged markers --- browse/static/js/toggle-labs.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/browse/static/js/toggle-labs.js b/browse/static/js/toggle-labs.js index 5cb24b9f6..25ae9344c 100644 --- a/browse/static/js/toggle-labs.js +++ b/browse/static/js/toggle-labs.js @@ -27,10 +27,8 @@ $(document).ready(function() { "sciencecast": $('#sciencecast-toggle').data('script-url'), "gotitpub": $('#gotitpub-toggle').data('script-url'), "alphaxiv": $('#alphaxiv-toggle').data('script-url'), -<<<<<<< HEAD -======= + "summarizepaper": $('#summarizepaper-toggle').data('script-url'), ->>>>>>> Update SummarizePaper toggle functionality and improve UX across project "bibex": { "url": $('#bibex-toggle').data('script-url'), "container": "#bib-main" @@ -137,15 +135,13 @@ $(document).ready(function() { }).fail(function() { console.error("failed to load huggingface script (on cookie check)", arguments) }); -<<<<<<< HEAD -======= + } else if (key === "summarizepaper-toggle") { $.cachedScript(scripts["summarizepaper"]).done(function(script, textStatus) { console.log(textStatus); }).fail(function() { console.error("failed to load summarizepaper script (on cookie check)", arguments) }); ->>>>>>> Update SummarizePaper toggle functionality and improve UX across project } } } @@ -260,14 +256,11 @@ $(document).ready(function() { }).fail(function() { console.error("failed to load huggingface script (on lab toggle)", arguments) }); -<<<<<<< HEAD -======= } else if ($(this).attr("id") == "summarizepaper-toggle") { $.cachedScript(scripts["summarizepaper"]).done(function(script, textStatus) { }).fail(function() { console.error("failed to load summarizepaper script (on lab toggle)", arguments) }); ->>>>>>> Update SummarizePaper toggle functionality and improve UX across project } From 923639284cec1573e658298af6df4f5b69336eec Mon Sep 17 00:00:00 2001 From: qkral <61017598+qkral@users.noreply.github.com> Date: Wed, 24 Sep 2025 22:53:08 +0200 Subject: [PATCH 4/4] Update labs_tabs.html put initial svg back --- browse/templates/abs/labs_tabs.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browse/templates/abs/labs_tabs.html b/browse/templates/abs/labs_tabs.html index 2fefb7dc5..05af5d964 100644 --- a/browse/templates/abs/labs_tabs.html +++ b/browse/templates/abs/labs_tabs.html @@ -383,7 +383,7 @@

arXivLabs: experimental projects with community collaborators

Have an idea for a project that will add value for arXiv's community? Learn more about arXivLabs.

-

+