kpumuk commented on code in PR #14:
URL: https://github.com/apache/thrift-website/pull/14#discussion_r3089485342


##########
_plugins/remote_snippets.rb:
##########
@@ -21,44 +22,84 @@ def initialize(tag_name, text, tokens)
 
   def render(context)
     title = context.registers[:site].config['title']
-    prefix = context.registers[:site].config['gitbox_url']
-    url = "#{prefix};a=blob_plain;hb=HEAD;f=#{@path}"
-    pretty_url = "#{prefix};a=blob;hb=HEAD;f=#{@path}"
-    content = ""
-    if @range == "all"
-      URI.open(url) {|f| content = f.read }
-    else
-      rangenums = @range.split(",", 2)
-      first = 0
-      second = 0
-      if rangenums.length() == 2
-        first = Integer(rangenums[0])
-        second = Integer(rangenums[1]) - first
-        URI.open(url) {|f| content = 
f.each_line.drop(first).take(second).join() }
-      else
-        first = Integer(rangenums[0])
-        URI.open(url) {|f| content = f.each_line.drop(first).join() }
-      end
-    end
+    source = snippet_source(context)
+    content = read_content(source[:read_path], source[:local])
     snippet_type = "snippet"
     if @type == "direct"
-      content = Kramdown::Document.new(content).to_html
+      content = render_markdown(content, context)
       snippet_type = "page"
     else
       content = content.force_encoding("utf-8")
       formatter = Rouge::Formatters::HTMLLegacy.new
       lexer = Rouge::Lexer.find_fancy(@type, content)
       content = formatter.format(lexer.lex(content))
     end
+    source_link = "<a 
href=\"#{source[:pretty_url]}\">#{CGI.escapeHTML(@path)}</a>"
     #content = CGI::escapeHTML(content)
     return """
 #{content}
 <p class=\"snippet_footer\">This #{snippet_type} was generated by #{title}'s 
<strong>source tree docs</strong>:
-<a href=\"#{pretty_url}\">#{@path}</a>
+#{source_link}
 </p>
       """
   end
+
+  private
+
+  def snippet_source(context)

Review Comment:
   Revered all unrelated changes, sorry for the noise.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to