Class: Lurker::BasePresenter
- Inherits:
-
Object
- Object
- Lurker::BasePresenter
show all
- Defined in:
- lib/lurker/presenters/base_presenter.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(options = {}) ⇒ BasePresenter
Returns a new instance of BasePresenter.
8
9
10
|
# File 'lib/lurker/presenters/base_presenter.rb', line 8
def initialize(options = {})
@options = options
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
6
7
8
|
# File 'lib/lurker/presenters/base_presenter.rb', line 6
def options
@options
end
|
Instance Method Details
#asset_path(asset) ⇒ Object
24
25
26
|
# File 'lib/lurker/presenters/base_presenter.rb', line 24
def asset_path(asset)
"#{html_directory}/#{assets[asset] || asset}"
end
|
#assets ⇒ Object
20
21
22
|
# File 'lib/lurker/presenters/base_presenter.rb', line 20
def assets
options[:assets] || {}
end
|
#html_directory ⇒ Object
12
13
14
|
# File 'lib/lurker/presenters/base_presenter.rb', line 12
def html_directory
options[:url_base_path] || options[:html_directory] || ""
end
|
#index_path(subdirectory = "") ⇒ Object
28
29
30
31
32
33
34
35
|
# File 'lib/lurker/presenters/base_presenter.rb', line 28
def index_path(subdirectory = "")
html_path = File.join(html_directory, subdirectory)
if options[:static_html]
File.join(html_path, 'index.html')
else
html_path
end
end
|
#markup(content) ⇒ Object
48
49
50
51
52
|
# File 'lib/lurker/presenters/base_presenter.rb', line 48
def markup(content)
return unless content
Lurker.safe_require 'kramdown'
defined?(Kramdown) ? Kramdown::Document.new(content).to_html : content
end
|
#tag_with_anchor(tag, content, anchor_slug = nil) ⇒ Object
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/lurker/presenters/base_presenter.rb', line 37
def tag_with_anchor(tag, content, anchor_slug = nil)
anchor_slug ||= content.downcase.gsub(' ', '_')
<<-EOS
<#{tag} id="#{anchor_slug}">
<a href="##{anchor_slug}" class="anchor">
#{content}
</a>
</#{tag}>
EOS
end
|
#url_base_path ⇒ Object
16
17
18
|
# File 'lib/lurker/presenters/base_presenter.rb', line 16
def url_base_path
options[:url_base_path] || '/'
end
|