mirror of
https://github.com/httpjamesm/launchpad-redirects.git
synced 2024-12-06 19:16:34 +01:00
feat: error msgs
This commit is contained in:
@@ -27,7 +27,7 @@ func main() {
|
||||
parsed, err := url.Parse(inputUrl)
|
||||
if err != nil {
|
||||
c.HTML(200, "home.html", gin.H{
|
||||
"error": err.Error(),
|
||||
"Error": "Invalid URL",
|
||||
})
|
||||
return
|
||||
}
|
||||
@@ -39,21 +39,21 @@ func main() {
|
||||
if lists.ContainsString(lists.RedditDomains, parsed.Host) {
|
||||
// replace domain with discuss.whatever.social
|
||||
parsed.Host = "discuss.whatever.social"
|
||||
}
|
||||
|
||||
if lists.ContainsString(lists.TwitterDomains, parsed.Host) {
|
||||
} else if lists.ContainsString(lists.TwitterDomains, parsed.Host) {
|
||||
// replace domain with read.whatever.social
|
||||
parsed.Host = "read.whatever.social"
|
||||
}
|
||||
|
||||
if lists.ContainsString(lists.YouTubeDomains, parsed.Host) {
|
||||
} else if lists.ContainsString(lists.YouTubeDomains, parsed.Host) {
|
||||
// replace domain with watch.whatever.social
|
||||
parsed.Host = "watch.whatever.social"
|
||||
}
|
||||
|
||||
if lists.ContainsString(lists.StackOverflowDomains, parsed.Host) {
|
||||
} else if lists.ContainsString(lists.StackOverflowDomains, parsed.Host) {
|
||||
// replace domain with code.whatever.social
|
||||
parsed.Host = "code.whatever.social"
|
||||
} else {
|
||||
// send error
|
||||
c.HTML(200, "home.html", gin.H{
|
||||
"Error": "Unsupported domain",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if parsed.Host != originalParsedHost {
|
||||
|
||||
@@ -251,3 +251,17 @@ code {
|
||||
font-size: 0.9rem;
|
||||
font-family: "Fira Code", monospace;
|
||||
}
|
||||
|
||||
.error {
|
||||
width: 100%;
|
||||
background-color: rgb(255, 153, 153);
|
||||
color: black;
|
||||
padding: 0.5rem;
|
||||
box-sizing: border-box;
|
||||
border-radius: 5px;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.error p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
@@ -55,6 +55,11 @@
|
||||
<h1>Launchpad</h1>
|
||||
</div>
|
||||
</a>
|
||||
{{ if .Error }}
|
||||
<div class="error">
|
||||
<p>{{ .Error }}</p>
|
||||
</div>
|
||||
{{ end }}
|
||||
<form action="/">
|
||||
<div class="url-input">
|
||||
<input
|
||||
|
||||
Reference in New Issue
Block a user