Commit 9d7cb7e7 authored by a_luna's avatar a_luna

Fix for markdown viewer

ApplicationController#renderer initialization receives a Warden::Proxy
to avoid Devise errors.
parent c2502887
# frozen_string_literal: true
class SnippetBlobPresenter < BlobPresenter
include Gitlab::Routing
def rich_data
return if blob.binary?
return unless blob.rich_viewer
......@@ -35,22 +33,16 @@ class SnippetBlobPresenter < BlobPresenter
end
def render_rich_partial
renderer.render("projects/blob/viewers/#{blob.rich_viewer.partial_name}",
viewer: blob.rich_viewer,
blob: blob,
blow_raw_path: raw_path)
renderer.render("projects/blob/viewers/_#{blob.rich_viewer.partial_name}",
locals: { viewer: blob.rich_viewer, blob: blob, blob_raw_path: raw_path },
layout: false)
end
def renderer
ActionView::Base.new(build_lookup_context, { snippet: snippet }, ActionController::Base.new).tap do |renderer|
renderer.extend ApplicationController._helpers
renderer.class_eval do
include Rails.application.routes.url_helpers
end
end
proxy = Warden::Proxy.new({}, Warden::Manager.new({})).tap do |i|
i.set_user(current_user, scope: :user)
end
def build_lookup_context
ActionView::Base.build_lookup_context(ActionController::Base.view_paths)
ApplicationController.renderer.new('warden' => proxy)
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment