Module: Anecdote
- Defined in:
- lib/anecdote.rb,
lib/anecdote/engine.rb,
lib/anecdote/version.rb,
app/helpers/anecdote/application_helper.rb,
app/controllers/anecdote/application_controller.rb
Defined Under Namespace
Modules: ApplicationHelper Classes: ApplicationController, Engine
Constant Summary collapse
- VERSION =
"0.0.2"
Class Method Summary collapse
-
.init_raconteur ⇒ Object
<div class=“guie-n765ns-intrinsic-embed”> <div class=“inner” style=“padding-bottom: 64.92248062%;”> <img src=“/baymard-articles/category-specific-sorting-01-rei-mock-up-0f0ae156f355de764324aa6aa4b84d3f.jpg” alt=“” /> </div> </div>.
- .markdown_and_parse(content = "") ⇒ Object
- .module_classes(settings) ⇒ Object
- .raconteur ⇒ Object
Class Method Details
.init_raconteur ⇒ Object
<div class=“guie-n765ns-intrinsic-embed”>
<div class="inner" style="padding-bottom: 64.92248062%;">
<img src="/baymard-articles/category-specific-sorting-01-rei-mock-up-0f0ae156f355de764324aa6aa4b84d3f.jpg" alt="" />
</div>
</div>
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/anecdote.rb', line 21 def self.init_raconteur raconteur.settings.setting_quotes = '$' raconteur.processors.register!('graphic', { template: '<div class="{{ klass }}"><div class="inner"><div class="image">{{ image }}</div><div class="caption anecdote-wysicontent-ndj4ab">{{ caption }}</div></div></div>', handler: lambda do |settings| klass = (['anecdote-graphic-dn32ja'] + module_classes(settings)).flatten.join(' ') image = view_context.content_tag(:div, class: 'anecdote-intrinsic-embed-n42ha1') do geo = Paperclip::Geometry.from_file(Rails.root.join('app', 'assets', 'images', settings[:assets_path])) view_context.content_tag(:div, view_context.image_tag(settings[:assets_path], alt: ''), class: 'inner', style: "padding-bottom: #{geo.height / geo.width * 100}%;") end caption = markdown_and_parse(settings[:caption] || "[No caption]") { klass: klass, image: image, caption: caption } end }) raconteur.processors.register!('pull-quote', { handler: lambda do |settings| klass = (['anecdote-pull-quote-sba2ha'] + module_classes(settings)).flatten.join(' ') view_context.content_tag(:div, view_context.content_tag(:div, markdown_and_parse(settings[:text]), class: 'inner'), class: klass) end }) end |
.markdown_and_parse(content = "") ⇒ Object
6 7 8 |
# File 'lib/anecdote.rb', line 6 def self.markdown_and_parse(content="") Kramdown::Document.new( raconteur.parse(content), { input: :GFM } ).to_html.html_safe end |
.module_classes(settings) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/anecdote.rb', line 43 def self.module_classes(settings) klasses = %w(anecdote-module-3ba83n) if settings[:size].present? klasses << case settings[:size] when 'small' then 'v-size-small' when 'medium' then 'v-size-medium' when 'big' then 'v-size-big' when 'full-width' then 'v-size-full-width' end end if settings[:float].present? klasses << case settings[:float] when 'right' then 'v-float-right' when 'left' then 'v-float-left' end end klasses end |
.raconteur ⇒ Object
10 11 12 |
# File 'lib/anecdote.rb', line 10 def self.raconteur @raconteur ||= ::Raconteur.new end |