Module: Bible270::PlanHelper
- Defined in:
- app/helpers/bible270/plan_helper.rb
Instance Method Summary collapse
- #b270_avatar(reader, size: 34) ⇒ Object
- #b270_avatar_src(reader) ⇒ Object
- #b270_bible_version ⇒ Object
- #b270_custom_footer ⇒ Object
- #b270_day_status_class(reader, day) ⇒ Object
- #b270_favicon_tag ⇒ Object
-
#b270_footer ⇒ Object
The signed-in reader's translation, falling back to the site default for visitors who aren't signed in.
-
#b270_omniauth_path(provider) ⇒ Object
Path that begins the OmniAuth request phase.
- #b270_passage_url(reference, version = nil) ⇒ Object
- #b270_provider_label(provider) ⇒ Object
- #b270_track(track) ⇒ Object
-
#b270_version_tag(version = nil) ⇒ Object
Small grey "(NKJV)" after a reading, so it's clear which translation the link opens in.
Instance Method Details
#b270_avatar(reader, size: 34) ⇒ Object
85 86 87 88 89 90 91 92 93 |
# File 'app/helpers/bible270/plan_helper.rb', line 85 def b270_avatar(reader, size: 34) src = b270_avatar_src(reader) if src image_tag src, class: 'b270-avatar', width: size, height: size, alt: reader.display_name else content_tag :span, reader.initials, class: 'b270-avatar b270-avatar-fallback', style: "width:#{size}px;height:#{size}px;line-height:#{size}px" end end |
#b270_avatar_src(reader) ⇒ Object
79 80 81 82 83 |
# File 'app/helpers/bible270/plan_helper.rb', line 79 def b270_avatar_src(reader) return main_app.rails_blob_path(reader.avatar, only_path: true) if reader.avatar_uploaded? reader.avatar_url.presence end |
#b270_bible_version ⇒ Object
63 64 65 |
# File 'app/helpers/bible270/plan_helper.rb', line 63 def b270_bible_version current_reader&.effective_bible_version || Translations.resolve(nil) end |
#b270_custom_footer ⇒ Object
47 48 49 50 51 52 |
# File 'app/helpers/bible270/plan_helper.rb', line 47 def case Bible270.config. when :partial then render(Bible270.config.) when :html then content_tag(:footer, Bible270.config..html_safe, class: 'b270-footer') end end |
#b270_day_status_class(reader, day) ⇒ Object
95 96 97 98 99 100 101 102 103 |
# File 'app/helpers/bible270/plan_helper.rb', line 95 def b270_day_status_class(reader, day) return '' unless reader case reader.day_status(day) when :complete then 'complete' when :partial then 'partial' else '' end end |
#b270_favicon_tag ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'app/helpers/bible270/plan_helper.rb', line 54 def b270_favicon_tag favicon = Bible270.config.favicon return if favicon == false href = favicon.presence || Favicon.data_uri type = href.start_with?('data:image/svg+xml', 'http') || href.end_with?('.svg') ? 'image/svg+xml' : nil tag.link(rel: 'icon', type: type, href: href) end |
#b270_footer ⇒ Object
The signed-in reader's translation, falling back to the site default for visitors who aren't signed in. Applies to every page the engine's layout renders, i.e. everything under the mount point. Pages rendered inside a host layout need this in that layout's
instead. The footer, from whichever source the host configured. A partial is looked up in the host's view paths as well as the engine's, so 'shared/footer' finds app/views/shared/_footer.html.erb. The footer, from whichever source the host configured. A partial is looked up in the host's view paths as well as the engine's, so 'shared/footer' finds app/views/shared/_footer.html.erb. config.footer_placement decides whether a custom footer replaces the engine's or sits alongside it.
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/helpers/bible270/plan_helper.rb', line 33 def config = Bible270.config return if config. == :none return render('bible270/shared/footer') if config. == :default parts = [] if config. default = render('bible270/shared/footer') config. == :after ? parts.unshift(default) : parts.push(default) end safe_join(parts) end |
#b270_omniauth_path(provider) ⇒ Object
Path that begins the OmniAuth request phase. Must be POSTed to: OmniAuth 2.0+ refuses GET on its own routes (CVE-2015-9284), so every sign-in control in these views is a button_to, not a link_to.
12 13 14 15 |
# File 'app/helpers/bible270/plan_helper.rb', line 12 def b270_omniauth_path(provider) prefix = Bible270.config.omniauth_path_prefix || "#{request.script_name}/auth" "#{prefix}/#{provider}" end |
#b270_passage_url(reference, version = nil) ⇒ Object
67 68 69 70 71 |
# File 'app/helpers/bible270/plan_helper.rb', line 67 def b270_passage_url(reference, version = nil) return '#' if reference.blank? Bible270.config.passage_url_builder.call(reference, version || b270_bible_version) end |
#b270_provider_label(provider) ⇒ Object
17 18 19 |
# File 'app/helpers/bible270/plan_helper.rb', line 17 def b270_provider_label(provider) Bible270.config.label_for_provider(provider) end |
#b270_track(track) ⇒ Object
5 6 7 |
# File 'app/helpers/bible270/plan_helper.rb', line 5 def b270_track(track) Plan::TRACKS.fetch(track.to_s) end |
#b270_version_tag(version = nil) ⇒ Object
Small grey "(NKJV)" after a reading, so it's clear which translation the link opens in.
75 76 77 |
# File 'app/helpers/bible270/plan_helper.rb', line 75 def b270_version_tag(version = nil) content_tag :span, "(#{version || b270_bible_version})", class: 'b270-version' end |