GNU General Public License v3.0

项目介绍

nelsontky/gh-pages-url-shortener 是一个托管在 GitHub 上的开源项目,主要使用 HTML 编写,采用 GNU General Public License v3.0 许可证,目前获得 1.4k 个 Star、530 次 Fork。

仓库全名
nelsontky/gh-pages-url-shortener
开源许可证
GNU General Public License v3.0
Star 数
1.4k
Fork 数
530
未关闭 Issue
12

README 摘要

🔗 GitHub Pages URL Shortener This is a minimal URL shortener that can be entirely hosted on GitHub pages. It does not need the maintenance of any servers or databases and can be hosted entirely on GitHub for free! Yay! We got to the top of HN! And on GitHub trending! 👨‍🏫 Demo 1. ccb.wtf/1 should link to this repo. 1. To add a new short link, add an issue with the title being the link you want to shorten…

完整内容见 GitHub 原始 README 或本页 。

常见问题

gh-pages-url-shortener 用什么语言开发?

主要使用 HTML 编写,采用 GNU General Public License v3.0 许可证,目前有 1.4k 个 Star。

gh-pages-url-shortener 可以免费商用吗?

仓库标注的许可证为 GNU General Public License v3.0,商用前请先阅读仓库 LICENSE 文件确认授权范围。

如何获取 gh-pages-url-shortener 的源码?

可以直接克隆仓库:git clone https://github.com/nelsontky/gh-pages-url-shortener.git,默认分支为 main;安装与运行步骤见仓库 README。

gh-pages-url-shortener 最近还在维护吗?

仓库最近一次更新为 2024年6月26日,当前有 12 个未关闭 Issue;Star 数为 1.4k,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

Minimal URL shortener that can be entirely hosted on GitHub pages.

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

语言占比

HTML

README

License: GPL v3 GitHub stars

🔗 GitHub Pages URL Shortener

This is a minimal URL shortener that can be entirely hosted on GitHub pages. It does not need the maintenance of any servers or databases and can be hosted entirely on GitHub for free!

Yay! We got to the top of HN!

Top of HN

And on GitHub trending!

GitHub Trending

👨‍🏫 Demo

  1. ccb.wtf/1 should link to this repo.

  2. To add a new short link, add an issue with the title being the link you want to shorten (including the http(s)://) to https://github.com/nelsontky/gh-pages-url-shortener-db/issues.

  3. The newly created short url can be accessed via ccb.wtf/{issue_number}

☕️ Features

  1. Unlike many URL shorteners, this one does not need a database uses a “database” in the form of GitHub issues and can be entirely hosted on GitHub pages.

  2. There is no need for the pound symbol - short URLs look clean like this: ccb.wtf/1 instead of looking like this: ccb.wtf/#1.

💡 How does this work?

Thanks to @kidGodzilla for the pretty neat explanation here.

  1. 404.html handles all requests
  2. Small javascript snippet fetches a JSON representation of the GitHub issue via the JSON API, and redirects to the issue title, as a URL.
  3. Profit?

😎 This is so cool! How can I use this with my own domain?!

Disclaimer: This method of creating a URL shortener is hacky and not meant to be reliable. Do proceed at your own risk!

  1. Fork the repo before cloning your fork.
  2. Set up GitHub pages for your forked repo.
    1. In your forked repo, click the Settings tab and scroll down to the GitHub Pages section.
    2. Then select the main branch source and click on the Save button.
    3. How to create GitHub page
  3. If you are using your own domain:
    1. Set your domain up for GitHub pages.
    2. Change the URL in CNAME file to your domain.
  4. If you are using GitHub page’s default domain i.e. Something like https://<username>.github.io/<repo-name>/
    1. Delete the CNAME file.
    2. Change var PATH_SEGMENTS_TO_SKIP = 0; at the top of 404.html to var PATH_SEGMENTS_TO_SKIP = 1;.
      1. This is as GitHub domains have an additional path segment (the repo name) after the host name.
  5. Create a new repo as a database. (Or you could use your forked repo)
    1. Update var GITHUB_ISSUES_LINK = "<your-github-issues-link>"; at the top of 404.html accordingly afterwards.
      1. Format for GITHUB_ISSUES_LINK: https://api.github.com/repos/{owner}/{repo}/issues/
      2. Remember the trailing /!
  6. Push your changes to your forked repo, and your low cost and cool as heck URL shortener will be ready for use!

To feature your fork here, edit this section and open a PR!

  • eexit.github.io/s - Created a bash script that allows for shortening of URLs straight on the command line! Check out his script here.
  • gh-short-url - A npm command line tool that uses GitHub pages to convert short URLs.

评论

暂无评论