Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SlintPad: implement short URL permalinks #5283

Open
kanashimia opened this issue May 21, 2024 · 1 comment
Open

SlintPad: implement short URL permalinks #5283

kanashimia opened this issue May 21, 2024 · 1 comment
Labels
a:slintpad SlintPad web frontend implementation (mT,bS)

Comments

@kanashimia
Copy link

kanashimia commented May 21, 2024

Current URLs are too large even on trivial files, you can't paste them in quite a lot of places, telegram silently truncates them for example, which means you have to use external URL shorteners. BUT! URLs are so large in fact that a number of URL shorteners break too, imagine!

URLs should contain the key to the entry in the DB instead. That's what rust playground and godbolt do. This is trivial to implement.

Implementation notes:

You would probably want to compress the DB with zstd, also you would need to implement rate limit to prevent API abuse.
To implement rate limit you would need to hash the client IP address and store the date of link generation.

For the DB I suggest using RocksDB, I had great time in using it with Rust, it also supports lz4 and zstd compression for hot/cold data, the downside is that it is harder to administer with CLI tools. You can use any DB that you want, it doesn't matter much. You can store all of the data just as plaintext regular files in the FS tree too, for that ideally you would want something like a compressed btrfs subvolume.

You may also add privacy policy. I suggest copying from godbolt:

Short links
If you choose to share your code using the "Share" dropdown, then the user interface state including the source code is stored. For a "Full" link, this information is encoded into the URL as a URL hash (e.g. https://godbolt.org/#ui_state_and_code). For short URLs, the interface state is stored on Compiler Explorer's servers, and a shortened name uniquely referring to this data is returned. The shortened name comes from a secure hash of the state, and without knowing the name it is infeasible to access the data. Only Compiler Explorer administrators can access this data directly. Obfuscated IP addresses and creation time are stored alongside this data, to enable spam detection. Links of this form look like https://godbolt.org/z/SHORTNAME.

Prior to storing data itself, Compiler Explorer used an external URL shortening service (goo.gl) and the resulting short URL was rewritten as https://godbolt.org/g/SHORTURLPART. The storage for the user experience state in this case remains with the short URL provider, not Compiler Explorer.

@hunger
Copy link
Member

hunger commented May 22, 2024

Right now your code is never seen by the slintpad server. So it can not store it for you. We want to add a way to share data with other users, so we need to add this eventually.

You can share into a github Gist, getting you a shorter URL. That sends the data to github, but needs you to set up an access token.

@hunger hunger added the a:slintpad SlintPad web frontend implementation (mT,bS) label May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:slintpad SlintPad web frontend implementation (mT,bS)
Projects
None yet
Development

No branches or pull requests

2 participants