Method: Dolt::ControllerActions#blob

Defined in:
lib/libdolt/controller_actions.rb

#blob(repo, ref, path, custom_data = {}, options = { :template => :blob }) ⇒ Object



99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/libdolt/controller_actions.rb', line 99

def blob(repo, ref, path, custom_data = {}, options = { :template => :blob })
  if oid = lookup_ref_oid(repo, ref)
    return redirect(router.blob_url(repo, oid, path), 307)
  end

  data = (custom_data || {}).merge(lookup.blob(repo, u(ref), path))
  blob = data[:blob]
  return redirect(router.tree_url(repo, ref, path)) if blob.class.to_s !~ /\bBlob/

  tpl_options = options[:template_options] || {}
  [200, headers(options.merge(:ref => ref)), [
      renderer.render(options[:template], data, tpl_options)
    ]]
end