Class: Plotline::EntryPresenter

Inherits:
BasePresenter show all
Defined in:
app/presenters/plotline/entry_presenter.rb

Instance Method Summary collapse

Methods inherited from BasePresenter

#initialize

Constructor Details

This class inherits a constructor from Plotline::BasePresenter

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Plotline::BasePresenter

Instance Method Details

#body_markdownObject



5
6
7
8
# File 'app/presenters/plotline/entry_presenter.rb', line 5

def body_markdown
  text = parse_custom_markdown(@object.body.to_s)
  RDiscount.new(text, :smart, :footnotes).to_html.html_safe
end

#image_attrs(img) ⇒ Object



31
32
33
34
35
# File 'app/presenters/plotline/entry_presenter.rb', line 31

def image_attrs(img)
  return { data: {} } unless img

  { data: { width: img.width, height: img.height, ratio: img.ratio } }
end

#photoset_item(src:, alt:, attrs:) ⇒ Object



10
11
12
13
14
15
# File 'app/presenters/plotline/entry_presenter.rb', line 10

def photoset_item(src:, alt:, attrs:)
  img = images_hash[src]
  attrs["class"] = "photoset-item " + attrs["class"].to_s

  photoset_item_html(img, src, alt, attrs, image_attrs(img))
end

#photoset_item_html(img, src, alt, attrs, image_attrs) ⇒ Object



17
18
19
20
21
22
# File 'app/presenters/plotline/entry_presenter.rb', line 17

def photoset_item_html(img, src, alt, attrs, image_attrs)
  (:figure, attrs) do
    concat image_tag(src, { alt: alt }.merge(image_attrs))
    concat (:figcaption, alt)
  end
end

#single_image_html(src:, alt:, attrs:) ⇒ Object



24
25
26
27
28
29
# File 'app/presenters/plotline/entry_presenter.rb', line 24

def single_image_html(src:, alt:, attrs:)
  (:figure, attrs) do
    concat image_tag(src, alt: alt)
    concat (:figcaption, alt)
  end
end