diff --git a/demo/ner_pipeline/run.py b/demo/ner_pipeline/run.py index 23315913f5..f131632aec 100644 --- a/demo/ner_pipeline/run.py +++ b/demo/ner_pipeline/run.py @@ -12,7 +12,10 @@ def ner(text): output = ner_pipeline(text) return {"text": text, "entities": output} -gr.Interface(ner, +demo = gr.Interface(ner, gr.Textbox(placeholder="Enter sentence here..."), gr.HighlightedText(), - examples=examples).launch() \ No newline at end of file + examples=examples) + +if __name__ == "__main__": + demo.launch() diff --git a/website/homepage/src/docs/template.html b/website/homepage/src/docs/template.html index 4a1ed73131..5cc41e2dea 100644 --- a/website/homepage/src/docs/template.html +++ b/website/homepage/src/docs/template.html @@ -170,15 +170,11 @@ window.__gradio_mode__ = "website"; - - {% include 'templates/footer.html' %} - - + + + + + diff --git a/website/homepage/src/guides/template.html b/website/homepage/src/guides/template.html index fa102dd4a7..f8e5d1a907 100644 --- a/website/homepage/src/guides/template.html +++ b/website/homepage/src/guides/template.html @@ -73,8 +73,6 @@ - - {% include 'templates/footer.html' %} - - + + + diff --git a/website/homepage/src/assets/add_anchors.js b/website/homepage/src/templates/add_anchors.js similarity index 100% rename from website/homepage/src/assets/add_anchors.js rename to website/homepage/src/templates/add_anchors.js diff --git a/website/homepage/src/assets/add_copy.js b/website/homepage/src/templates/add_copy.js similarity index 100% rename from website/homepage/src/assets/add_copy.js rename to website/homepage/src/templates/add_copy.js diff --git a/website/homepage/src/templates/links-nav.js b/website/homepage/src/templates/links-nav.js new file mode 100644 index 0000000000..2c8bcfc39e --- /dev/null +++ b/website/homepage/src/templates/links-nav.js @@ -0,0 +1,13 @@ +let mainNavLinks = document.querySelectorAll(".navigation a"); +window.addEventListener("scroll", event => { + let fromTop = window.scrollY; + let lowest_link = null; + mainNavLinks.forEach(link => { + let section = document.querySelector(link.hash); + if (section.offsetTop <= fromTop * 1.01) { + lowest_link = link; + } + link.classList.remove("current-nav-link"); + }); + lowest_link.classList.add("current-nav-link"); +}); diff --git a/website/homepage/src/templates/links.js b/website/homepage/src/templates/links.js deleted file mode 100644 index 7494dc40c7..0000000000 --- a/website/homepage/src/templates/links.js +++ /dev/null @@ -1,91 +0,0 @@ -let mainNavLinks = document.querySelectorAll(".navigation a"); -window.addEventListener("scroll", event => { - let fromTop = window.scrollY; - let lowest_link = null; - mainNavLinks.forEach(link => { - let section = document.querySelector(link.hash); - if (section.offsetTop <= fromTop * 1.01) { - lowest_link = link; - } - link.classList.remove("current-nav-link"); - }); - lowest_link.classList.add("current-nav-link"); -}); - - -// adds anchor button when hovering over headers, except on touch devices where instead the header becomes a link - -function createAnchorTag(link) { - let a = document.createElement('a'); - a.href = link; - a.classList.add("invisible", "group-hover-visible"); - let img = document.createElement('img'); - img.classList.add("anchor-img") - img.src = "/assets/img/anchor.svg"; - a.appendChild(img); - return a; -} -function createMobileAnchorTag(link) { - let a = document.createElement('a'); - a.href = link; - a.classList.add("no-underline") - return a; -} - -var headers = document.querySelectorAll("h2, h3"); - -function isTouchDevice() { - return (('ontouchstart' in window) || - (navigator.maxTouchPoints > 0) || - (navigator.msMaxTouchPoints > 0)); -} - -if (isTouchDevice()) { - for (let i = 0; i < headers.length; i++) { - let link = '#' + headers[i].id; - var parent = headers[i].parentNode; - var wrapper = createMobileAnchorTag(link); - parent.replaceChild(wrapper, headers[i]); - wrapper.appendChild(headers[i]); - } -} else { - for (let i = 0; i < headers.length; i++) { - headers[i].classList.add("group") - let link = '#' + headers[i].id; - var anchorTag = createAnchorTag(link); - headers[i].appendChild(createAnchorTag(link)); - } -} - -// add copy buttons to all codeblocks - -const svgCopy = - ''; -const svgCheck = - ''; - - -const addCopyButtons = (clipboard) => { - document.querySelectorAll("pre > code").forEach((codeBlock) => { - const button = document.createElement("button"); - button.classList.add("clipboard-button"); - button.type = "button"; - button.innerHTML = svgCopy; - button.addEventListener("click", () => { - clipboard.writeText(codeBlock.innerText).then( - () => { - button.blur(); - button.innerHTML = svgCheck; - setTimeout(() => (button.innerHTML = svgCopy), 2000); - }, - (error) => (button.innerHTML = "Error") - ); - }); - const pre = codeBlock.parentNode; - pre.parentNode.insertBefore(button, pre); - }); -}; - -if (navigator && navigator.clipboard) { - addCopyButtons(navigator.clipboard); -};