Module: Card::Set::All::HtmlContent::HtmlFormat

Extended by:
Card::Set::AbstractFormat
Defined in:
card/tmpsets/set/mod008-card-mod-format/all/html_content.rb,
card/tmpsets/set/mod007-card-mod-format/all/html_content.rb

Instance Method Summary collapse

Instance Method Details

#countObject



172
173
174
# File 'card/tmpsets/set/mod008-card-mod-format/all/html_content.rb', line 172

def count
  @count ||= card.count
end

#current_set_cardObject



120
121
122
123
124
125
# File 'card/tmpsets/set/mod008-card-mod-format/all/html_content.rb', line 120

def current_set_card
  set_name = params[:current_set]
  set_name ||= "#{card.name}+*type" if card.known? && card.type_id == Card::CardtypeID
  set_name ||= "#{card.name}+*self"
  Card.fetch(set_name)
end

#labeled(label, content) ⇒ Object



87
88
89
# File 'card/tmpsets/set/mod008-card-mod-format/all/html_content.rb', line 87

def labeled label, content
  haml :labeled, label: label, content: content
end

#labeled_field(field, item_view = :name, opts = {}) ⇒ Object



91
92
93
94
95
# File 'card/tmpsets/set/mod008-card-mod-format/all/html_content.rb', line 91

def labeled_field field, item_view=:name, opts={}
  opts[:title] ||= Card.fetch_name field
  field_nest field, opts.merge(view: :labeled,
                               items: (opts[:items] || {}).merge(view: item_view))
end

#one_line_contentObject



132
133
134
135
136
137
# File 'card/tmpsets/set/mod008-card-mod-format/all/html_content.rb', line 132

def one_line_content
  # TODO: use a version of Card::Content.smart_truncate
  #       that counts characters instead of clean!
  cleaned = Card::Content.clean! render_core, {}
  cut_with_ellipsis cleaned
end

#prepare_content_slotObject



9
10
11
12
# File 'card/tmpsets/set/mod008-card-mod-format/all/html_content.rb', line 9

def prepare_content_slot
  class_up "card-slot", "d0-card-content"
  voo.hide :menu
end

#raw_one_line_contentObject



127
128
129
130
# File 'card/tmpsets/set/mod008-card-mod-format/all/html_content.rb', line 127

def raw_one_line_content
  cleaned = Card::Content.clean! render_raw, {}
  cut_with_ellipsis cleaned
end

#short_contentObject

LOCALIZE



140
141
142
# File 'card/tmpsets/set/mod008-card-mod-format/all/html_content.rb', line 140

def short_content
  short_content_items || short_content_fields || short_content_from_core
end

#short_content_fieldsObject



149
150
151
152
153
# File 'card/tmpsets/set/mod008-card-mod-format/all/html_content.rb', line 149

def short_content_fields
  with_short_content_fields do |num_fields|
    "#{num_fields} #{'field'.pluralize num_fields}" if num_fields.positive?
  end
end

#short_content_from_coreObject



159
160
161
162
163
164
165
166
167
168
169
170
# File 'card/tmpsets/set/mod008-card-mod-format/all/html_content.rb', line 159

def short_content_from_core
  content = render_core
  if content.blank?
    "empty"
  elsif content.size <= 5
    content
  elsif content.count("\n") < 2
    "#{content.size} characters"
  else
    "#{content.count("\n") + 1} lines"
  end
end

#short_content_itemsObject



144
145
146
147
# File 'card/tmpsets/set/mod008-card-mod-format/all/html_content.rb', line 144

def short_content_items
  return unless card.respond_to? :count
  "#{count} #{'item'.pluralize count}"
end

#toggle_logicObject



116
117
118
# File 'card/tmpsets/set/mod008-card-mod-format/all/html_content.rb', line 116

def toggle_logic
  show_view?(:title_link, :hide) ? voo.show(:icon_toggle) : voo.show(:title_toggle)
end

#view: closedObject



106
107
108
109
110
111
112
113
114
# File 'card/tmpsets/set/mod008-card-mod-format/all/html_content.rb', line 106

view :closed do
  with_nest_mode :compact do
    toggle_logic
    class_up "d0-card-body", "closed-content"
    @content_body = false
    @toggle_mode = :close
    frame
  end
end

#view: contentObject



16
17
18
19
20
21
# File 'card/tmpsets/set/mod008-card-mod-format/all/html_content.rb', line 16

view :content do
  voo.hide :edit_button
  wrap do
    [_render_menu, _render_core, _render_edit_button(edit: :inline)]
  end
end

#view: content_panelObject



60
61
62
63
64
65
66
# File 'card/tmpsets/set/mod008-card-mod-format/all/html_content.rb', line 60

view :content_panel do
  wrap do
    wrap_with :div, class: "card-body" do
      [_render_menu, _render_core]
    end
  end
end

#view: content_with_edit_buttonObject



27
28
29
30
31
# File 'card/tmpsets/set/mod008-card-mod-format/all/html_content.rb', line 27

view :content_with_edit_button do
  wrap do
    [_render_menu, _render_core, _render_edit_button(edit: :inline)]
  end
end

#view: content_with_titleObject



49
50
51
52
53
# File 'card/tmpsets/set/mod008-card-mod-format/all/html_content.rb', line 49

view :content_with_title do
  wrap true, title: card.format(:text).render_core do
    [_render_menu, _render_core]
  end
end

#view: labeledObject



80
81
82
83
84
85
# File 'card/tmpsets/set/mod008-card-mod-format/all/html_content.rb', line 80

view :labeled, unknown: true do
  @content_body = true
  wrap(true, class: "row") do
    labeled(render_title, wrap_body { "#{render_menu}#{render_labeled_content}" })
  end
end

#view: one_line_contentObject



42
43
44
45
# File 'card/tmpsets/set/mod008-card-mod-format/all/html_content.rb', line 42

view :one_line_content, unknown: :mini_unknown,
                        wrap: { div: { class: "text-muted" } } do
  one_line_content
end

#view: openObject



97
98
99
100
101
102
103
104
# File 'card/tmpsets/set/mod008-card-mod-format/all/html_content.rb', line 97

view :open do
  toggle_logic
  @toggle_mode = :open
  @content_body = true
  frame do
    [_render_open_content, render_comment_box(optional: :hide)]
  end
end

#view: raw_one_line_contentObject



37
38
39
40
# File 'card/tmpsets/set/mod008-card-mod-format/all/html_content.rb', line 37

view :raw_one_line_content, unknown: :mini_unknown,
                            wrap: { div: { class: "text-muted" } } do
  raw_one_line_content
end

#view: short_contentObject



33
34
35
# File 'card/tmpsets/set/mod008-card-mod-format/all/html_content.rb', line 33

view :short_content, wrap: { div: { class: "text-muted" } } do
  short_content
end

#view: titledObject



68
69
70
71
72
73
74
75
76
77
78
# File 'card/tmpsets/set/mod008-card-mod-format/all/html_content.rb', line 68

view :titled do
  @content_body = true
  wrap do
    [
      naming { render_header },
      render_flash,
      wrap_body { render_titled_content },
      render_comment_box(optional: :hide)
    ]
  end
end

#with_short_content_fields {|nested_field_names.size| ... } ⇒ Object

Yields:

  • (nested_field_names.size)


155
156
157
# File 'card/tmpsets/set/mod008-card-mod-format/all/html_content.rb', line 155

def with_short_content_fields
  yield nested_field_names.size if voo.structure || card.structure
end