class Markdownplus::Webshots::WebshotsHandler

Public Class Methods

webshot() click to toggle source
# File lib/markdownplus/webshots.rb, line 30
def self.webshot
  @@webshot ||= Webshot::Screenshot.instance
end

Public Instance Methods

execute(input, parameters, variables, warnings, errors) click to toggle source
# File lib/markdownplus/webshots.rb, line 10
def execute(input, parameters, variables, warnings, errors)
  output = nil
  warnings << "Webshots handler ignores input" if(input!=nil && !input.strip.empty?)
  if parameters==nil
    errors << "No url given"
  elsif parameters.count == 0
    errors << "No url given"
  else
    url = parameters.first
    filename = "#{UUID.generate}.png"
    begin
      WebshotsHandler.webshot.capture url, filename
      output = "![#{url}](#{filename})"
    rescue => e
      errors << "Error opening [#{url}] [#{filename}] [#{e.message}]"
    end
  end
  output
end