Commit Graph
20 Commits
Author SHA1 Message Date
Will Norris 41c8dbe5b1 cmd/golink: refactor storage logic into db.go
This is a straight refactor with no functional changes. All file access
is captured in the FileDB type. The DB interface is not strictly
necessary here since we only have a single implementation, but helped to
keep the API clean, which will be useful in a future sqlite migration.

Change-Id: I9b86db3040e2618a4ffef237369288ccfc10bc1e
2022-06-10 10:11:11 -07:00
Will Norris 7f69882100 cmd/golink: fix scaling on mobile
apparently also pickup some stray tailwind changes

Change-Id: I8bf5ba4b4f6d185edf45f6c85f9d7cae3637de76
2022-06-09 09:46:37 -07:00
Will Norris 5f349bb6d2 cmd/golink: add styling using tailwind
Change-Id: I301e1d6a9b38de3762c1e9e92c1fff6ccd873afd
2022-06-08 09:16:45 -07:00
Will Norris 259ce77cdc cmd/golink: move home template into separate file
This sets up an embed.FS even though we only have the one file right
now, as we will have more shortly.

Change-Id: I1292e4c00602fbfc3a7bc2a5f93a8c9b9e6715c0
2022-06-07 13:49:29 -07:00
Brad FitzpatrickandWill Norris 7f2e1430f8 cmd/golink: set funcmap in save path too
Otherwise we can't save a link using the funcs.

Change-Id: If48e1527f5b21f0314d3e1b4c3c38b9ca7fa65b8
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-06-07 08:14:35 -07:00
Will Norris 47351686f5 cmd/golink: expose PathEscape and QueryEscape funcs
Change-Id: I045d414fdbe265076a76ef6f652196761df3bb2c
2022-06-06 15:45:16 -07:00
Will Norris 4f58c2b81c cmd/golink: add support for templates in long URLs
long URLs are now executed using text/template to allow for more advaned
handling.  Templates have access to PathEscape and QueryEscape funcs, as
well as a data struct containing the current time (Now) and the
remaining path from the user-provided short link (Path).

Change-Id: Iedbbafccf98c4a623d06e9519877c7137ca559e8
2022-06-03 16:47:00 -07:00
Maisem AliandWill Norris 6715af7ee0 cmd/{golink,who,flycdn}: configure cmd using mkctr
Change-Id: I18c53e217be1f1342617e0ba20c2bcd3488fd263
Signed-off-by: Maisem Ali <maisem@tailscale.com>
2022-06-04 01:10:26 +05:00
Will Norris 28227f8267 golink: add validation of short names
Change-Id: Ic288d699e50dcd5367ee163225be37f044e7ef12
2022-06-03 11:09:19 -07:00
Will Norris 7460caa6de golink: ignore hyphens and allow changing name
- ignore hyphens, preventing link ambiguity. If hyphens are included
  when creating the link, they are saved as the "canonical" name for
  the link, but links are still resolved without them.

- allow overwriting the "canonical" name for a short link by simply
  recreating it with the new canonical name. Stats are not updated when
  the canonical name is updated, which is probably fine.

Change-Id: Ia962caa846489850784ef15cdfad7f13bafd8842
2022-06-03 10:56:01 -07:00
Brad FitzpatrickandWill Norris befe7feef2 cmd/{golink,who}: only build amd64 for fly
Change-Id: I436ed82d9977e72a3e0a601bf5d9790f3c209005
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-06-03 10:13:19 -07:00
David CrawshawandWill Norris 06a1697247 cmd/golink: also sort recent clicks by name
Makes the page stable on reload.

Change-Id: Ic991bbd4d2010d138ec55df6ae5cd38e16665ed1
2022-06-03 10:21:17 -07:00
David CrawshawandWill Norris d2ac80a0eb cmd/golink: show recent popular links
Change-Id: I7cc1da65751907e885473a835cbba79b5c2fd4de
2022-06-03 09:28:04 -07:00
Brad FitzpatrickandWill Norris ccce3f8e0a cmd/golink: expand, add tests for URL expansions
Change-Id: Ic91358499c8f5eecfdd70aaf9d67ef58b9a104a8
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-06-02 19:22:51 -07:00
Will NorrisandWill Norris 172ed66cc3 golinks: append remaining path onto destination
allow for links like http://go/who/will to resolve to http://who/will

Change-Id: I79e502eb9d9e874a863c7062b6449197b03cbabc
Signed-off-by: Will Norris <will@tailscale.com>
2022-06-02 15:23:46 -07:00
Brad FitzpatrickandWill Norris f9c85e6b51 cmd/golink: force UTC 2022-06-01 19:19:37 -07:00
Brad FitzpatrickandWill Norris f6ed6a49e7 cmd/golink: run on Fly
And change /export to /_/export.

Updates #nnn

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-06-01 19:15:55 -07:00
Brad FitzpatrickandWill Norris 61fd39d80e cmd/golink: add snapshot, restore support
In the meantime, before sqlite-and-litestream-to-S3, and as a
transition mechanism to move this service to be running on Fly instead
of Brad's dev box, add support for backing up the go/ links to a file
in git, baking it into the binary, and restoring it as needed when the
binary starts up, including in a newly added dev mode.

Change-Id: I8961f720c0f9b29eb7b0b6b1f62bac7ace2d67dc
2022-08-19 11:18:57 -05:00
Brad FitzpatrickandWill Norris 38952e2705 cmd/golink: add /export handler
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-06-01 12:58:23 -07:00
Brad FitzpatrickandWill Norris 3cb4c6cb03 cmd/golink: start of our http://go/ shortlink service
Change-Id: Ica3c73ba4f288baada2960144ebe70727ab12f4c
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-05-31 13:58:41 -07:00