Class: Docs::AttributionFilter

Inherits:
Filter
  • Object
show all
Defined in:
lib/docs/filters/core/attribution.rb

Constant Summary

Constants inherited from Filter

Filter::SCHEME_RGX

Instance Method Summary collapse

Methods inherited from Filter

#absolute_url_string?, #at_css, #at_xpath, #base_url, #css, #current_url, #fragment_url_string?, #initial_page?, #parse_html, #relative_url_string?, #root_page?, #root_path, #root_url, #slug, #subpath, #subpath_to, #xpath

Instance Method Details

#attributionObject


8
9
10
# File 'lib/docs/filters/core/attribution.rb', line 8

def attribution
  context[:attribution]
end

#attribution_htmlObject


12
13
14
15
16
17
18
19
20
21
# File 'lib/docs/filters/core/attribution.rb', line 12

def attribution_html
  <<-HTML.strip_heredoc
  <div class="_attribution">
    <p class="_attribution-p">
      #{attribution.strip_heredoc.delete "\n"}<br>
      #{attribution_link}
    </p>
  </div>
  HTML
end

23
24
25
26
27
# File 'lib/docs/filters/core/attribution.rb', line 23

def attribution_link
  unless base_url.host == 'localhost'
    %(<a href="#{current_url}" class="_attribution-link">#{current_url}</a>)
  end
end

#callObject


3
4
5
6
# File 'lib/docs/filters/core/attribution.rb', line 3

def call
  html << attribution_html if attribution
  html
end