Skip to content

Instantly share code, notes, and snippets.

@jpmckinney
Created January 22, 2011 19:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jpmckinney/791405 to your computer and use it in GitHub Desktop.
Save jpmckinney/791405 to your computer and use it in GitHub Desktop.
Downloads all Disqus source code
# blog post: http://blog.slashpoundbang.com/post/2592867566/disqus-the-missing-manual
require 'net/http'
require 'open-uri'
# The list of files to download
files = {
# used in production
'build' => {
# Disqus translations
'lang' => [
'ar',
'af',
'bg',
'zh',
'zh_HANT',
'cs',
'da',
'nl',
'et',
'fr',
'de_formal',
'de_inf',
'el',
'hu',
'he',
'it',
'is',
'id',
'ja',
'ko',
'lv',
'lb',
'lt',
'nb',
'pl',
'pt_BR',
'pt_EU',
'ro',
'ru',
'sk',
'sl',
'es_AR',
'es_MX',
'es_ES',
'sv_SE',
'tr',
'th',
'uk',
'vi',
'fi',
'ms',
'sr_CYRL',
'sr_LATIN',
],
# names are minified: see below
'system' => [
'loader',
'defaults',
# disqus.js and dqs.js are the current API
'disqus',
'dsq', # used if Facebook Like arguments appears in query string
# disqus.newframes.js and dsq.newframes.js are the legacy API
'disqus.newframes',
'dsq.newframes', # used if Facebook Like arguments appears in query string
],
},
# used in testing: these are concatenated to create disqus.js and dsq.js above
'javascript' => {
# names aren't minified
'embed' => {
# current API
'dtpl' => [
'loader',
'dtpl',
'utils',
'sandbox',
'tooltip',
'api',
'ui',
'compat',
],
# legacy API
'newframes' => [
'dtpl',
'utils',
'sandbox',
'newframes',
'parentmessenger',
'jsonrpc',
'fragmentpacket',
'postmessagepacket',
'tooltip',
'api',
'ui',
],
},
},
'js' => {
'dist' => [
'commentbox',
'lib',
],
'src' => [
'json', {
'lib' => [
'easyxdm',
'stacktrace',
],
},
],
},
# client files
'uploads' => {
# custom themes
'themes' => [
'custom_cnn',
't_c9f0f895fb98ab9159f51fd0297e236d',
],
},
}
# Traverses the list of files
def traverse(files, parts)
files.each do |k,v|
base = parts + [k]
if v.is_a? Array
v.each do |w|
if w.is_a? String
path = (base + [w]).join('/') + '.js'
`curl -s --create-dirs -o #{File.expand_path('../disqus/' + path, __FILE__)} #{'http://mediacdn.disqus.com/' + path}`
elsif w.is_a? Hash
traverse w, base
end
end
elsif v.is_a? Hash
traverse v, base
end
end
end
# Gets the current release's UNIX timestamp, e.g.
# 1289172589 = 2010-11-07 23:29:49 UTC
# 1290216453 = 2010-11-20 01:27:33 UTC
# 1290563000 = 2010-11-24 01:43:20 UTC
# 1291775874 = 2010-12-08 02:37:54 UTC
# 1292627651 = 2010-12-17 23:14:11 UTC
# 1293147696 = 2010-12-23 23:41:36 UTC
# 1293675352 = 2010-12-30 02:15:52 UTC
# 1294082394 = 2011-01-03 19:19:54 UTC
# 1294180938 = 2011-01-04 22:42:18 UTC
# 1294184022 = 2011-01-04 23:33:42 UTC
# 1294857368 = 2011-01-12 18:36:08 UTC
def timestamp
Net::HTTP.start('cnn.disqus.com', 80) do |http|
return http.head('/embed.js').response['location'][/\d+/]
end
end
# Can take a UNIX timestamp as an argument
traverse files, [ARGV[0] || timestamp]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment