Live data from Hacker News

Show HN: I created a URL shortener that can be entirely hosted on GitHub Pages

github.com

91–100 of 182 posts

Re: Show HN: I created a URL shortener that can be entirely hosted on GitHub Pages

#92

Better be ready for the malicious links. I'm the developer of https://t.ly/ link shortener. I spend most of my time adding in protection to prevent people from using the service for malicious links.

Thank you for the advice! I love that domain though, have always been trying to find a 4 character URL shortener since GoDaddy killed x.co. Will definitely use your service more than I use my own HAHA. That being said, my project is not meant to be seriously used, just kinda a cool hack that is not meant to work forever/work reliably. Appreciate your comments and all the best for your service! You just gained one mor…

Thanks! Your project is really neat. Curious how long github would let it go and if they have a max number of issues. In a short time, T.LY has almost 5 millions short links. I have a lot of users using the shortener from the extension https://t.ly/extension

Re: Show HN: I created a URL shortener that can be entirely hosted on GitHub Pages

#93
post #83

Congrats! I really love this concept for two reasons. First I'm always fascinated by smart solutions that make use of existing free (as in beer) infrastructures to provide a service with open-source software. In this way we truly get FOSS. Second, I really like the idea that the information on where the shortened url redirects to is publicly available. I know that solutions like bitly.com do provide a way to preview…

You raise a point that strikes me as odd, but perhaps I am not up to date on what is considered FOSS nowadays.

In what way will this lead to `truly` FOSS? Sure, the URL shortener project is open-source, but neither Github Pages nor Github Issues are free-as-in-libre open-source projects. What is being show-cased here is a neat idea, but ultimately the dependency on Github's Pages and Issues will make it difficult to port to other systems, thus you are not really free to do with as you please.

So, while the URL shortener program itself is FOSS with all the right licenses, doesn't the direction you are proposing lead to more capture by these non-free platforms, as the value they offer for free-as-in-beer becomes more and more difficult to ignore?

Re: Show HN: I created a URL shortener that can be entirely hosted on GitHub Pages

#94

Not working now... EDIT (After 1 minute): Looks like its working again. Wonder how such a service can go down. Was Github's server failing or DNS?

Probably GitHub's API went down for an instance since I didn't make any new pushes then!

Re: Show HN: I created a URL shortener that can be entirely hosted on GitHub Pages

#95

Neat project. What were your ideas for storing the content in git version history? (i.e as files itself?) Shameless plug for a similar project that i did few years back: A (partial) static site generator based on github issues :) https://github.com/geekodour/gitpushblog

If the links were to be stored in files, I probably would run a GitHub action on every push to statically generate the pages for new links!

Re: Show HN: I created a URL shortener that can be entirely hosted on GitHub Pages

#98

I was always fixated with URL shorteners and always wanted to write one myself. While it would be easy to write one that works with a server, I loved the idea of hosting and running one for free. Thus, I wrote this URL shortener which does not need a backend to work at all. It uses GitHub issues as a "database", and unlike most other URL shorteners that do not need backends, this one doesn't need a # prefixed to the…

> does not need a backend

GitHub issues infrastructure is a backend!

Re: Show HN: I created a URL shortener that can be entirely hosted on GitHub Pages

#99
post #8

You could also push static HTML pages to the git root which have, e.g., https://news.ycombinator.com/ '" /> in the header.

I reckon it'll be possible to "simplify" it even more for an end-user, by making a static site generator generate these redirect HTML files from markdown or a CSV.

I did exactly as you said, about a year or two ago, using Jekyll.

https://gitlab.com/davch/static-redirect

Re: Show HN: I created a URL shortener that can be entirely hosted on GitHub Pages

#100
This is really cool. I think it might even be possible to improve it further so opening an issue isn't even needed.

My thinking is you could store the links and the corresponding shortened URL lookups as an element in the HTML source itself. You would have a submit input on the page. User enters the url they'd like to shorten (or is pulled from a param). The JS reads that value and then looks it up to see if it already exists in the element you created for storage. If not, it creates a hash as the shortened 'link' and adds it to a hashmap / element. Now this is the crucial part: have JS call the Github Actions API to trigger a workflow (https://docs.github.com/en/free-pro-team@latest/rest/referen...) that puts the updated hashmap (which is a payload for a custom parameter you defined for the GH Action) into a file e.g. `links.json` or even outputted directly into the HTML source. Then have the action commit this file back into the repo. Thus, the flat file in the repo acts as the storage mechanism for the links. From a UX standpoint, this is a little smoother and more cohesive (same site to input & redirect) than having to open a GH issue.

With this approach, you can still have the nlsn.cf short domain redirect as long as you pass the URL params and get them in JS from the location, which it looks like you already do. I might try whipping up a version of this tonight. Thanks for the inspiration!

Post reply on HN