mirror of
https://git.swurl.xyz/swirl/link.git
synced 2023-11-08 10:44:52 +02:00
82 lines
2.8 KiB
HTML
82 lines
2.8 KiB
HTML
<!DOCTYPE html>
|
|
<html lang=en>
|
|
<head>
|
|
<title>A Minimal, SQLite-Backed URL Shortener</title>
|
|
<meta charset='utf-8'>
|
|
<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>
|
|
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
|
|
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
|
<meta content='A minimal, SQLite backed URL shortener. Made with Go, Vim, and FreeBSD.' name='description'>
|
|
</head>
|
|
<body style='font-family: monospace; max-width: 80ch;'>
|
|
|
|
<header>
|
|
A Minimal, SQLite-Backed URL Shortener
|
|
</header>
|
|
|
|
<style>
|
|
@media (max-width: 1000px) {
|
|
pre code {
|
|
display: block;
|
|
max-width: 100%%;
|
|
overflow-x: auto;
|
|
-webkit-overflow-scrolling: touch;
|
|
padding: 0 5px 5px 0;
|
|
}
|
|
}
|
|
</style>
|
|
|
|
<pre><code>| Examples:
|
|
|
|
|
| 1. Create a short link to https://duckduckgo.com
|
|
| $ curl -d https://duckduckgo.com %s
|
|
| %s/502fb5543c36014f
|
|
|
|
|
| 2. Deleting a short link
|
|
| $ TMP=$(mktemp)
|
|
| $ # temp file will store header
|
|
| $ LINK=$(curl -sS %s -d https://duckduckgo.com -D $TMP)
|
|
| $ # the link has been successfully created
|
|
| $ DEL=$(cat $TMP | grep -i delete-with | awk '{print$2}'| tr -d '\r')
|
|
| $ # deletion key is stored in 'X-Delete-With' header.
|
|
| $ curl $LINK
|
|
| <a href="https://duckduckgo.com">Permanent Redirect</a>.
|
|
| $ # the link is working as expected
|
|
| $ curl $LINK -X DELETE -d $DEL
|
|
| $ curl $LINK
|
|
| record not found
|
|
| $ # the link has been successfully deleted.</code></pre>
|
|
|
|
<p>
|
|
Please note: this is an example deployment. If you attempt to create a short
|
|
link here you will receive a 401 Unauthorized. If you like the examples above
|
|
and want to use this URL shortener you should self-host an instance. It's easy
|
|
to do (one of the design goals). Below are instructions detailing how.
|
|
<p>
|
|
|
|
<pre><code>| How to self-host:
|
|
|
|
|
| 1. Install dependencies:
|
|
| a. The Go programming language:
|
|
| <a href='https://golang.org/doc/install'>https://golang.org/doc/install</a>
|
|
| b. Git version control.
|
|
| <a href='https://git-scm.com/book/en/v2/Getting-Started-Installing-Git'>https://git-scm.com/book/en/v2/Getting-Started-Installing-Git</a>
|
|
|
|
|
| * On FreeBSD this would be:
|
|
| $ pkg install -y go git
|
|
|
|
|
| 2. Fetch, complile, and execute the source code:
|
|
| $ env GO111MODULE=off go get git.fsh.ee/i/link
|
|
| $ env GO111MODULE=off go run git.fsh.ee/i/link -url https://your.domain.com -port 8080 -db /path/to/sqlite/file -seed secret
|
|
|
|
|
| * The server is now running on localhost at port 8080.
|
|
| * If the SQLite database at this filepath does not exist it will be created.
|
|
| * All logging will be printed to standard error and standard output.</code></pre>
|
|
|
|
<footer style='white-space: pre;'>Source code: <a href='https://fsh.ee/src'>fsh.ee/src</a>
|
|
License: AGPL v3
|
|
Copy: 2021 i@fsh.ee
|
|
Made with: Go, Vim, and FreeBSD
|
|
Unrelated blog: <a href='https://etc.fsh.ee/'>etc.fsh.ee</a>
|
|
</footer>
|