This commit is contained in:
Alexandre Perrin 2013-10-07 09:39:05 +02:00
commit 9225798c0b
3 changed files with 29 additions and 11 deletions

View File

@ -9,7 +9,8 @@
<p class="meta">
{% include post/date.html %}{{ time }}
{% if site.disqus_short_name and page.comments != false and post.comments != false and site.disqus_show_comment_count == true %}
| <a href="{% if index %}{{ root_url }}{{ post.url }}{% endif %}#disqus_thread">Comments</a>
| <a href="{% if index %}{{ root_url }}{{ post.url }}{% endif %}#disqus_thread"
data-disqus-identifier="{% if post.meta.disqus_id %}{{ post.meta.disqus_id }}{% else %}{{ site.url }}{{ post.url }}{% endif %}">Comments</a>
{% endif %}
</p>
{% endunless %}

View File

@ -14,7 +14,7 @@
{% endif %}
(function () {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/' + disqus_script;
dsq.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + disqus_shortname + '.disqus.com/' + disqus_script;
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
}());
</script>

View File

@ -46,7 +46,7 @@ module Jekyll
end
def get_gist_url_for(gist, file)
"https://raw.github.com/gist/#{gist}/#{file}"
"https://gist.github.com/raw/#{gist}/#{file}"
end
def cache(gist, file, data)
@ -71,8 +71,31 @@ module Jekyll
end
def get_gist_from_web(gist, file)
gist_url = get_gist_url_for gist, file
raw_uri = URI.parse gist_url
gist_url = get_gist_url_for(gist, file)
data = get_web_content(gist_url)
if data.code.to_i == 302
data = handle_gist_redirecting(data)
end
if data.code.to_i != 200
raise RuntimeError, "Gist replied with #{data.code} for #{gist_url}"
end
cache(gist, file, data.body) unless @cache_disabled
data.body
end
def handle_gist_redirecting(data)
redirected_url = data.header['Location']
if redirected_url.nil? || redirected_url.empty?
raise ArgumentError, "GitHub replied with a 302 but didn't provide a location in the response headers."
end
get_web_content(redirected_url)
end
def get_web_content(url)
raw_uri = URI.parse url
proxy = ENV['http_proxy']
if proxy
proxy_uri = URI.parse(proxy)
@ -84,12 +107,6 @@ module Jekyll
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new raw_uri.request_uri
data = https.request request
if data.code.to_i != 200
raise RuntimeError, "Gist replied with #{data.code} for #{gist_url}"
end
data = data.body
cache gist, file, data unless @cache_disabled
data
end
end