Module: Card::Set::Type::Image::HtmlFormat

Extended by:
AbstractFormat
Includes:
File::HtmlFormat
Defined in:
tmpsets/set/mod019-carrierwave/type/image.rb

Instance Method Summary collapse

Methods included from File::HtmlFormat

#cached_upload_card_name, #file_chooser_action_text, #humanized_attachment_name, #preview_editor_delete_text

Instance Method Details

#content_changes(action, diff_type, hide_diff = false) ⇒ Object



126
127
128
129
# File 'tmpsets/set/mod019-carrierwave/type/image.rb', line 126

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

#invalid_image(source) ⇒ Object



105
106
107
108
# File 'tmpsets/set/mod019-carrierwave/type/image.rb', line 105

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

#new_image(action) ⇒ Object



139
140
141
142
143
# File 'tmpsets/set/mod019-carrierwave/type/image.rb', line 139

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

#old_image(action, hide_diff) ⇒ Object



131
132
133
134
135
136
137
# File 'tmpsets/set/mod019-carrierwave/type/image.rb', line 131

def old_image action, hide_diff
  return if hide_diff || !action
  return unless (last_change = card.last_change_on(:db_content, before: action))
  card.with_selected_action_id last_change.card_action_id do
    Card::Content::Diff.render_deleted_chunk _render_core
  end
end

#previewObject



110
111
112
113
114
115
116
# File 'tmpsets/set/mod019-carrierwave/type/image.rb', line 110

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

#show_action_content_toggle?(_action, _view_type) ⇒ Boolean

Returns:

  • (Boolean)


118
119
120
# File 'tmpsets/set/mod019-carrierwave/type/image.rb', line 118

def show_action_content_toggle? _action, _view_type
  true
end

#with_valid_sourceObject



87
88
89
90
91
92
93
94
95
96
97
# File 'tmpsets/set/mod019-carrierwave/type/image.rb', line 87

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