Skip to content

Commit

Permalink
Avoid SSL verification errors when using open-uri
Browse files Browse the repository at this point in the history
  • Loading branch information
adamlogic committed Nov 26, 2012
1 parent 977d59b commit 3b191c8
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/ghpreview/previewer.rb
Expand Up @@ -14,6 +14,7 @@ def initialize(md_filepath, options = {})
@md_filepath = md_filepath
@md_filename = md_filepath.split('/').last
@md_filedir = md_filepath.split('/').unshift('.').uniq[0..-2].join('/')
@http = HTTPClient.new
generate_template_with_fingerprinted_stylesheet_links

options[:watch] ? listen : open
Expand Down Expand Up @@ -43,15 +44,13 @@ def open

def markdown_to_html
markdown = File.read(@md_filepath)
client = HTTPClient.new
message = client.post API_URI, body: markdown, header: {'Content-Type' => 'text/plain'}
message = @http.post API_URI, body: markdown, header: {'Content-Type' => 'text/plain'}
message.body
end

def generate_template_with_fingerprinted_stylesheet_links
if stale_template?(STYLED_TEMPLATE_FILEPATH)
uri = URI.parse(HOMEPAGE)
stylesheet_links = uri.read.split("\n").select do |line|
stylesheet_links = @http.get(HOMEPAGE).body.split("\n").select do |line|
line =~ /https:.*github.*\.css/
end.join

Expand Down

0 comments on commit 3b191c8

Please sign in to comment.