Spaces:
Sleeping
Sleeping
Commit ·
59a4389
1
Parent(s): ef0c5fd
login fix
Browse files
app.py
CHANGED
|
@@ -104,6 +104,28 @@ def create_ui():
|
|
| 104 |
"This avoids rate limiting issues and allows you to fetch gated datasets. "
|
| 105 |
"If your dataset is not on Hugging Face, you can still use the validator without logging in.</p>")
|
| 106 |
gr.LoginButton(elem_classes=["login-button"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
# Track the active tab for conditional UI updates
|
| 109 |
active_tab = gr.State("upload") # Default to upload tab
|
|
|
|
| 104 |
"This avoids rate limiting issues and allows you to fetch gated datasets. "
|
| 105 |
"If your dataset is not on Hugging Face, you can still use the validator without logging in.</p>")
|
| 106 |
gr.LoginButton(elem_classes=["login-button"])
|
| 107 |
+
gr.HTML("""
|
| 108 |
+
<script>
|
| 109 |
+
(function() {
|
| 110 |
+
function patchLoginButton() {
|
| 111 |
+
document.querySelectorAll('.login-button button').forEach(function(btn) {
|
| 112 |
+
if (btn.dataset.oauthPatched) return;
|
| 113 |
+
btn.dataset.oauthPatched = '1';
|
| 114 |
+
btn.addEventListener('click', function(e) {
|
| 115 |
+
e.preventDefault();
|
| 116 |
+
e.stopImmediatePropagation();
|
| 117 |
+
var targetUrl = window.location.pathname + (window.location.search || '');
|
| 118 |
+
window.open('/login?_target_url=' + encodeURIComponent(targetUrl), '_blank');
|
| 119 |
+
}, true);
|
| 120 |
+
});
|
| 121 |
+
}
|
| 122 |
+
var observer = new MutationObserver(patchLoginButton);
|
| 123 |
+
observer.observe(document.body, {childList: true, subtree: true});
|
| 124 |
+
patchLoginButton();
|
| 125 |
+
setTimeout(patchLoginButton, 1000);
|
| 126 |
+
})();
|
| 127 |
+
</script>
|
| 128 |
+
""")
|
| 129 |
|
| 130 |
# Track the active tab for conditional UI updates
|
| 131 |
active_tab = gr.State("upload") # Default to upload tab
|