pjhyett (owner)

Revisions

gist: 114994 Download_button fork
public
Description:
Experiment to create a read-only version of GitHub during migrations and what not. Doesn't work because Google throttles hits to their cache to prevent people from doing exactly what this does.
Public Clone URL: git://gist.github.com/114994.git
Embed All Files: show embed
cache-down.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require 'rubygems'
require 'sinatra'
require 'open-uri'
 
def strip_header(text)
  prefix = %{
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<base href="http://github.com/"<div style="width"<!DOCTYPE
}
  text.sub(/.+<!DOCTYPE/m, prefix)
end
 
get '/*' do
  response = open("http://www.google.com/search?q=cache:github.com/#{params[:splat].join('/')}").read
  @output = strip_header(response)
  erb :index
end
 
use_in_file_templates!
 
__END__
 
@@ index
 
<div style="width:98%; font-size:1em; background:#ffffcc; padding:1em; font-weight:bold; border-bottom:1px solid #ccc;">
<span style="font-size:1.2em">You're viewing a read-only version of GitHub.</span><br />
The content may be slightly out of date as we're reading it from Google's cache until we're able to bring the site back up.
</div>
 
<%= @output %>