Giter Club home page Giter Club logo

rawgit's Introduction

RawGit

Warning

RawGit is no longer actively developed. You should use jsDelivr instead. If you arrived here via any website other than rawgit.com, that website is not associated with this project and is not maintained by this project's maintainers (even if it uses this code).

This is the source code behind https://rawgit.com/.

Have questions about RawGit? See the FAQ.

Installing

  1. Install Node.js.

  2. Clone this git repo (fork it first if you plan to make changes).

    git clone git://github.com/rgrove/rawgit.git
    
  3. Install dependencies.

    cd rawgit && npm install
    
  4. Start the local server.

    npm start
    
  5. Browse to http://localhost:5000/ and you should see RawGit in action.

Running Tests

npm test

Contributing

Want to fix a bug? If it's something small, just send a pull request. If you want to add a new feature or make significant changes, please get in touch and ask if I'm interested before doing the work.

License

Copyright (c) 2018 Ryan Grove ([email protected]).

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

rawgit's People

Contributors

bgilmer77 avatar brianpeiris avatar carpeliam avatar dependabot[bot] avatar fabiosantoscode avatar fiatjaf avatar holic avatar jaw111 avatar kimshinelove avatar mad-gooze avatar mauvm avatar monsieurdart avatar mzummo avatar pwalsh avatar rgrove avatar tomvangoethem avatar tristancavelier avatar usmanatron avatar williamboman avatar yzgyyang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rawgit's Issues

Update evil.js and use evil.css again

I think you should update evil.js, as it hasn't been updated for some time now. I also think you should use evil.css again instead of your current whole document rotating technique which is not exactly very subtle. Also, for your evil.html you should link to evil.css instead of evil.js which doesn't really do much in that situation.

Allow caching

Please add some cache headers to your responses. If you don't want to make this the default, add a query parameter to allow for caching. But most of the time this is what you really want, so I would make caching the default. Besides, this would ameliorate the load on github.

Add support for private repositories

When I access a private raw file in GitHub, GitHub appends a token to the URL so that one can acess it:

https://raw.githubusercontent.com/...?token=...

