Skip to content

Commit 7f28be1

Browse files
committed
add redirection. Closes #3
1 parent a0ee51c commit 7f28be1

File tree

2 files changed

+108
-8
lines changed

2 files changed

+108
-8
lines changed

main.go

+1-8
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,7 @@ func getPollOptionVote(w http.ResponseWriter, r *http.Request) {
8282
return
8383
}
8484

85-
// if url := r.Header.Get("Referer"); url != "" {
86-
// log.WithField("url", url).Info("redirect")
87-
// w.Header().Set("Location", url)
88-
// response.Found(w, "Voted!")
89-
// return
90-
// }
91-
92-
response.OK(w, "Voted!")
85+
http.ServeFile(w, r, "static/voted.html")
9386
}
9487

9588
// getPollOption responds with a poll option svg.

static/voted.html

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Thanks for the vote!</title>
6+
<style>
7+
:root {
8+
--color: #7048E8;
9+
--color-light: #E5DBFF;
10+
--background: #FBFAFF;
11+
--size: 500px;
12+
--ease: cubic-bezier(0.175, 0.885, 0.32, 1.275);
13+
}
14+
15+
@keyframes thanks {
16+
from {
17+
opacity: 0;
18+
transform: scale(0.5, 0.5);
19+
}
20+
21+
to {
22+
opacity: 1;
23+
transform: scale(1, 1);
24+
}
25+
}
26+
27+
html, body {
28+
width: 100%;
29+
height: 100%;
30+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
31+
font-size: 15px;
32+
}
33+
34+
#container {
35+
display: flex;
36+
justify-content: center;
37+
align-items: center;
38+
width: 100%;
39+
height: 100%;
40+
}
41+
42+
#thanks-container {
43+
display: flex;
44+
justify-content: center;
45+
align-items: center;
46+
flex-direction: column;
47+
background: var(--background);
48+
width: var(--size);
49+
height: var(--size);
50+
border-radius: 3px;
51+
animation: thanks 800ms var(--ease);
52+
}
53+
54+
#thanks {
55+
font-size: 1.5rem;
56+
font-weight: 300;
57+
letter-spacing: 2px;
58+
color: var(--color);
59+
padding: 15px 0 5px 0;
60+
text-shadow: 1px 1px var(--color-light);
61+
}
62+
63+
#redirect {
64+
font-size: 0.8rem;
65+
color: var(--color);
66+
opacity: .6;
67+
}
68+
</style>
69+
</head>
70+
<body>
71+
<div id="container">
72+
<div id="thanks-container">
73+
<svg width="60px" height="60px" viewBox="0 0 60 60" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
74+
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
75+
<g id="Artboard" transform="translate(-325.000000, -310.000000)">
76+
<g id="cat" transform="translate(325.000000, 310.000000)">
77+
<g id="Duotone" transform="translate(1.000000, 1.000000)">
78+
<polygon id="Shape" fill="#FFFFFF" fill-rule="nonzero" points="52.75 34 29.75 21.25 29.75 21.25 35.25 19 35.25 0.25 27.75 5.25 17.75 5.25 10.25 0.25 10.25 19 15.25 21 15.25 57.75 52.75 57.75 57.75 49"></polygon>
79+
<path d="M22.75,24 L15.25,21 L15.25,26 L22.75,29 L35,24 L29.75,21 L22.75,24 Z" id="Shape" fill="#E5DBFF" fill-rule="nonzero"></path>
80+
<path d="M15.25,52.75 L15.25,57.75 L52.75,57.75 L57.75,49 L52.75,49 L50.25,52.75 L15.25,52.75 Z" id="Shape" fill="#E5DBFF" fill-rule="nonzero"></path>
81+
<path d="M17.75,10.25 L17.75,12.75" id="Shape" stroke="#7048E8" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path>
82+
<path d="M27.75,10.25 L27.75,12.75" id="Shape" stroke="#7048E8" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path>
83+
<polyline id="Shape" stroke="#7048E8" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" points="15.25 57.75 6.5 57.75 0.25 51.5 6.5 42.75 1.5 37.75 5.25 32.75"></polyline>
84+
<polygon id="Shape" stroke="#7048E8" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" points="27.75 5.25 17.75 5.25 10.25 0.25 10.25 19 22.75 24 35.25 19 35.25 0.25"></polygon>
85+
<polyline id="Shape" stroke="#7048E8" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" points="15.25 21 15.25 57.75 52.75 57.75 57.75 49 52.75 34 29.75 21.25"></polyline>
86+
<path d="M30.25,57.75 L30.25,35.25" id="Shape" stroke="#7048E8" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path>
87+
<path d="M22.75,57.75 L22.75,35.25" id="Shape" stroke="#7048E8" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path>
88+
<polyline id="Shape" stroke="#7048E8" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" points="45.25 42.75 39 42.75 30.25 52.75"></polyline>
89+
</g>
90+
<g id="Frames-24px">
91+
<rect id="Rectangle-path" x="0" y="0" width="60" height="60"></rect>
92+
</g>
93+
</g>
94+
</g>
95+
</g>
96+
</svg>
97+
<div id="thanks">Thanks for voting!</div>
98+
<div id="redirect">Redirecting you back in a second.</div>
99+
</div>
100+
</div>
101+
<script>
102+
setTimeout(function(){
103+
window.history.back()
104+
}, 2000)
105+
</script>
106+
</body>
107+
</html>

0 commit comments

Comments
 (0)