Created
August 17, 2012 12:00
-
-
Save takuya/3378320 to your computer and use it in GitHub Desktop.
gistの貼り付けタグのScriptからHTMLにする。 ref: http://qiita.com/items/333e7d9c9b16ab566665
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'openssl' | |
require 'open-uri' | |
require 'rubygems' | |
require 'json' | |
if ARGV.size < 1 || ! (/([0-9]+)/ =~ ARGV[0]) | |
puts "Usage : Gist のIDを指定。" | |
puts "以下のように指定" | |
puts " #{__FILE__} https://gist.github.com/3033059 " | |
puts " #{__FILE__} https://gist.github.com/3033059.js " | |
puts " #{__FILE__} https://gist.github.com/3033059.json " | |
puts " #{__FILE__} 3033059 " | |
exit | |
end | |
id = $1 | |
json = open("https://gist.github.com/#{id}.json").read | |
data = JSON.load json | |
puts '<style>' | |
puts 'div.highlight{ background-color: #FFFFFF !important;}' #はてなダイアリーとかぶるので。 | |
puts open('https://gist.github.com/stylesheets/gist/embed.css').read | |
puts '</style>' | |
puts data["div"] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment