This is an automated email from the ASF dual-hosted git repository. dcelasun pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/thrift-website.git
commit 8211eb7c58a6f4a5e260c9d97a656d4dcf2c9a81 Author: Christopher Tubbs <[email protected]> AuthorDate: Thu Oct 29 16:11:39 2020 -0400 Fix plugin bug with opening remote snippets --- _plugins/remote_snippets.rb | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/_plugins/remote_snippets.rb b/_plugins/remote_snippets.rb index a374c72..7fe56bb 100644 --- a/_plugins/remote_snippets.rb +++ b/_plugins/remote_snippets.rb @@ -19,15 +19,6 @@ class RemoteSnippet < Liquid::Tag end end - def openLink(url) - begin - URI.open(url) - rescue OpenURI::HTTPError - $stderr.print "Failed to download #{url}" - raise - end - end - def render(context) title = context.registers[:site].config['title'] prefix = context.registers[:site].config['gitbox_url'] @@ -35,7 +26,7 @@ class RemoteSnippet < Liquid::Tag pretty_url = "#{prefix};a=blob;hb=HEAD;f=#{@path}" content = "" if @range == "all" - openLink(url) {|f| content = f.read } + URI.open(url) {|f| content = f.read } else rangenums = @range.split(",", 2) first = 0 @@ -43,14 +34,13 @@ class RemoteSnippet < Liquid::Tag if rangenums.length() == 2 first = Integer(rangenums[0]) second = Integer(rangenums[1]) - first - openLink(url) {|f| content = f.each_line.drop(first).take(second).join() } + URI.open(url) {|f| content = f.each_line.drop(first).take(second).join() } else first = Integer(rangenums[0]) - openLink(url) {|f| content = f.each_line.drop(first).join() } + URI.open(url) {|f| content = f.each_line.drop(first).join() } end end snippet_type = "snippet" - content = "" if @type == "direct" content = Kramdown::Document.new(content).to_html snippet_type = "page"
