Spaces:
Running
Running
Message if iframe.
Browse files
main.py
CHANGED
@@ -936,6 +936,52 @@ def render_kta():
|
|
936 |
return out_div
|
937 |
|
938 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
939 |
iframe_js_detect = """
|
940 |
function isInIframe() {
|
941 |
try {
|
@@ -945,14 +991,25 @@ function isInIframe() {
|
|
945 |
}
|
946 |
}
|
947 |
|
948 |
-
|
|
|
|
|
|
|
|
|
949 |
if (isInIframe()) {
|
950 |
-
|
951 |
-
} else {
|
952 |
-
console.log("This page is not in an iframe");
|
953 |
}
|
954 |
"""
|
955 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
956 |
@rt("/")
|
957 |
def index_get(session):
|
958 |
if 'session_id' not in session:
|
@@ -973,7 +1030,10 @@ def index_get(session):
|
|
973 |
title = Title('C code review for students')
|
974 |
kta_social = render_kta()
|
975 |
iframe_script = Script(iframe_js_detect)
|
|
|
976 |
preamble = [
|
|
|
|
|
977 |
iframe_script,
|
978 |
auth_area,
|
979 |
H1("Evaluate your C code!"),
|
|
|
936 |
return out_div
|
937 |
|
938 |
|
939 |
+
iframe_overlay_style= """
|
940 |
+
#iframe-overlay {
|
941 |
+
display: none;
|
942 |
+
position: fixed;
|
943 |
+
top: 0;
|
944 |
+
left: 0;
|
945 |
+
width: 100%;
|
946 |
+
height: 100%;
|
947 |
+
background-color: rgba(0, 0, 0, 0.8);
|
948 |
+
z-index: 9999;
|
949 |
+
font-family: Arial, sans-serif;
|
950 |
+
}
|
951 |
+
|
952 |
+
#iframe-overlay-content {
|
953 |
+
position: absolute;
|
954 |
+
top: 50%;
|
955 |
+
left: 50%;
|
956 |
+
transform: translate(-50%, -50%);
|
957 |
+
text-align: center;
|
958 |
+
background-color: rgba(255, 255, 255, 0.9);
|
959 |
+
padding: 20px;
|
960 |
+
border-radius: 10px;
|
961 |
+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
|
962 |
+
}
|
963 |
+
|
964 |
+
#iframe-overlay-content h2 {
|
965 |
+
color: #333;
|
966 |
+
margin-bottom: 10px;
|
967 |
+
}
|
968 |
+
|
969 |
+
#iframe-overlay-content p {
|
970 |
+
color: #555;
|
971 |
+
margin-bottom: 15px;
|
972 |
+
}
|
973 |
+
|
974 |
+
#iframe-overlay-content a {
|
975 |
+
color: #10A010;
|
976 |
+
text-decoration: none;
|
977 |
+
font-weight: bold;
|
978 |
+
font-size: 32px;
|
979 |
+
}
|
980 |
+
|
981 |
+
#iframe-overlay-content a:hover {
|
982 |
+
text-decoration: underline;
|
983 |
+
}"""
|
984 |
+
|
985 |
iframe_js_detect = """
|
986 |
function isInIframe() {
|
987 |
try {
|
|
|
991 |
}
|
992 |
}
|
993 |
|
994 |
+
function showOverlay() {
|
995 |
+
const overlay = document.getElementById('iframe-overlay');
|
996 |
+
overlay.style.display = 'block';
|
997 |
+
}
|
998 |
+
|
999 |
if (isInIframe()) {
|
1000 |
+
showOverlay();
|
|
|
|
|
1001 |
}
|
1002 |
"""
|
1003 |
|
1004 |
+
def html_get_iframe_overlay():
|
1005 |
+
msgs = [
|
1006 |
+
H2("Access the space directly to get full functionality:"),
|
1007 |
+
H3("Click the link below:"),
|
1008 |
+
A("ml-visoft-c-reviewer.hf.space", href="https://ml-visoft-c-reviewer.hf.space/"),
|
1009 |
+
]
|
1010 |
+
divs = Div(Div(*msgs, id="iframe-overlay-content"), id="iframe-overlay")
|
1011 |
+
return divs
|
1012 |
+
|
1013 |
@rt("/")
|
1014 |
def index_get(session):
|
1015 |
if 'session_id' not in session:
|
|
|
1030 |
title = Title('C code review for students')
|
1031 |
kta_social = render_kta()
|
1032 |
iframe_script = Script(iframe_js_detect)
|
1033 |
+
iframe_css = Style(iframe_overlay_style)
|
1034 |
preamble = [
|
1035 |
+
iframe_css,
|
1036 |
+
html_get_iframe_overlay(),
|
1037 |
iframe_script,
|
1038 |
auth_area,
|
1039 |
H1("Evaluate your C code!"),
|