feat: error msgs

This commit is contained in:
httpjamesm
2023-05-24 00:06:00 -04:00
parent d287d7db7e
commit 2a6736bacd
3 changed files with 29 additions and 10 deletions
+10 -10
View File
@@ -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 {
+14
View File
@@ -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;
}
+5
View File
@@ -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