https://github.com/myterminal/gh-helper
A web helper for fetching raw GitHub content as plain text
https://github.com/myterminal/gh-helper
github
Last synced: 2 months ago
JSON representation
A web helper for fetching raw GitHub content as plain text
- Host: GitHub
- URL: https://github.com/myterminal/gh-helper
- Owner: myTerminal
- License: mit
- Created: 2022-05-02T14:04:50.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-06-06T00:12:07.000Z (about 2 years ago)
- Last Synced: 2026-03-08T04:05:38.217Z (4 months ago)
- Topics: github
- Language: JavaScript
- Homepage:
- Size: 38.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gh-helper
[](https://travis-ci.org/myTerminal/gh-helper)
[](https://codeclimate.com/github/myTerminal/gh-helper)
[](https://www.npmjs.com/package/eslint-config/myterminal)
[](https://coveralls.io/r/myTerminal/gh-helper?branch=master)
[](https://opensource.org/licenses/MIT)
A web helper for fetching raw GitHub content
## Problem
URLs to retrieve raw data from a file hosted under a GitHub repository can get unreasonably long. This project aims to shorten such URLs for easy sharing.
## How to Configure
Configuration for *gh-pages* only contains two keys at this point:
{
"basePath": "myTerminal",
"aliases": {
"/setup": "/dotfiles/master/.setup/bootstrap"
}
}
`basePath` stands for a GitHub username or organization (eg: [https://github.com/myTerminal]()).
`aliases` can contain keys that can help further shorten URLs, so given the above configuration,
/dotfiles/master/.setup/bootstrap
would become
/setup
## How to Use
Clone the repository inside a directory, and simply run `npm start`.
The structure of the project has been designed to work with [team-fluxion/web-host](https://github.com/team-fluxion/web-host), but it can also be run independently.
With the example configuration, a URL as short as
https://[domain].[tld]/setup
could be turned into
https://raw.githubusercontent.com/myTerminal/dotfiles/master/.setup/bootstrap
### Content types
The response type of the data being returned is determined from the file extension in the URL if one is present.
Currently, the system identifies the following file extensions:
1. `.txt` for plain text files
2. `.html` for web pages
So, a URL that looks like `https://[domain].[tld]/[path]/../[file].html` would be retrieved as a web page with content type "text/html", while something like `https://[domain].[tld]/[path]/../[file].html` would be retrieved as a plain text.
Response types can also be specified explicitly, and that can used to override the identified content type if there is one.
So, though a URL that looks like `https://[domain].[tld]/[path]/../[file].html` would otherwise be treated as a web page, appending a `?t=text` would get it as plain text.
https://[domain].[tld]/[path]/../[file].html?t=text
The above is how an overridden content type would look like.