Skip to content

Commit

Permalink
fix: rename
Browse files Browse the repository at this point in the history
  • Loading branch information
resslr committed Jan 8, 2025
1 parent d09a7a8 commit d6a78af
Show file tree
Hide file tree
Showing 26 changed files with 90 additions and 90 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM docker.io/golang:latest

WORKDIR shawty
WORKDIR surf

COPY . .

EXPOSE 1234

RUN go mod tidy
RUN go build
CMD ["./shawty"]
CMD ["./surf"]
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Shawty
# Surf

**Shawty** is a URL shortener built using [Golang](https://go.dev),
**Surf** is a URL shortener built using [Golang](https://go.dev),
[Turso](https://turso.tech) and [HTMX](https://htmx.org). It provides a simple
web interface for shortening URLs, tracking their usage, and offering
statistics about shortened URLs.
Expand Down Expand Up @@ -33,8 +33,8 @@ also checks if the URL contains a valid

1. **Clone the repository**:
```bash
git clone https://github.com/wavly/shawty.git
cd shawty
git clone https://github.com/wavly/surf.git
cd surf
```
2. **Set ENV Variables**:

Expand Down Expand Up @@ -86,4 +86,4 @@ We welcome any contributions to this project! For major changes, please open an

## LICENSE

- Shawty is [Licensed](LICENSE) under MIT
- Surf is [Licensed](LICENSE) under MIT
2 changes: 1 addition & 1 deletion asserts/assert.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package asserts
import (
"os"

prettylogger "github.com/wavly/shawty/pretty-logger"
prettylogger "github.com/wavly/surf/pretty-logger"
)

var logger = prettylogger.GetLogger(nil)
Expand Down
6 changes: 3 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"os"

"github.com/joho/godotenv"
"github.com/wavly/shawty/asserts"
. "github.com/wavly/shawty/env"
prettylogger "github.com/wavly/shawty/pretty-logger"
"github.com/wavly/surf/asserts"
. "github.com/wavly/surf/env"
prettylogger "github.com/wavly/surf/pretty-logger"
)

var logger = prettylogger.GetLogger(nil)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/wavly/shawty
module github.com/wavly/surf

go 1.23.1

Expand Down
12 changes: 6 additions & 6 deletions handlers/redirect.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import (
"time"

"github.com/patrickmn/go-cache"
"github.com/wavly/shawty/asserts"
. "github.com/wavly/shawty/cache"
"github.com/wavly/shawty/internal/database"
prettylogger "github.com/wavly/shawty/pretty-logger"
"github.com/wavly/shawty/utils"
"github.com/wavly/shawty/validate"
"github.com/wavly/surf/asserts"
. "github.com/wavly/surf/cache"
"github.com/wavly/surf/internal/database"
prettylogger "github.com/wavly/surf/pretty-logger"
"github.com/wavly/surf/utils"
"github.com/wavly/surf/validate"
)

var Logger = prettylogger.GetLogger(nil)
Expand Down
10 changes: 5 additions & 5 deletions handlers/shawty.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import (
"html/template"
"net/http"

"github.com/wavly/shawty/asserts"
"github.com/wavly/shawty/internal/database"
"github.com/wavly/shawty/utils"
"github.com/wavly/shawty/validate"
"github.com/wavly/surf/asserts"
"github.com/wavly/surf/internal/database"
"github.com/wavly/surf/utils"
"github.com/wavly/surf/validate"
)

type ShortLink struct {
ShortUrl string
}

func Shawty(w http.ResponseWriter, r *http.Request) {
func Surf(w http.ResponseWriter, r *http.Request) {
inputUrl := r.FormValue("url")
Logger.Info("Shorten the URL", "url", inputUrl, "user-agent", r.UserAgent())

Expand Down
8 changes: 4 additions & 4 deletions handlers/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"net/http"

"github.com/mergestat/timediff"
"github.com/wavly/shawty/asserts"
"github.com/wavly/shawty/internal/database"
"github.com/wavly/shawty/utils"
"github.com/wavly/shawty/validate"
"github.com/wavly/surf/asserts"
"github.com/wavly/surf/internal/database"
"github.com/wavly/surf/utils"
"github.com/wavly/surf/validate"
)

type AccessCount struct {
Expand Down
16 changes: 8 additions & 8 deletions handlers/unshort.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
"strings"

"github.com/patrickmn/go-cache"
"github.com/wavly/shawty/asserts"
. "github.com/wavly/shawty/cache"
"github.com/wavly/shawty/internal/database"
"github.com/wavly/shawty/utils"
"github.com/wavly/shawty/validate"
"github.com/wavly/surf/asserts"
. "github.com/wavly/surf/cache"
"github.com/wavly/surf/internal/database"
"github.com/wavly/surf/utils"
"github.com/wavly/surf/validate"
)

func Unshort(w http.ResponseWriter, r *http.Request) {
Expand All @@ -37,8 +37,8 @@ func Unshort(w http.ResponseWriter, r *http.Request) {
}

// Check if domain matches
if parsedUrl.Host != "shawty.wavly.tech" || parsedUrl.Scheme != "https" {
asserts.NoErr(errorTempl.Execute(w, "URL must use 'https://shawty.wavly.tech'"), "Failed to execute template short-link-error.html")
if parsedUrl.Host != "surf.wavly.tech" || parsedUrl.Scheme != "https" {
asserts.NoErr(errorTempl.Execute(w, "URL must use 'https://surf.wavly.tech'"), "Failed to execute template short-link-error.html")
return
}

Expand Down Expand Up @@ -68,7 +68,7 @@ func Unshort(w http.ResponseWriter, r *http.Request) {
if err != nil {
if err == sql.ErrNoRows {
Logger.Warn("url doesn't exists in the database", "code", code, "user-agent", r.UserAgent(), "error", err)
asserts.NoErr(errorTempl.Execute(w, "There is no destination URL for this short URL: "+"shawty.wavly.tech/s/"+code), "Failed to execute template short-link-error.html")
asserts.NoErr(errorTempl.Execute(w, "There is no destination URL for this short URL: "+"surf.wavly.tech/s/"+code), "Failed to execute template short-link-error.html")
return
}

Expand Down
18 changes: 9 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import (
"syscall"
"time"

"github.com/wavly/shawty/asserts"
"github.com/wavly/shawty/config"
"github.com/wavly/shawty/env"
"github.com/wavly/shawty/handlers"
"github.com/wavly/shawty/internal/database"
prettylogger "github.com/wavly/shawty/pretty-logger"
"github.com/wavly/shawty/utils"
"github.com/wavly/shawty/validate"
"github.com/wavly/surf/asserts"
"github.com/wavly/surf/config"
"github.com/wavly/surf/env"
"github.com/wavly/surf/handlers"
"github.com/wavly/surf/internal/database"
prettylogger "github.com/wavly/surf/pretty-logger"
"github.com/wavly/surf/utils"
"github.com/wavly/surf/validate"
)

func main() {
Expand Down Expand Up @@ -84,7 +84,7 @@ func main() {
})

// API route for shortening the URL
router.HandleFunc("POST /shawty", handlers.Shawty)
router.HandleFunc("POST /surf", handlers.Surf)

// API route for unshortening the URL
router.HandleFunc("POST /unshort", handlers.Unshort)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "shawty",
"name": "surf",
"dependencies": {
"tailwindcss": "^3.4.14"
},
Expand Down
2 changes: 1 addition & 1 deletion partial-html/short-link.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="flex flex-col items-center gap-4 text-lg font-mono mb-2 mt-10 text-center">
<div class="flex items-center gap-2">
<a class="underline text-white" href="/s/{{ .ShortUrl }}">shawty/s/{{ .ShortUrl }}</a>
<a class="underline text-white" href="/s/{{ .ShortUrl }}">surf/s/{{ .ShortUrl }}</a>
<button onclick="copyToClipboard(this, '/s/{{ .ShortUrl }}')" class="bg-zinc-700 hover:bg-zinc-600 text-white font-bold py-1 px-3 rounded transition duration-300">
Copy
</button>
Expand Down
2 changes: 1 addition & 1 deletion pretty-logger/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"strconv"
"sync"

"github.com/wavly/shawty/env"
"github.com/wavly/surf/env"
)

const (
Expand Down
18 changes: 9 additions & 9 deletions static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="title" content="Shawty - Tool for shortening long URLs" />
<meta name="title" content="Surf - Tool for shortening long URLs" />
<meta
name="description"
content="Shawty is a tool for shortening long URLs making it easy to share them"
content="Surf is a tool for shortening long URLs making it easy to share them"
/>
<script
src="https://unpkg.com/[email protected]"
integrity="sha384-Y7hw+L/jvKeWIRRkqWYfPcvVxHzVzn5REgzbawhxAuQGwX1XWe70vji+VSeHOThJ"
crossorigin="anonymous"
></script>
<title>Shawty</title>
<title>Surf</title>
<link rel="stylesheet" href="/static/dist.css" />
<style>
a {
Expand All @@ -24,11 +24,11 @@
<body class="bg-[#090909] text-[#ada9a9] min-h-screen flex flex-col items-center px-4 sm:px-6 lg:px-8">
<main class="w-full max-w-4xl mx-auto mt-8">
<h1 class="text-4xl sm:text-5xl text-center text-white font-bold">
Shawty
Surf
</h1>
<p class="text-center text-lg mb-10">
Shawty is a free and
<a class="underline" target="_blank" href="https://github.com/wavly/shawty">open-source</a> tool for
Surf is a free and
<a class="underline" target="_blank" href="https://github.com/wavly/surf">open-source</a> tool for
shortening long URLs
</p>

Expand All @@ -38,7 +38,7 @@ <h2 class="text-2xl sm:text-3xl font-bold text-center mb-6">
</h2>
<form
class="flex flex-col sm:flex-row justify-center gap-4 sm:gap-0 mb-6 relative"
hx-post="/shawty"
hx-post="/surf"
hx-target="#return"
>
<div class="relative">
Expand Down Expand Up @@ -74,7 +74,7 @@ <h2 class="font-bold mb-4 mt-10 text-2xl sm:text-3xl">
Simple and fast URL shortener!
</h2>
<p class="text-lg mb-6">
Shawty allows you to shorten long links from various platforms like
Surf allows you to shorten long links from various platforms like
<a class="underline" target="_blank" href="https://www.instagram.com">Instagram</a>,
<a class="underline" target="_blank" href="https://facebook.com">Facebook</a>,
<a class="underline" target="_blank" href="https://youtube.com">YouTube</a>,
Expand All @@ -96,7 +96,7 @@ <h2 class="font-bold mb-4 mt-10 text-2xl sm:text-3xl">
of hits from your URL with our click counter.
</p>
<footer class="border-t border-white w-full py-3">
<p class="text-center">&copy; shawty.wavly.tech - Tool for shortening long links</p>
<p class="text-center">&copy; surf.wavly.tech - Tool for shortening long links</p>
</footer>
</main>
</body>
Expand Down
12 changes: 6 additions & 6 deletions static/unshort.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="title" content="Shawty - Tool for shortening long URLs" />
<meta name="title" content="Surf - Tool for shortening long URLs" />
<meta
name="description"
content="Shawty is a tool for shortening long URLs making it easy to share them"
content="Surf is a tool for shortening long URLs making it easy to share them"
/>
<script
src="https://unpkg.com/[email protected]"
integrity="sha384-Y7hw+L/jvKeWIRRkqWYfPcvVxHzVzn5REgzbawhxAuQGwX1XWe70vji+VSeHOThJ"
crossorigin="anonymous"
></script>
<title>Shawty</title>
<title>Surf</title>
<link rel="stylesheet" href="/static/dist.css" />
<style>
a {
Expand All @@ -24,11 +24,11 @@
<body class="bg-[#090909] text-[#ada9a9] min-h-screen flex flex-col items-center px-4 sm:px-6 lg:px-8">
<main class="w-full max-w-4xl mx-auto mt-8">
<h1 class="text-4xl sm:text-5xl text-center text-white font-bold">
<a class="no-underline" href="/">Shawty</a>
<a class="no-underline" href="/">Surf</a>
</h1>
<p class="text-center text-lg mb-10">
Shawty is a free and
<a class="underline" target="_blank" href="https://github.com/wavly/shawty">open-source</a> tool for
Surf is a free and
<a class="underline" target="_blank" href="https://github.com/wavly/surf">open-source</a> tool for
shortening long URLs
</p>

Expand Down
6 changes: 3 additions & 3 deletions templs/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="title" content="Shawty - Tool for shortening long URLs">
<meta name="description" content="Shawty is a tool for shortening long URLs making it easy to share them">
<meta name="title" content="Surf - Tool for shortening long URLs">
<meta name="description" content="Surf is a tool for shortening long URLs making it easy to share them">
<script src="https://unpkg.com/[email protected]"
integrity="sha384-Y7hw+L/jvKeWIRRkqWYfPcvVxHzVzn5REgzbawhxAuQGwX1XWe70vji+VSeHOThJ"
crossorigin="anonymous"></script>
<title>Shawty</title>
<title>Surf</title>
<link rel="stylesheet" href="/static/dist.css">
<style>
a {
Expand Down
2 changes: 1 addition & 1 deletion templs/server-error.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="title" content="Internal Server Error">
<meta name="description" content="Shawty is a tool for shortening long URLs making it easy to share them">
<meta name="description" content="Surf is a tool for shortening long URLs making it easy to share them">
<title>Internal Server Error</title>
<link rel="stylesheet" href="/static/dist.css">
</head>
Expand Down
14 changes: 7 additions & 7 deletions templs/stat.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="title" content="Shawty - Tool for shortening long URLs">
<meta name="description" content="Shawty is a tool for shortening long URLs making it easy to share them">
<title>Shawty - URL Statistics</title>
<meta name="title" content="Surf - Tool for shortening long URLs">
<meta name="description" content="Surf is a tool for shortening long URLs making it easy to share them">
<title>Surf - URL Statistics</title>
<link rel="stylesheet" href="/static/dist.css">
</head>
<body class="bg-[#090909] text-[#ada9a9] min-h-screen flex flex-col items-center px-4 sm:px-6 lg:px-8 py-8 mt-8">
<h1 class="text-4xl sm:text-5xl text-center text-white font-bold">
Shawty
Surf
</h1>
<p class="text-center text-lg mb-10">
Shawty is a free and
<a class="underline" target="_blank" href="https://github.com/wavly/shawty">open-source</a> tool for
Surf is a free and
<a class="underline" target="_blank" href="https://github.com/wavly/surf">open-source</a> tool for
shortening long URLs
</p>

<div class="fw-full max-w-4xl flex flex-col gap-3 my-4 mx-auto">
<h2 class="text-2xl sm:text-3xl font-bold font-mono">Total number of clicks</h2>
<p class="text-base sm:text-lg">The number of clicks from the shortened URL that redirected the user to the destination page.</p>
<a class="underline bg-[#292929] font-mono p-2 w-fit rounded-md text-white break-all" href="/s/{{ .ShortUrl }}">shawty/s/{{ .ShortUrl }}</a>
<a class="underline bg-[#292929] font-mono p-2 w-fit rounded-md text-white break-all" href="/s/{{ .ShortUrl }}">surf/s/{{ .ShortUrl }}</a>
<p class="text-base sm:text-lg font-bold flex flex-col sm:flex-row gap-2 sm:gap-3">
<span>Original URL:</span>
<a class="underline font-mono break-all" href="{{ .OriginalUrl }}">{{ .OriginalUrl }}</a>
Expand Down
Loading

0 comments on commit d6a78af

Please sign in to comment.