Skip to content

Commit

Permalink
Avoid overflow for navigation buttons
Browse files Browse the repository at this point in the history
Enable full screen mode for images
Restrict users from viewing cached page using back button
  • Loading branch information
dormant-user committed Feb 28, 2024
1 parent 717fc17 commit 8762709
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/templates/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,11 @@ pub fn get_content() -> String {
</body>
<!-- control the behavior of the browser's navigation without triggering a full page reload -->
<script>
history.pushState(null, document.title, location.href);
window.addEventListener('popstate', function (event) {
document.addEventListener('DOMContentLoaded', function() {
history.pushState(null, document.title, location.href);
window.addEventListener('popstate', function (event) {
history.pushState(null, document.title, location.href);
});
});
</script>
<!-- handle authentication from login page -->
Expand Down
39 changes: 37 additions & 2 deletions src/templates/landing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,20 @@ pub fn get_content() -> String {
height: 75vh; /* Set height to 75% of the viewport height */
margin: 0 auto; /* Center the container horizontally */
}
#nav-container {
position: relative;
width: 70%;
margin: 0 auto; /* Center the container horizontally */
}
#image-source {
max-width: 100%;
height: 75vh;
margin: 0 auto; /* Center the container horizontally */
display: flex;
justify-content: center;
align-items: center; /* Center the container vertically */
cursor: pointer; /* Add a pointer cursor to indicate it's clickable */
overflow: hidden; /* Avoid vertical overflow */
}
#video-player {
position: relative;
Expand Down Expand Up @@ -158,7 +165,7 @@ pub fn get_content() -> String {
<br><br>
<h1>{{ media_title }}</h1>
{% if render_image %}
<img id="image-source" src="">
<img id="image-source" src="" onclick="fullScreen()">
{% else %}
<div id="content-container">
<video id="video-player"
Expand All @@ -185,7 +192,7 @@ pub fn get_content() -> String {
</video>
</div>
{% endif %}
<div id="content-container">
<div id="nav-container">
{% if previous %}
<button class="iter" style="float: left" onclick="window.location='{{ previous }}'" title="{{ previous }}">
<i class="fa fa-backward"></i> Previous
Expand Down Expand Up @@ -238,6 +245,34 @@ pub fn get_content() -> String {
window.history.back();
}
</script>
<script>
function fullScreen() {
var image = document.getElementById("image-source");
if (!document.fullscreenElement && !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement) {
// Enter fullscreen mode
if (image.requestFullscreen) {
image.requestFullscreen();
} else if (image.mozRequestFullScreen) { /* Firefox */
image.mozRequestFullScreen();
} else if (image.webkitRequestFullscreen) { /* Chrome, Safari and Opera */
image.webkitRequestFullscreen();
} else if (image.msRequestFullscreen) { /* IE/Edge */
image.msRequestFullscreen();
}
} else {
// Exit fullscreen mode
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.mozCancelFullScreen) { /* Firefox */
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) { /* Chrome, Safari and Opera */
document.webkitExitFullscreen();
} else if (document.msExitFullscreen) { /* IE/Edge */
document.msExitFullscreen();
}
}
}
</script>
</body>
</html>
"###.to_string()
Expand Down
9 changes: 9 additions & 0 deletions src/templates/logout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ pub fn get_content() -> String {
{% endif %}
<h4>Click <a href="https://vigneshrao.com/contact">ME</a> to reach out.</h4>
</body>
<!-- control the behavior of the browser's navigation without triggering a full page reload -->
<script>
document.addEventListener('DOMContentLoaded', function() {
history.pushState(null, document.title, location.href);
window.addEventListener('popstate', function (event) {
history.pushState(null, document.title, location.href);
});
});
</script>
</html>
"###.to_string()
}
9 changes: 9 additions & 0 deletions src/templates/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ pub fn get_content() -> String {
</button>
<h4>Click <a href="https://vigneshrao.com/contact">HERE</a> to reach out.</h4>
</body>
<!-- control the behavior of the browser's navigation without triggering a full page reload -->
<script>
document.addEventListener('DOMContentLoaded', function() {
history.pushState(null, document.title, location.href);
window.addEventListener('popstate', function (event) {
history.pushState(null, document.title, location.href);
});
});
</script>
</html>
"###.to_string()
}
9 changes: 9 additions & 0 deletions src/templates/unauthorized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ pub fn get_content() -> String {
</button>
<h4>Click <a href="https://vigneshrao.com/contact">HERE</a> to reach out.</h4>
</body>
<!-- control the behavior of the browser's navigation without triggering a full page reload -->
<script>
document.addEventListener('DOMContentLoaded', function() {
history.pushState(null, document.title, location.href);
window.addEventListener('popstate', function (event) {
history.pushState(null, document.title, location.href);
});
});
</script>
</html>
"###.to_string()
}

0 comments on commit 8762709

Please sign in to comment.