diff options
author | Parker Moore <parkrmoore@gmail.com> | 2013-10-05 20:52:12 -0400 |
---|---|---|
committer | Parker Moore <parkrmoore@gmail.com> | 2013-10-05 20:52:12 -0400 |
commit | e692d8ea1a242e385bfcbd49e28d8b4fd9392661 (patch) | |
tree | 1229a7b766959683eecc36e8d057a099c2f2a16d | |
parent | 6a7cced3aac70847dd4f47e785a50c134571d6cd (diff) | |
download | my_new_personal_website-e692d8ea1a242e385bfcbd49e28d8b4fd9392661.tar.xz my_new_personal_website-e692d8ea1a242e385bfcbd49e28d8b4fd9392661.zip |
Clean up Gist redirection.
Diffstat (limited to '')
-rw-r--r-- | plugins/gist_tag.rb | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/plugins/gist_tag.rb b/plugins/gist_tag.rb index 62c490d0..f5123cb9 100644 --- a/plugins/gist_tag.rb +++ b/plugins/gist_tag.rb @@ -71,26 +71,24 @@ module Jekyll end def get_gist_from_web(gist, file) - gist_url = get_gist_url_for gist, file - data = get_web_content gist_url - data = handle_gist_redirecting data + 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 - data = data.body - cache gist, file, data unless @cache_disabled - data + + cache(gist, file, data.body) unless @cache_disabled + data.body end def handle_gist_redirecting(data) - if data.code.to_i == 302 - redirected_url = data.header['Location'] - data = get_web_content redirected_url - if data.code.to_i != 200 - raise RuntimeError, "Gist replied with #{data.code} for #{gist_url}" - end - end - data + redirected_url = data.header['Location'] + get_web_content(redirected_url) end def get_web_content(url) |