forked from tailscale/golink
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'tailscale:main' into main
- Loading branch information
Showing
10 changed files
with
79 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,58 @@ | ||
{{ define "main" }} | ||
<article class="prose max-w-5xl"> | ||
<p> | ||
go links provide short, memorable links for the websites you and your team use most. | ||
{{go}} links provide short, memorable links for the websites you and your team use most. | ||
|
||
<h2>Creating go links</h2> | ||
<h2>Creating {{go}} links</h2> | ||
|
||
<p> | ||
All go links have a <strong>short name</strong> and a <strong>destination link</strong> that the go link points to. | ||
All {{go}} links have a <strong>short name</strong> and a <strong>destination link</strong> that the {{go}} link points to. | ||
Some notes on short names: | ||
|
||
<ul> | ||
<li>names must start with a letter or number | ||
<li>names may contain letters, numbers, hyphens, and periods | ||
<li>names are <strong>not</strong> case-sensitive (go/foo is the same as go/FOO) | ||
<li>hyphens are ignored when resolving links (go/meetingnotes is the same as go/meeting-notes) | ||
<li>names are <strong>not</strong> case-sensitive ({{go}}/foo is the same as {{go}}/FOO) | ||
<li>hyphens are ignored when resolving links ({{go}}/meetingnotes is the same as {{go}}/meeting-notes) | ||
</ul> | ||
|
||
<p> | ||
In simple cases, the destination link is an absolute URL, such as <strong>https://www.google.com/</strong>. | ||
|
||
<p> | ||
<img width=737 height=62 class="mx-4" src="/.static/images/create-link.png"> | ||
<!-- example non-functional form --> | ||
<div class="flex flex-wrap mx-4"> | ||
<div class="flex"> | ||
<label class="flex my-2 px-2 items-center bg-gray-100 border border-r-0 border-gray-300 rounded-l-md text-gray-700">http://{{go}}/</label> | ||
<input disabled type=text size=15 value="search" class="p-2 my-2 rounded-r-md border-gray-300"> | ||
<span class="flex m-2 items-center">→</span> | ||
</div> | ||
<input disabled type=text size=30 value="https://www.google.com/" class="p-2 my-2 mr-2 max-w-full rounded-md border-gray-300"> | ||
<button disabled type=submit class="py-2 px-4 my-2 rounded-md bg-blue-500 border-blue-500 text-white hover:bg-blue-600 hover:border-blue-600">Create</button> | ||
</div> | ||
|
||
<h2>Resolving links</h2> | ||
|
||
<p> | ||
When logged in to your Tailscale network, go links can be entered directly into any browser or command line utility such as curl. | ||
When logged in to your Tailscale network, {{go}} links can be entered directly into any browser or command line utility such as curl. | ||
You do not need any additional browser extensions. | ||
|
||
<p> | ||
Any additional path provided after the short name will be added to the end of the destination link. | ||
For example, if <strong>go/who</strong> goes to your company directory at <strong>http://directory/</strong>, | ||
then <strong>go/who/amelie</strong> will go to <strong>http://directory/amelie</strong>. | ||
For example, if <strong>{{go}}/who</strong> goes to your company directory at <strong>http://directory/</strong>, | ||
then <strong>{{go}}/who/amelie</strong> will go to <strong>http://directory/amelie</strong>. | ||
|
||
<p> | ||
<a href="#advanced">Advanced destination links</a> allow you to further customize this behavior. | ||
|
||
<h2 id="advanced">Advanced destination links</h2> | ||
|
||
<p> | ||
To have more control over how go links are resolved, destination links can use <a href="https://pkg.go.dev/text/template">Go template syntax</a>. | ||
To have more control over how {{go}} links are resolved, destination links can use <a href="https://pkg.go.dev/text/template">Go template syntax</a>. | ||
Templates are provided a data structure with the following fields: | ||
|
||
<ul> | ||
<li><code>.Path</code> is the remaining path value after the short name (without a leading slash). | ||
For the link <strong>go/who/amelie</strong>, the value of <code>.Path</code> is <code>amelie</code>. | ||
For the link <strong>{{go}}/who/amelie</strong>, the value of <code>.Path</code> is <code>amelie</code>. | ||
<li><code>.Now</code> is a <a href="https://pkg.go.dev/time#Time">time.Time</a> value representing the current date and time. | ||
<li><code>.User</code> is the current user resolving the link. | ||
This is the email address of the user or <code>{username}@github</code> for tailnets that use GitHub authentication. | ||
|
@@ -61,34 +69,34 @@ <h2 id="advanced">Advanced destination links</h2> | |
|
||
<p> | ||
The most common use of advanced destination links is to put the additional path in a custom location in the destination link. | ||
For example, you might set the destination for <strong>go/search</strong> to: | ||
For example, you might set the destination for <strong>{{go}}/search</strong> to: | ||
|
||
<pre>{{`https://www.google.com/{{if .Path}}search?q={{QueryEscape .Path}}{{end}}`}}</pre> | ||
|
||
When a user visits <strong>go/search</strong> with no additional path, they will be directed to <a href="https://www.google.com/">https://www.google.com/</a>. | ||
If they include an additional path like <strong>go/search/pangolins</strong>, they will be directed to <a href="https://www.google.com/search?q=pangolins">https://www.google.com/search?q=pangolins</a>. | ||
When a user visits <strong>{{go}}/search</strong> with no additional path, they will be directed to <a href="https://www.google.com/">https://www.google.com/</a>. | ||
If they include an additional path like <strong>{{go}}/search/pangolins</strong>, they will be directed to <a href="https://www.google.com/search?q=pangolins">https://www.google.com/search?q=pangolins</a>. | ||
|
||
<h3>Examples</h3> | ||
|
||
<table> | ||
<tr> | ||
<td>Include path in query</td> | ||
<td>go/search</td> | ||
<td>{{go}}/search</td> | ||
<td>{{`https://cloudsearch.google.com/{{if .Path}}cloudsearch/search?q={{QueryEscape .Path}}{{end}}`}}</td> | ||
</tr> | ||
<tr> | ||
<td>Include path in destination path</td> | ||
<td>go/slack</td> | ||
<td>{{go}}/slack</td> | ||
<td>{{`https://company.slack.com/{{if .Path}}channels/{{PathEscape .Path}}{{end}}`}}</td> | ||
</tr> | ||
<tr> | ||
<td>Include path in hostname</td> | ||
<td>go/varz</td> | ||
<td>{{go}}/varz</td> | ||
<td>{{`http://{{if .Path}}{{.Path}}{{else}}host{{end}}.example/debug/varz`}}</td> | ||
</tr> | ||
<tr> | ||
<td>Include today's date in wiki page</td> | ||
<td>go/today</td> | ||
<td>{{go}}/today</td> | ||
<td>{{`http://wiki/{{.Now.Format "01-02-2006"}}`}}</td> | ||
</tr> | ||
</table> | ||
|
@@ -101,8 +109,8 @@ <h2 id="api">Application Programming Interface (API)</h2> | |
<p> | ||
Include a "+" after a link to get information about a link without resolving it: | ||
|
||
<pre>{{`$ curl -L go/search+ | ||
{ | ||
<pre>$ curl -L {{go}}/search+ | ||
{{`{ | ||
"Short": "search", | ||
"Long": "https://cloudsearch.google.com/{{if .Path}}cloudsearch/search?q={{QueryEscape .Path}}{{end}}", | ||
"Created": "2022-06-08T04:27:32.829906577Z", | ||
|
@@ -113,19 +121,19 @@ <h2 id="api">Application Programming Interface (API)</h2> | |
</pre> | ||
|
||
<p> | ||
Visit <a href="/.export">go/.export</a> to export all saved links and their metadata in <a href="https://jsonlines.org/">JSON Lines format</a>. | ||
Visit <a href="/.export">{{go}}/.export</a> to export all saved links and their metadata in <a href="https://jsonlines.org/">JSON Lines format</a>. | ||
This is useful to create data snapshots that can be restored later. | ||
|
||
<pre>{{`$ curl -L go/.export | ||
{"Short":"go","Long":"http://go","Created":"2022-05-31T13:04:44.741457796-07:00","LastEdit":"2022-05-31T13:04:44.741457796-07:00","Owner":"[email protected]","Clicks":1} | ||
<pre>$ curl -L {{go}}/.export | ||
{{`{"Short":"go","Long":"http://go","Created":"2022-05-31T13:04:44.741457796-07:00","LastEdit":"2022-05-31T13:04:44.741457796-07:00","Owner":"[email protected]","Clicks":1} | ||
{"Short":"slack","Long":"https://company.slack.com/{{if .Path}}channels/{{PathEscape .Path}}{{end}}","Created":"2022-06-17T18:05:43.562948451Z","LastEdit":"2022-06-17T18:06:35.811398Z","Owner":"[email protected]","Clicks":4}`}} | ||
</pre> | ||
|
||
<p> | ||
Create a new link by sending a POST request with a <code>short</code> and <code>long</code> value: | ||
|
||
<pre>{{`$ curl -L -H Sec-Golink:1 -d short=cs -d long=https://cs.github.com/ go | ||
{"Short":"cs","Long":"https://cs.github.com/","Created":"2022-06-03T22:15:29.993978392Z","LastEdit":"2022-06-03T22:15:29.993978392Z","Owner":"[email protected]"}`}} | ||
<pre>$ curl -L -H Sec-Golink:1 -d short=cs -d long=https://cs.github.com/ {{go}} | ||
{{`{"Short":"cs","Long":"https://cs.github.com/","Created":"2022-06-03T22:15:29.993978392Z","LastEdit":"2022-06-03T22:15:29.993978392Z","Owner":"[email protected]"}`}} | ||
</pre> | ||
|
||
</article> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/"> | ||
<ShortName>{{.Hostname}}</ShortName> | ||
<ShortName>{{go}}</ShortName> | ||
<Description>Private shortlinks on your tailnet</Description> | ||
<InputEncoding>UTF-8</InputEncoding> | ||
<Image width="16" height="16" type="image/png">http://{{.Hostname}}/.static/favicon.png</Image> | ||
<Url type="text/html" method="get" template="http://{{.Hostname}}/{searchTerms}"/> | ||
<moz:SearchForm>http://{{.Hostname}}/</moz:SearchForm> | ||
<Image width="16" height="16" type="image/png">http://{{go}}/.static/favicon.png</Image> | ||
<Url type="text/html" method="get" template="http://{{go}}/{searchTerms}"/> | ||
<moz:SearchForm>http://{{go}}/</moz:SearchForm> | ||
</OpenSearchDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{{ define "main" }} | ||
<h2 class="text-xl font-bold pb-2">Success</h2> | ||
|
||
<p><a class="text-blue-600 hover:underline" href="/{{.Short}}">go/{{.Short}}</a> has been saved.</p> | ||
<p><a class="text-blue-600 hover:underline" href="/{{.Short}}">{{go}}/{{.Short}}</a> has been saved.</p> | ||
{{ end }} |