When I open rawgit URL I get 404. :-(

It seems token is not used/passed on?

I would need this to be able to add SVG images to the README in a private repository.

Display a raw.github.com health index on the front page

Seems like raw.github.com times out a lot (or maybe they're just throttling us). It'd be cool if rawgithub kept track of timeouts and errors and used this to generate a raw.github.com "health index" that we could display on the front page.

Cache requested resources briefly to reduce requests to raw.github.com

Investigate caching requested resources briefly (perhaps for 5-10 minutes) to avoid making multiple unnecessary requests to raw.github.com and reduce the impact of upstream timeouts.

Perhaps support a ?nocache query string flag to allow a cache bypass in the event that someone wants to test a file they've just updated.

URL Validation

These URLs provide GitHub sign-in or error pages, rather than the standard rawgithub.com 404. There probably needs to be some more validation on what is a valid URL.

  • rawgithub.com/%20/1234/wtf/wtf
  • rawgithub.com/%20/7289012/raw/
  • rawgithub.com/%20/7289012/raw/wtf.html

Please come back!

Can you just blacklist the spammer and restore the service? Or, possibly, whitelist our file?

Is there an ETA for having the service back online? If not, do you have any ideas for alternate solutions for hosting static content? We're using GH pages for almost everything, but they don't serve HTML as the right mimetype for us so we still have to use RGH for one particular file.

This is what we get for using RGH in production! Can't say you didn't warn us.

XHTML files are not served with the proper content type header

For XHTML files the returned content type is text/plain; charset=utf-8 instead of application/xhtml+xml; charset=utf-8.

For example it doesn't work for this file:
https://raw.githubusercontent.com/w3c/csswg-test/master/css-multicol-1/multicol-nested-002.xht

However it works using the CDN URL it works as expected (thought it's not convenient for my particular use case as the resources are cached):
https://cdn.rawgit.com/w3c/csswg-test/master/css-multicol-1/multicol-nested-002.xht

PDF mimetype support

Hi,

thanks for this ingenious service! Can you please add support for PDF?
I think its very simple - just add some lines to conf folder, but it will be easier for you.
Correct mime type is application/pdf. Now I recieve redirect to raw.github.com which downloads with application/octet-stream.

Thanks
Pavel

Redirect images to raw.github.com

raw.github.com seems to serve the correct content types for images, so there's no need to proxy those. Should investigate other non-text filetypes as well.

I get a 404

I wanted to use rawgit for this file: https://github.com/Stuk/jszip/blob/master/dist/jszip.min.js. Clicking on the "Raw" button triggers a download dialog, so I right-clicked > Copy link location. This gave me this URL:

https://github.com/Stuk/jszip/raw/master/dist/jszip.min.js

I assume this is the correct raw URL. Now, when I paste this URL into rawgit, I get this development URL:

https://rawgit.com/Stuk/jszip/raw/master/dist/jszip.min.js

When I try to load this URL in the browser, I get a 404.

Please whitelist kml

Mobile browsers especially benefit from this since the user is not given the option to launch google earth otherwise

Getting a HTTP 301 redirect

When I try to request a JSON-LD file like this:

curl https://rawgit.com/dvh/KentekenAPI/master/context.jsonld -k

I get a HTTP 301 Moved Permanently response redirecting me to the original GitHub raw file URL.
Fetching the original raw file is giving issues with the incorrect Content-Type and Access-Control-Allow-Origin headers, hence why I'm using RawGit in the first place.

Does RawGit only support certain file types (JSON-LD not being among them)?

Bookmarklet

Just a simple bookmarklet to redirect the current repo/file to rawgit.

The usage is quite simple:
Go to any repo where you like to preview a file, and execute the booklet. If the current url is a file, it should open the file directly, otherwise it will ask for a filename.

I've tested it with the following url-usecases:

Ok, enough for now: https://gist.github.com/yckart/5832645

Any thoughts?

add bookmarklet

I didn't see an offering for a quick dev link peek. I'm using this...
๐Ÿ”– javascript:(function(L){L.href=L.href.replace('raw.githubusercontent','rawgit')}(location));

shortlinks

your service is great. but urls like:

https://cdn.rawgit.com/branderxero/44209619ba485e32d7b3/raw/be86b2237efd035b068652b855fc79cef6161cf5/vim-colors.html

are impossible to remember. i'd be wonderful if you offered a shortened url option. e.g.

https://x.rawgit.com/c1v

Support for WOFF2 fonts?

Hello!

Looks like RawGit is not supporting WOFF2 font. It's served with Content-Type:application/octet-stream instead of application/font-woff2.

However WOFF is served correctly with Content-Type:application/font-woff.

gist rawgithub support

I like using gist when filing defects for Selenium, so this would be awesome for simplifying my repro scripts!

If you like the idea but don't have time for it, I'll probably take a shot at it.

404 error: possibly some characters in filename

proxy-path.js causes stream error node v.0.10.28

Fetching a file from github through rawgit running on node version 0.10.28 causes a stream error:

_stream_readable.js:664
    throw new Error('Cannot switch to old mode now.');
          ^
Error: Cannot switch to old mode now.
    at emitDataEvents (_stream_readable.js:664:11)
    at IncomingMessage.Readable.resume (_stream_readable.js:649:3)
    at Object._onImmediate (/opt/nodejs/proxy/rawgit/lib/middleware/proxy-path.js:157:18)
    at processImmediate [as _immediateCallback] (timers.js:309:15)

The streaming API was redesigned for node v.0.10.x [1] and resume() and pause() are not available if the new non-flowing interface is triggered [2]. The error goes away after commenting out incoming.resume(); on line 157 in proxy-path.js:

    // Ensure that the incoming stream is drained once the response is closed.
    // Otherwise we can leak Buffers.
    finished(res, function () {
/*
        incoming.resume();    // causes stream error
*/
    });
}

Is there a side effect of commenting out incoming.resume()?

Change hard-coded domain name

I am running my own copy of RawGit and it's great!

The issue I have is that it still says "rawgit.com" everywhere, and that confuses my users. I know that I can just change it everywhere, but that means I'd have to change it again every time that I pull upstream changes.

I think that the solution is to be able to set variables with the names of the domain and the CDN, to make this easier for myself and others like me.

I can do this in a pull request, but I wanted to hear what you think before I put in the time.

Symbolic links support.

Currently when you open a symbolic link in rawgithub its path is displayed (example).

A 307 redirection would be much nicer.

Support for submodules (also hosted on github)

Files within submodules return 404:
https://rawgithub.com/cben/CodeMirror-MathJax/7bfeedfe99d72b44621ba0851e4c5f4e51452565/CodeMirror/lib/codemirror.css
which is unrurprising because raw.github.com also returns 404:
https://raw.github.com/cben/CodeMirror-MathJax/7bfeedfe99d72b44621ba0851e4c5f4e51452565/CodeMirror/lib/codemirror.css
(here CodeMirror/ dir is a submodule)

But they do work on Github Pages (only one level deep), and rawgithub is handy even for Pages-hosted projects to send sombody a demo from a specific version/branch, so it'd be nice if it followed submodules.

  1. You could use the API similarly to #16 to check if any parent dir is a submodule.
  2. A more efficient solution is just to parse the .gitmodules file e.g.
    https://raw.github.com/cben/CodeMirror-MathJax/7bfeedfe99d72b44621ba0851e4c5f4e51452565/.gitmodules

P.S. Many thanks for creating and running this service ๐Ÿ‘ !

Getting 200 OK for cached resource

Hi,
thanks for this wonderful service!

I'm currently getting 200 OK responses on all my requests, so caching on the client is effectively off. Do you have any ideas why this might be?

eg URL https://cdn.rawgit.com/kriskowal/q/3f62d467cb55efe4e0f53fa880239ab5057990e8/q.js

Request Headers

:host:cdn.rawgit.com
:method:GET
:path:/kriskowal/q/3f62d467cb55efe4e0f53fa880239ab5057990e8/q.js
:scheme:https
:version:HTTP/1.1
accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
accept-encoding:gzip, deflate, sdch
accept-language:en-US,en;q=0.8,de;q=0.6,fr;q=0.4
cache-control:max-age=0
cookie:_ga=GA1.2.547487526.1413531650
user-agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.50 Safari/537.36

Response Headers

access-control-allow-origin:*
cache-control:max-age=315569000
content-encoding:gzip
content-type:application/javascript; charset=utf-8
date:Mon, 23 Mar 2015 16:03:42 GMT
rawgit-cache-status:HIT
server:NetDNA-cache/2.2
status:200 OK
vary:Accept-Encoding
version:HTTP/1.1
x-cache:HIT
x-content-type-options:nosniff
x-robots-tag:none

Thank you!

A.

Font looks horrible on Windows/Chrome

When viewing the site with Chrome on Windows 7, the font you use looks really weird. I guess it's a scaling/anti-aliasing issue.

image

With Chrome on OS X Mountain Lion it looks a lot better but still not perfect.

Any way to update the cached content in cdn.rawgit.com ?

Thx for your great job. I really want to use cdn.rawgit.com which is faster than rawgit.com and saves money for you. but it prevent me to use cdn.rawgit.com that there is no way to flash the old content.

so, is there any way to do this?

Will it be a solution that when rawgit.com/a/b/c is visited, cdn.rawgit.com/a/b/c will be updated ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.