Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build image
FROM crystallang/crystal:1.10.1-alpine as builder
FROM crystallang/crystal:1.15.1-alpine as builder
WORKDIR /opt
# Cache dependencies
COPY ./shard.yml ./shard.lock /opt/
Expand Down
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ development_dependencies:
github: crystal-ameba/ameba
version: ~> 1.5.0

crystal: 1.10.1
crystal: 1.15

license: MIT
11 changes: 11 additions & 0 deletions src/server.cr
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ get "/" do |env|
end
end

get "/s/:scheme/:url" do |env|
begin
fallback_url = URI.parse(env.params.url["url"])
target_uri = URI.parse(env.params.url["url"])
target_uri.scheme = env.params.url["scheme"]
render "src/views/s.ecr"
rescue udl_error
render "src/views/fallback.ecr"
end
end

get "/.well-known/apple-app-site-association" do |env|
env.response.content_type = "application/json"

Expand Down
57 changes: 57 additions & 0 deletions src/views/s.ecr
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<!DOCTYPE html>
<html lang="en">
<body style="text-align: center; padding-top: 50px;">

<style>
.container {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
}

.spinner {
width: 50px;
height: 50px;
border: 5px solid #f3f3f3;
border-top: 5px solid #3498db;
border-radius: 50%;
animation: spin 1s linear infinite;
margin: 0 auto;
}

@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}

.loading-text {
margin-top: 20px;
font-family: Arial, sans-serif;
}
</style>

<div class="container">
<div class="spinner"></div>
<div class="loading-text">Redirecting to your destination...</div>
</div>

<script type="text/javascript">
window.onload = function() {
// Deep link to your app goes here
document.getElementById("l").src = "<%= target_uri.to_s %>";

setTimeout(function() {
window.location = "<%= fallback_url.to_s %>";

setTimeout(function() {
window.close();
}, 1000);
}, 600);
};
</script>
<iframe id="l" width="1" height="1" style="visibility:hidden"></iframe>

</body>
</html>