Sha256: 501a1325cde72f3a4e994ed6b3b60f06158b0aa846ddcbe4ad8a2e5d22f90e10

Contents?: true

Size: 1.96 KB

Versions: 12

Compression:

Stored size: 1.96 KB

Contents

format :html do
  include File::HtmlFormat

  # core HTML image view.
  view :core do
    return card.attachment.read.html_safe if svg?

    with_valid_source do |source|
      image_tag source, alt: card.name
    end
  end

  def with_valid_source
    handle_source do |source|
      if source.blank? || source == "missing"
        # FIXME: these images should be "broken", not "missing"
        invalid_image source
      else
        yield source
        # consider title..
      end
    end
  end

  view :full_width do
    with_valid_source do |source|
      image_tag source, alt: card.name, class: "w-100"
    end
  end

  def invalid_image source
    # ("missing" is the view for "unknown" now, so we shouldn't further confuse things)
    "<!-- invalid image for #{safe_name}; source: #{source} -->"
  end

  def preview
    return if card.new_card? && !card.preliminary_upload?

    wrap_with :div, class: "attachment-preview",
                    id: "#{card.attachment.filename}-preview" do
      _render_core size: :medium
    end
  end

  def show_action_content_toggle? _action, _view_type
    true
  end

  view :content_changes do
    content_changes card.last_action, :expanded
  end

  def content_changes action, diff_type, hide_diff=false
    voo.size = diff_type == :summary ? :icon : :medium
    [old_image(action, hide_diff), new_image(action)].compact.join
  end

  def old_image action, hide_diff
    return if hide_diff || !action

    old_image_change action do |old_action_id|
      card.with_selected_action_id old_action_id do
        Card::Content::Diff.render_deleted_chunk _render_core
      end
    end
  end

  def old_image_change action
    return unless (change = card.last_change_on(:db_content, before: action))

    yield change.card_action_id
  end

  def new_image action
    card.with_selected_action_id action.id do
      Card::Content::Diff.render_added_chunk _render_core
    end
  end

  def goto_autocomplete_icon
    render :core, size: :small
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
card-mod-carrierwave-0.18.1 set/type/image/html_views.rb
card-mod-carrierwave-0.18.0 set/type/image/html_views.rb
card-mod-carrierwave-0.17.0 set/type/image/html_views.rb
card-mod-carrierwave-0.16.0 set/type/image/html_views.rb
card-mod-carrierwave-0.15.6 set/type/image/html_views.rb
card-mod-carrierwave-0.15.5 set/type/image/html_views.rb
card-mod-carrierwave-0.15.4 set/type/image/html_views.rb
card-mod-carrierwave-0.15.3 set/type/image/html_views.rb
card-mod-carrierwave-0.15.2.pre1 set/type/image/html_views.rb
card-mod-carrierwave-0.15.1.1 set/type/image/html_views.rb
card-mod-carrierwave-0.15.1 set/type/image/html_views.rb
card-mod-carrierwave-0.15.0 set/type/image/html_views.rb