link/index.html

88 lines
3.0 KiB
HTML
Raw Normal View History

2021-04-30 02:28:21 +00:00
<!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 {{.URL}}
| {{.URL}}/502fb5543c36014f
2021-04-30 02:28:21 +00:00
|
| 2. Create a short link with a custom path
| $ curl -d https://duckduckgo.com {{.URL}}/ddg
| {{.URL}}/ddg
|
| 3. Deleting a short link
2021-04-30 02:28:21 +00:00
| $ TMP=$(mktemp)
| $ # temp file will store header
| $ LINK=$(curl -sS {{.URL}} -d https://duckduckgo.com -D $TMP)
2021-04-30 02:28:21 +00:00
| $ # 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
| &lt;a href=&quot;https://duckduckgo.com&quot;&gt;Permanent Redirect&lt;/a&gt;.
| $ # 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>
{{if .Demo}}
2021-04-30 02:28:21 +00:00
<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
2021-04-30 02:28:21 +00:00
| <a href='https://golang.org/doc/install'>https://golang.org/doc/install</a>
| b. Git version control
2021-04-30 02:28:21 +00:00
| <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
2021-04-30 02:28:21 +00:00
| $ 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>
{{end}}
2021-04-30 02:28:21 +00:00
<footer style='white-space: pre;'>Source code: <a href='https://fsh.ee/src'>fsh.ee/src</a>
License: AGPL v3{{if .Copy}}
Copy: {{.Copy}}{{end}}
Made with: Go, Vim, and FreeBSD{{if .Demo}}
Unrelated blog: <a href='https://etc.fsh.ee/'>etc.fsh.ee</a>{{end}}
2021-04-30 02:28:21 +00:00
</footer>