GitLab snippet Web Intents - autofill from text query parameter
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Problem to solve
Currently, there isn't a programmatic way to populate the snippet text area.
Intended users
Intended for Gitter users. We will translate code blocks written in markdown into a GitLab snippet, see https://gitlab.com/gitlab-org/gitter/webapp/issues/2415
Further details
For a related issue/feature, we have a way to preselect the issue template via query parameter, gitlab-foss#26595 (closed)
There is something similar for Twitter which they call Web Intents, https://developer.twitter.com/en/docs/twitter-for-websites/tweet-button/guides/web-intent
For example, when you visit https://twitter.com/intent/tweet?text=myspecialtweet, it will start a draft tweet with myspecialtweet
in place
Proposal
Add ?text=mynewsnippet
query parameter to the new snippet endpoint that will autofill the file text. This doesn't create the snippet, just autofill the text area.
https://gitlab.com/snippets/new?text=mynewsnippet
There is a max length of about 2000 characters for URL's in browsers so we can't support unlimited length snippets but should be sufficient for many cases.
Permissions and Security
You need to be signed in to create a snippet. Currently when you link the new snippet page, it will ask you to sign in first before viewing it. We need to ensure the redirect back keeps the ?text=
parameter and autofills
Documentation
Add documentation to https://docs.gitlab.com/ee/api/snippets.html
Availability & Testing
- Integration test changes
What does success look like, and how can we measure that?
Visit https://gitlab.com/snippets/new?text=mynewsnippet and see the snippet textarea filled will mynewsnippet