Add html templates, improved URL validation and control flag for shortened URL
This commit is contained in:
parent
dc9472b5fd
commit
ecbc575db7
@ -13,5 +13,6 @@ FROM scratch
|
||||
LABEL maintainer="Thomas Andrade <wolvie@gmail.com>"
|
||||
|
||||
COPY --from=builder /go/src/short/short /
|
||||
COPY templates /templates
|
||||
|
||||
ENTRYPOINT [ "/short" ]
|
114
main.go
114
main.go
@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"math/rand"
|
||||
@ -15,6 +16,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/asaskevich/govalidator"
|
||||
"github.com/gorilla/handlers"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/patrickmn/go-cache"
|
||||
@ -30,59 +32,6 @@ const (
|
||||
appVersion = "0.2.0"
|
||||
)
|
||||
|
||||
const indexPage = `
|
||||
<!DOCTYPE html>
|
||||
<html lang=en>
|
||||
<head>
|
||||
<title>Short: the simple url shortener</title>
|
||||
<style>
|
||||
form{
|
||||
position:fixed;
|
||||
top:30%;
|
||||
left:40%;
|
||||
width:500px;
|
||||
font-family:georgia,garamond,serif;
|
||||
font-size:16px;
|
||||
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<form action="/" method="POST">
|
||||
<label for="url">
|
||||
Please type the url</label>
|
||||
<br>
|
||||
<input id="url" type="text" name="url"/>
|
||||
<input type="submit" name="Submit" value="Submit"/>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
`
|
||||
|
||||
const returnPage = `
|
||||
<!DOCTYPE html>
|
||||
<html lang=en>
|
||||
<head>
|
||||
<title>Short: the simple url shortner</title>
|
||||
<style>
|
||||
.center {
|
||||
padding: 70px 0;
|
||||
border: none;
|
||||
border-color: transparent;
|
||||
text-align: center;
|
||||
font-family:georgia,garamond,serif;
|
||||
font-size:16px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="center">
|
||||
URL Shortened to <a href="%s">%s</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
`
|
||||
|
||||
var domain string
|
||||
var redisServer string
|
||||
var addr string
|
||||
@ -90,11 +39,18 @@ var port string
|
||||
var proto string
|
||||
var path string
|
||||
var dumpFile string
|
||||
var urlSize int
|
||||
var src = rand.NewSource(time.Now().UnixNano())
|
||||
var pool = cache.New(240*time.Hour, 1*time.Hour)
|
||||
var indexTmpl = template.Must(template.ParseFiles("templates/index.html"))
|
||||
var returnTmpl = template.Must(template.ParseFiles("templates/returnPage.html"))
|
||||
var notFoundTmpl = template.Must(template.ParseFiles("templates/404.html"))
|
||||
var badRequestTmpl = template.Must(template.ParseFiles("templates/400.html"))
|
||||
var internalErrorTmpl = template.Must(template.ParseFiles("templates/500.html"))
|
||||
var okTmpl = template.Must(template.ParseFiles("templates/ok.html"))
|
||||
|
||||
func index(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte(indexPage))
|
||||
indexTmpl.Execute(w, indexTmpl)
|
||||
}
|
||||
|
||||
// get executes the GET command
|
||||
@ -124,21 +80,19 @@ func redirect(w http.ResponseWriter, r *http.Request) {
|
||||
http.Redirect(w, r, url, http.StatusFound)
|
||||
} else {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
w.Write([]byte("URL don't exist"))
|
||||
notFoundTmpl.Execute(w, notFoundTmpl)
|
||||
}
|
||||
}
|
||||
|
||||
func shortner(w http.ResponseWriter, r *http.Request) {
|
||||
u, err := url.ParseRequestURI(r.FormValue("url"))
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
w.Write([]byte("Bad URL"))
|
||||
} else {
|
||||
suffix := RandStringBytesMaskImprSrc(10)
|
||||
if govalidator.IsURL(r.FormValue("url")) {
|
||||
u, _ := url.Parse(r.FormValue("url"))
|
||||
|
||||
suffix := RandStringBytesMaskImprSrc(urlSize)
|
||||
for {
|
||||
_, status := get(suffix)
|
||||
if status {
|
||||
suffix = RandStringBytesMaskImprSrc(10)
|
||||
suffix = RandStringBytesMaskImprSrc(urlSize)
|
||||
} else {
|
||||
break
|
||||
}
|
||||
@ -153,8 +107,11 @@ func shortner(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
set(u.String(), suffix)
|
||||
shortend := proto + "://" + domain + hostSuf + path + suffix
|
||||
output := fmt.Sprintf(returnPage, shortend, shortend)
|
||||
w.Write([]byte(output))
|
||||
returnTmpl.Execute(w, shortend)
|
||||
|
||||
} else {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
badRequestTmpl.Execute(w, badRequestTmpl)
|
||||
}
|
||||
}
|
||||
|
||||
@ -205,14 +162,10 @@ func itemsFromFile(w http.ResponseWriter, r *http.Request) {
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write(
|
||||
[]byte("Cannot open file " + dumpFile),
|
||||
)
|
||||
internalErrorTmpl.Execute(w, "Cannot open file "+dumpFile)
|
||||
} else {
|
||||
pool = cache.NewFrom(240*time.Hour, 1*time.Hour, dumpObj)
|
||||
w.Write(
|
||||
[]byte("OK"),
|
||||
)
|
||||
okTmpl.Execute(w, "Imported "+strconv.Itoa(len(dumpObj))+" items to the DB")
|
||||
}
|
||||
}
|
||||
|
||||
@ -223,14 +176,10 @@ func itemsFromPost(w http.ResponseWriter, r *http.Request) {
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write(
|
||||
[]byte("Cannot parse JSON"),
|
||||
)
|
||||
internalErrorTmpl.Execute(w, "Cannot parse JSON")
|
||||
} else {
|
||||
pool = cache.NewFrom(240*time.Hour, 1*time.Hour, dumpObj)
|
||||
w.Write(
|
||||
[]byte("OK"),
|
||||
)
|
||||
okTmpl.Execute(w, "Imported "+strconv.Itoa(len(dumpObj))+" items to the DB")
|
||||
}
|
||||
}
|
||||
|
||||
@ -241,21 +190,20 @@ func itemsDumpToFile(w http.ResponseWriter, r *http.Request) {
|
||||
err := ioutil.WriteFile(dumpFile, dumpObj, 0644)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write(
|
||||
[]byte("Failed to open json file"),
|
||||
)
|
||||
internalErrorTmpl.Execute(w, "Failed to open json file")
|
||||
} else {
|
||||
w.Write([]byte("Dump writen to: " + dumpFile))
|
||||
okTmpl.Execute(w, "Dump writen to: "+dumpFile)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.StringVar(&domain, "domain", "localhost", "Domain to write to the URLs")
|
||||
flag.StringVar(&addr, "addr", "localhost", "Address to listen for connections")
|
||||
flag.StringVar(&port, "port", "8080", "Port to listen for connections")
|
||||
flag.StringVar(&path, "path", "", "Path to the base URL (https://localhost/PATH/... remember to append a / at the end")
|
||||
flag.StringVar(&domain, "domain", "localhost", "Domain to write to the URLs")
|
||||
flag.StringVar(&dumpFile, "dump", "urls.json", "Path to the file to dump the kv db")
|
||||
flag.StringVar(&path, "path", "", "Path to the base URL (https://localhost/PATH/... remember to append a / at the end")
|
||||
flag.StringVar(&port, "port", "8080", "Port to listen for connections")
|
||||
flag.StringVar(&proto, "proto", "https", "proto to the base URL (HTTPS://localhost/path/... no real https here just to set the url (for like a proxy offloading https")
|
||||
flag.IntVar(&urlSize, "urlsize", 10, "Define the size of the shortened String, default 10")
|
||||
version := flag.Bool("v", false, "prints current version")
|
||||
flag.Parse()
|
||||
if *version {
|
||||
|
293
templates/400.html
Normal file
293
templates/400.html
Normal file
@ -0,0 +1,293 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang=en>
|
||||
<head>
|
||||
<title>Short: the simple url shortener</title>
|
||||
<style>
|
||||
@import url('https://fonts.googleapis.com/css?family=Abril+Fatface|Lato');
|
||||
|
||||
body {
|
||||
background: #D3DEEA;
|
||||
}
|
||||
|
||||
.top {
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
.container {
|
||||
margin: 0 auto;
|
||||
position: relative;
|
||||
width: 250px;
|
||||
height: 250px;
|
||||
margin-top: -40px;
|
||||
}
|
||||
|
||||
.ghost {
|
||||
width: 50%;
|
||||
height: 53%;
|
||||
left: 25%;
|
||||
top: 10%;
|
||||
position: absolute;
|
||||
border-radius: 50% 50% 0 0;
|
||||
background: #EDEDED;
|
||||
border: 1px solid #BFC0C0;
|
||||
border-bottom: none;
|
||||
animation: float 2s ease-out infinite;
|
||||
}
|
||||
|
||||
.ghost-copy {
|
||||
width: 50%;
|
||||
height: 53%;
|
||||
left: 25%;
|
||||
top: 10%;
|
||||
position: absolute;
|
||||
border-radius: 50% 50% 0 0;
|
||||
background: #EDEDED;
|
||||
border: 1px solid #BFC0C0;
|
||||
border-bottom: none;
|
||||
animation: float 2s ease-out infinite;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.face {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 60%;
|
||||
top: 20%;
|
||||
}
|
||||
.eye, .eye-right {
|
||||
position: absolute;
|
||||
background: #585959;
|
||||
width: 13px;
|
||||
height: 13px;
|
||||
border-radius: 50%;
|
||||
top: 40%;
|
||||
}
|
||||
|
||||
.eye {
|
||||
left: 25%;
|
||||
}
|
||||
.eye-right {
|
||||
right: 25%;
|
||||
}
|
||||
|
||||
.mouth {
|
||||
position:absolute;
|
||||
top: 50%;
|
||||
left: 45%;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border: 3px solid;
|
||||
border-radius: 50%;
|
||||
border-color: transparent #585959 #585959 transparent;
|
||||
transform: rotate(225deg);
|
||||
}
|
||||
|
||||
.one, .two, .three, .four {
|
||||
position: absolute;
|
||||
background: #EDEDED;
|
||||
top: 85%;
|
||||
width: 25%;
|
||||
height: 23%;
|
||||
border: 1px solid #BFC0C0;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.one {
|
||||
border-radius: 0 0 100% 30%;
|
||||
left: -1px;
|
||||
}
|
||||
|
||||
.two {
|
||||
left: 23%;
|
||||
border-radius: 0 0 50% 50%;
|
||||
}
|
||||
|
||||
.three {
|
||||
left: 50%;
|
||||
border-radius: 0 0 50% 50%;
|
||||
}
|
||||
|
||||
.four {
|
||||
left: 74.5%;
|
||||
border-radius: 0 0 30% 100%;
|
||||
}
|
||||
|
||||
.shadow {
|
||||
position: absolute;
|
||||
width: 30%;
|
||||
height: 7%;
|
||||
background: #BFC0C0;
|
||||
left: 35%;
|
||||
top: 80%;
|
||||
border-radius: 50%;
|
||||
animation: scale 2s infinite;
|
||||
}
|
||||
|
||||
@keyframes scale {
|
||||
0% {
|
||||
transform: scale(1);
|
||||
}
|
||||
50% {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
100% {
|
||||
transform: scale(1);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes float {
|
||||
50% {
|
||||
transform: translateY(15px);
|
||||
}
|
||||
}
|
||||
|
||||
.bottom {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
/*text styling*/
|
||||
h1 {
|
||||
font-family: 'Abril Fatface', serif;
|
||||
color: #EDEDED;
|
||||
text-align: center;
|
||||
font-size: 9em;
|
||||
margin: 0;
|
||||
text-shadow: -1px 0 #BFC0C0, 0 1px #BFC0C0, 1px 0 #BFC0C0, 0 -1px #BFC0C0;
|
||||
}
|
||||
h3 {
|
||||
font-family: 'Lato', sans-serif;
|
||||
font-size: 2em;
|
||||
text-transform: uppercase;
|
||||
text-align: center;
|
||||
color: #BFC0C0;
|
||||
margin-top: -20px;
|
||||
font-weight: 900;
|
||||
}
|
||||
p {
|
||||
text-align: center;
|
||||
font-family: 'Lato', sans-serif;
|
||||
color: #585959;
|
||||
font-size: .6em;
|
||||
margin-top: -20px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.search {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.buttons {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
/*search style*/
|
||||
|
||||
.search-bar {
|
||||
border: 1px solid #BFC0C0;
|
||||
padding: 5px;
|
||||
height: 20px;
|
||||
margin-left: -30px;
|
||||
width: 200px;
|
||||
outline: none;
|
||||
&:focus {
|
||||
border: 1px solid #D3DEEA;
|
||||
}
|
||||
}
|
||||
|
||||
.search-btn {
|
||||
position: absolute;
|
||||
width: 30px;
|
||||
height: 32px;
|
||||
border: 1px solid #BFC0C0;
|
||||
background: #BFC0C0;
|
||||
text-align: center;
|
||||
color: #EDEDED;
|
||||
cursor: pointer;
|
||||
font-size: 1em;
|
||||
outline: none;
|
||||
&:hover {
|
||||
background: #EDEDED;
|
||||
border: 1px solid #EDEDED;
|
||||
color: #BFC0C0;
|
||||
transition: all .2s ease;
|
||||
}
|
||||
}
|
||||
|
||||
.btn {
|
||||
background: #EDEDED;
|
||||
padding: 15px 20px;
|
||||
margin: 5px;
|
||||
color: #585959;
|
||||
font-family: 'Lato', sans-serif;
|
||||
text-transform: uppercase;
|
||||
font-size: .6em;
|
||||
letter-spacing: 1px;
|
||||
border: 0;
|
||||
&:hover {
|
||||
background: #BFC0C0;
|
||||
transition: all .4s ease-out;
|
||||
}
|
||||
}
|
||||
|
||||
footer {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
text-align: center;
|
||||
font-size: 0.8em;
|
||||
text-transform: uppercase;
|
||||
padding: 10px;
|
||||
color: #EA7996;
|
||||
letter-spacing: 3px;
|
||||
font-family: 'Lato', sans-serif;
|
||||
a {
|
||||
color: #ffffff;
|
||||
text-decoration: none;
|
||||
&:hover {
|
||||
color: #7d7d7d;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="background"></div>
|
||||
<div class="top">
|
||||
<h1>400</h1>
|
||||
<h3>Bad Request</h3>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="ghost-copy">
|
||||
<div class="one"></div>
|
||||
<div class="two"></div>
|
||||
<div class="three"></div>
|
||||
<div class="four"></div>
|
||||
</div>
|
||||
<div class="ghost">
|
||||
<div class="face">
|
||||
<div class="eye"></div>
|
||||
<div class="eye-right"></div>
|
||||
<div class="mouth"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="shadow"></div>
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<p>Boo, looks like a ghost didn't like your request!
|
||||
<br>
|
||||
But you can try again, type an URL below to shorten it</p>
|
||||
<form class="search" action="/" method="POST">
|
||||
<input type="text" id="url" name="url" class="search-bar" placeholder="http://something :)">
|
||||
<button type="submit" value="Submit" name="Submit" class="search-btn">
|
||||
<i class="fa fa-search"></i>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<footer>
|
||||
<p>made by <a href="https://codepen.io/juliepark"> julie</a> ♡
|
||||
</footer>
|
||||
</body>
|
293
templates/404.html
Normal file
293
templates/404.html
Normal file
@ -0,0 +1,293 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang=en>
|
||||
<head>
|
||||
<title>Short: the simple url shortener</title>
|
||||
<style>
|
||||
@import url('https://fonts.googleapis.com/css?family=Abril+Fatface|Lato');
|
||||
|
||||
body {
|
||||
background: #D3DEEA;
|
||||
}
|
||||
|
||||
.top {
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
.container {
|
||||
margin: 0 auto;
|
||||
position: relative;
|
||||
width: 250px;
|
||||
height: 250px;
|
||||
margin-top: -40px;
|
||||
}
|
||||
|
||||
.ghost {
|
||||
width: 50%;
|
||||
height: 53%;
|
||||
left: 25%;
|
||||
top: 10%;
|
||||
position: absolute;
|
||||
border-radius: 50% 50% 0 0;
|
||||
background: #EDEDED;
|
||||
border: 1px solid #BFC0C0;
|
||||
border-bottom: none;
|
||||
animation: float 2s ease-out infinite;
|
||||
}
|
||||
|
||||
.ghost-copy {
|
||||
width: 50%;
|
||||
height: 53%;
|
||||
left: 25%;
|
||||
top: 10%;
|
||||
position: absolute;
|
||||
border-radius: 50% 50% 0 0;
|
||||
background: #EDEDED;
|
||||
border: 1px solid #BFC0C0;
|
||||
border-bottom: none;
|
||||
animation: float 2s ease-out infinite;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.face {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 60%;
|
||||
top: 20%;
|
||||
}
|
||||
.eye, .eye-right {
|
||||
position: absolute;
|
||||
background: #585959;
|
||||
width: 13px;
|
||||
height: 13px;
|
||||
border-radius: 50%;
|
||||
top: 40%;
|
||||
}
|
||||
|
||||
.eye {
|
||||
left: 25%;
|
||||
}
|
||||
.eye-right {
|
||||
right: 25%;
|
||||
}
|
||||
|
||||
.mouth {
|
||||
position:absolute;
|
||||
top: 50%;
|
||||
left: 45%;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border: 3px solid;
|
||||
border-radius: 50%;
|
||||
border-color: transparent #585959 #585959 transparent;
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
||||
.one, .two, .three, .four {
|
||||
position: absolute;
|
||||
background: #EDEDED;
|
||||
top: 85%;
|
||||
width: 25%;
|
||||
height: 23%;
|
||||
border: 1px solid #BFC0C0;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.one {
|
||||
border-radius: 0 0 100% 30%;
|
||||
left: -1px;
|
||||
}
|
||||
|
||||
.two {
|
||||
left: 23%;
|
||||
border-radius: 0 0 50% 50%;
|
||||
}
|
||||
|
||||
.three {
|
||||
left: 50%;
|
||||
border-radius: 0 0 50% 50%;
|
||||
}
|
||||
|
||||
.four {
|
||||
left: 74.5%;
|
||||
border-radius: 0 0 30% 100%;
|
||||
}
|
||||
|
||||
.shadow {
|
||||
position: absolute;
|
||||
width: 30%;
|
||||
height: 7%;
|
||||
background: #BFC0C0;
|
||||
left: 35%;
|
||||
top: 80%;
|
||||
border-radius: 50%;
|
||||
animation: scale 2s infinite;
|
||||
}
|
||||
|
||||
@keyframes scale {
|
||||
0% {
|
||||
transform: scale(1);
|
||||
}
|
||||
50% {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
100% {
|
||||
transform: scale(1);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes float {
|
||||
50% {
|
||||
transform: translateY(15px);
|
||||
}
|
||||
}
|
||||
|
||||
.bottom {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
/*text styling*/
|
||||
h1 {
|
||||
font-family: 'Abril Fatface', serif;
|
||||
color: #EDEDED;
|
||||
text-align: center;
|
||||
font-size: 9em;
|
||||
margin: 0;
|
||||
text-shadow: -1px 0 #BFC0C0, 0 1px #BFC0C0, 1px 0 #BFC0C0, 0 -1px #BFC0C0;
|
||||
}
|
||||
h3 {
|
||||
font-family: 'Lato', sans-serif;
|
||||
font-size: 2em;
|
||||
text-transform: uppercase;
|
||||
text-align: center;
|
||||
color: #BFC0C0;
|
||||
margin-top: -20px;
|
||||
font-weight: 900;
|
||||
}
|
||||
p {
|
||||
text-align: center;
|
||||
font-family: 'Lato', sans-serif;
|
||||
color: #585959;
|
||||
font-size: .6em;
|
||||
margin-top: -20px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.search {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.buttons {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
/*search style*/
|
||||
|
||||
.search-bar {
|
||||
border: 1px solid #BFC0C0;
|
||||
padding: 5px;
|
||||
height: 20px;
|
||||
margin-left: -30px;
|
||||
width: 200px;
|
||||
outline: none;
|
||||
&:focus {
|
||||
border: 1px solid #D3DEEA;
|
||||
}
|
||||
}
|
||||
|
||||
.search-btn {
|
||||
position: absolute;
|
||||
width: 30px;
|
||||
height: 32px;
|
||||
border: 1px solid #BFC0C0;
|
||||
background: #BFC0C0;
|
||||
text-align: center;
|
||||
color: #EDEDED;
|
||||
cursor: pointer;
|
||||
font-size: 1em;
|
||||
outline: none;
|
||||
&:hover {
|
||||
background: #EDEDED;
|
||||
border: 1px solid #EDEDED;
|
||||
color: #BFC0C0;
|
||||
transition: all .2s ease;
|
||||
}
|
||||
}
|
||||
|
||||
.btn {
|
||||
background: #EDEDED;
|
||||
padding: 15px 20px;
|
||||
margin: 5px;
|
||||
color: #585959;
|
||||
font-family: 'Lato', sans-serif;
|
||||
text-transform: uppercase;
|
||||
font-size: .6em;
|
||||
letter-spacing: 1px;
|
||||
border: 0;
|
||||
&:hover {
|
||||
background: #BFC0C0;
|
||||
transition: all .4s ease-out;
|
||||
}
|
||||
}
|
||||
|
||||
footer {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
text-align: center;
|
||||
font-size: 0.8em;
|
||||
text-transform: uppercase;
|
||||
padding: 10px;
|
||||
color: #EA7996;
|
||||
letter-spacing: 3px;
|
||||
font-family: 'Lato', sans-serif;
|
||||
a {
|
||||
color: #ffffff;
|
||||
text-decoration: none;
|
||||
&:hover {
|
||||
color: #7d7d7d;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="background"></div>
|
||||
<div class="top">
|
||||
<h1>404</h1>
|
||||
<h3>page not found</h3>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="ghost-copy">
|
||||
<div class="one"></div>
|
||||
<div class="two"></div>
|
||||
<div class="three"></div>
|
||||
<div class="four"></div>
|
||||
</div>
|
||||
<div class="ghost">
|
||||
<div class="face">
|
||||
<div class="eye"></div>
|
||||
<div class="eye-right"></div>
|
||||
<div class="mouth"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="shadow"></div>
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<p>Boo, looks like a ghost stole this page!
|
||||
<br>
|
||||
But you can type an URL below to shorten it</p>
|
||||
<form class="search" action="/" method="POST">
|
||||
<input type="text" id="url" name="url" class="search-bar" placeholder="http://something :)">
|
||||
<button type="submit" value="Submit" name="Submit" class="search-btn">
|
||||
<i class="fa fa-search"></i>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<footer>
|
||||
<p>made by <a href="https://codepen.io/juliepark"> julie</a> ♡
|
||||
</footer>
|
||||
</body>
|
287
templates/500.html
Normal file
287
templates/500.html
Normal file
@ -0,0 +1,287 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang=en>
|
||||
<head>
|
||||
<title>Short: the simple url shortener</title>
|
||||
<style>
|
||||
@import url('https://fonts.googleapis.com/css?family=Abril+Fatface|Lato');
|
||||
|
||||
body {
|
||||
background: #D3DEEA;
|
||||
}
|
||||
|
||||
.top {
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
.container {
|
||||
margin: 0 auto;
|
||||
position: relative;
|
||||
width: 250px;
|
||||
height: 250px;
|
||||
margin-top: -40px;
|
||||
}
|
||||
|
||||
.ghost {
|
||||
width: 50%;
|
||||
height: 53%;
|
||||
left: 25%;
|
||||
top: 10%;
|
||||
position: absolute;
|
||||
border-radius: 50% 50% 0 0;
|
||||
background: #EDEDED;
|
||||
border: 1px solid #BFC0C0;
|
||||
border-bottom: none;
|
||||
animation: float 2s ease-out infinite;
|
||||
}
|
||||
|
||||
.ghost-copy {
|
||||
width: 50%;
|
||||
height: 53%;
|
||||
left: 25%;
|
||||
top: 10%;
|
||||
position: absolute;
|
||||
border-radius: 50% 50% 0 0;
|
||||
background: #EDEDED;
|
||||
border: 1px solid #BFC0C0;
|
||||
border-bottom: none;
|
||||
animation: float 2s ease-out infinite;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.face {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 60%;
|
||||
top: 20%;
|
||||
}
|
||||
.eye, .eye-right {
|
||||
position: absolute;
|
||||
{# background: #585959; #}
|
||||
width: 13px;
|
||||
height: 13px;
|
||||
border-radius: 50%;
|
||||
top: 40%;
|
||||
}
|
||||
|
||||
.eye {
|
||||
left: 25%;
|
||||
}
|
||||
.eye-right {
|
||||
right: 25%;
|
||||
}
|
||||
|
||||
.mouth {
|
||||
position:absolute;
|
||||
top: 50%;
|
||||
left: 45%;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border: 3px solid;
|
||||
border-radius: 50%;
|
||||
border-color: transparent #585959 #585959 transparent;
|
||||
transform: rotate(225deg);
|
||||
}
|
||||
|
||||
.one, .two, .three, .four {
|
||||
position: absolute;
|
||||
background: #EDEDED;
|
||||
top: 85%;
|
||||
width: 25%;
|
||||
height: 23%;
|
||||
border: 1px solid #BFC0C0;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.one {
|
||||
border-radius: 0 0 100% 30%;
|
||||
left: -1px;
|
||||
}
|
||||
|
||||
.two {
|
||||
left: 23%;
|
||||
border-radius: 0 0 50% 50%;
|
||||
}
|
||||
|
||||
.three {
|
||||
left: 50%;
|
||||
border-radius: 0 0 50% 50%;
|
||||
}
|
||||
|
||||
.four {
|
||||
left: 74.5%;
|
||||
border-radius: 0 0 30% 100%;
|
||||
}
|
||||
|
||||
.shadow {
|
||||
position: absolute;
|
||||
width: 30%;
|
||||
height: 7%;
|
||||
background: #BFC0C0;
|
||||
left: 35%;
|
||||
top: 80%;
|
||||
border-radius: 50%;
|
||||
animation: scale 2s infinite;
|
||||
}
|
||||
|
||||
@keyframes scale {
|
||||
0% {
|
||||
transform: scale(1);
|
||||
}
|
||||
50% {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
100% {
|
||||
transform: scale(1);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes float {
|
||||
50% {
|
||||
transform: translateY(15px);
|
||||
}
|
||||
}
|
||||
|
||||
.bottom {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
/*text styling*/
|
||||
h1 {
|
||||
font-family: 'Abril Fatface', serif;
|
||||
color: #EDEDED;
|
||||
text-align: center;
|
||||
font-size: 9em;
|
||||
margin: 0;
|
||||
text-shadow: -1px 0 #BFC0C0, 0 1px #BFC0C0, 1px 0 #BFC0C0, 0 -1px #BFC0C0;
|
||||
}
|
||||
h3 {
|
||||
font-family: 'Lato', sans-serif;
|
||||
font-size: 2em;
|
||||
text-transform: uppercase;
|
||||
text-align: center;
|
||||
color: #BFC0C0;
|
||||
margin-top: -20px;
|
||||
font-weight: 900;
|
||||
}
|
||||
p {
|
||||
text-align: center;
|
||||
font-family: 'Lato', sans-serif;
|
||||
color: #585959;
|
||||
font-size: .6em;
|
||||
margin-top: -20px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.search {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.buttons {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
/*search style*/
|
||||
|
||||
.search-bar {
|
||||
border: 1px solid #BFC0C0;
|
||||
padding: 5px;
|
||||
height: 20px;
|
||||
margin-left: -30px;
|
||||
width: 200px;
|
||||
outline: none;
|
||||
&:focus {
|
||||
border: 1px solid #D3DEEA;
|
||||
}
|
||||
}
|
||||
|
||||
.search-btn {
|
||||
position: absolute;
|
||||
width: 30px;
|
||||
height: 32px;
|
||||
border: 1px solid #BFC0C0;
|
||||
background: #BFC0C0;
|
||||
text-align: center;
|
||||
color: #EDEDED;
|
||||
cursor: pointer;
|
||||
font-size: 1em;
|
||||
outline: none;
|
||||
&:hover {
|
||||
background: #EDEDED;
|
||||
border: 1px solid #EDEDED;
|
||||
color: #BFC0C0;
|
||||
transition: all .2s ease;
|
||||
}
|
||||
}
|
||||
|
||||
.btn {
|
||||
background: #EDEDED;
|
||||
padding: 15px 20px;
|
||||
margin: 5px;
|
||||
color: #585959;
|
||||
font-family: 'Lato', sans-serif;
|
||||
text-transform: uppercase;
|
||||
font-size: .6em;
|
||||
letter-spacing: 1px;
|
||||
border: 0;
|
||||
&:hover {
|
||||
background: #BFC0C0;
|
||||
transition: all .4s ease-out;
|
||||
}
|
||||
}
|
||||
|
||||
footer {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
text-align: center;
|
||||
font-size: 0.8em;
|
||||
text-transform: uppercase;
|
||||
padding: 10px;
|
||||
color: #EA7996;
|
||||
letter-spacing: 3px;
|
||||
font-family: 'Lato', sans-serif;
|
||||
a {
|
||||
color: #ffffff;
|
||||
text-decoration: none;
|
||||
&:hover {
|
||||
color: #7d7d7d;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="background"></div>
|
||||
<div class="top">
|
||||
<h1>500</h1>
|
||||
<h3>Internal server error</h3>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="ghost-copy">
|
||||
<div class="one"></div>
|
||||
<div class="two"></div>
|
||||
<div class="three"></div>
|
||||
<div class="four"></div>
|
||||
</div>
|
||||
<div class="ghost">
|
||||
<div class="face">
|
||||
<div class="eye"><h3 style="color:black;font-size:1.5em">X</h3></div>
|
||||
<div class="eye-right"><h3 style="color:black;font-size:1.5em">X</h3></div>
|
||||
<div class="mouth"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="shadow"></div>
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<p>Boo, the ghost is broken :(
|
||||
<br>
|
||||
His last words where: {{ . }} </p>
|
||||
</div>
|
||||
|
||||
<footer>
|
||||
<p>made by <a href="https://codepen.io/juliepark"> julie</a> ♡
|
||||
</footer>
|
||||
</body>
|
87
templates/index.html
Normal file
87
templates/index.html
Normal file
@ -0,0 +1,87 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang=en>
|
||||
<head>
|
||||
<title>Short: the simple url shortener</title>
|
||||
<style>
|
||||
@import url('https://fonts.googleapis.com/css?family=Abril+Fatface|Lato');
|
||||
|
||||
body {
|
||||
background: #D3DEEA;
|
||||
}
|
||||
|
||||
form{
|
||||
position:fixed;
|
||||
top:32%;
|
||||
left:35%;
|
||||
width:500px;
|
||||
font-family:georgia,garamond,serif;
|
||||
font-size:16px;
|
||||
|
||||
}
|
||||
.bottom {
|
||||
position:fixed;
|
||||
top:30%;
|
||||
left:35%;
|
||||
width:500px;
|
||||
}
|
||||
|
||||
p {
|
||||
text-align: center;
|
||||
font-family: 'Lato', sans-serif;
|
||||
color: #585959;
|
||||
font-size: .6em;
|
||||
margin-top: -20px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.search {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.search-bar {
|
||||
border: 1px solid #BFC0C0;
|
||||
padding: 5px;
|
||||
height: 20px;
|
||||
margin-left: -30px;
|
||||
width: 200px;
|
||||
outline: none;
|
||||
&:focus {
|
||||
border: 1px solid #D3DEEA;
|
||||
}
|
||||
}
|
||||
|
||||
.search-btn {
|
||||
position: absolute;
|
||||
width: 30px;
|
||||
height: 32px;
|
||||
border: 1px solid #BFC0C0;
|
||||
background: #BFC0C0;
|
||||
text-align: center;
|
||||
color: #EDEDED;
|
||||
cursor: pointer;
|
||||
font-size: 1em;
|
||||
outline: none;
|
||||
&:hover {
|
||||
background: #EDEDED;
|
||||
border: 1px solid #EDEDED;
|
||||
color: #BFC0C0;
|
||||
transition: all .2s ease;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="bottom">
|
||||
<p>Welcome to Short, the simple URL shortener,
|
||||
<br>
|
||||
Type an URL below to shorten it</p>
|
||||
<form class="search" action="/" method="POST">
|
||||
<input type="text" id="url" name="url" class="search-bar" placeholder="http://something :)">
|
||||
<button type="submit" value="Submit" name="Submit" class="search-btn">
|
||||
<i class="fa fa-search"></i>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
33
templates/ok.html
Normal file
33
templates/ok.html
Normal file
@ -0,0 +1,33 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang=en>
|
||||
<head>
|
||||
<title>Short: the simple url shortner</title>
|
||||
<style>
|
||||
@import url('https://fonts.googleapis.com/css?family=Abril+Fatface|Lato');
|
||||
|
||||
body {
|
||||
background: #D3DEEA;
|
||||
}
|
||||
|
||||
.bottom {
|
||||
position:fixed;
|
||||
top:30%;
|
||||
left:35%;
|
||||
}
|
||||
|
||||
p {
|
||||
text-align: center;
|
||||
font-family: 'Lato', sans-serif;
|
||||
color: #585959;
|
||||
font-size: .9em;
|
||||
margin-top: -20px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="bottom">
|
||||
<p>{{ . }}</a></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
33
templates/returnPage.html
Normal file
33
templates/returnPage.html
Normal file
@ -0,0 +1,33 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang=en>
|
||||
<head>
|
||||
<title>Short: the simple url shortner</title>
|
||||
<style>
|
||||
@import url('https://fonts.googleapis.com/css?family=Abril+Fatface|Lato');
|
||||
|
||||
body {
|
||||
background: #D3DEEA;
|
||||
}
|
||||
|
||||
.bottom {
|
||||
position:fixed;
|
||||
top:30%;
|
||||
left:35%;
|
||||
}
|
||||
|
||||
p {
|
||||
text-align: center;
|
||||
font-family: 'Lato', sans-serif;
|
||||
color: #585959;
|
||||
font-size: 1em;
|
||||
margin-top: -20px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="bottom">
|
||||
<p>URL Shortened to <a href="{{ . }}">{{ . }}</a></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user