Module: ApplicationHelper
- Included in:
- ApplicationController, SearchController
- Defined in:
- lib/nexmo_developer/app/helpers/application_helper.rb
Constant Summary collapse
- CONFIG =
{}.freeze
Instance Method Summary collapse
- #active_sidenav_item ⇒ Object
- #canonical_base ⇒ Object
- #canonical_base_from_config ⇒ Object
- #canonical_path ⇒ Object
- #canonical_url ⇒ Object
- #dashboard_cookie(campaign) ⇒ Object
- #search_enabled? ⇒ Boolean
- #set_utm_cookie(name, value) ⇒ Object
- #theme ⇒ Object
Instance Method Details
#active_sidenav_item ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/nexmo_developer/app/helpers/application_helper.rb', line 18 def active_sidenav_item if params[:tutorial_name] url_for(controller: :tutorial, action: :index, product: params[:product] || @sidenav_product, tutorial_name: params[:tutorial_name]) else request.path.chomp("/#{params[:code_language]}") end end |
#canonical_base ⇒ Object
36 37 38 39 40 |
# File 'lib/nexmo_developer/app/helpers/application_helper.rb', line 36 def canonical_base return "https://#{ENV['HEROKU_APP_NAME']}.herokuapp.com" if ENV['HEROKU_APP_NAME'] canonical_base_from_config || request.base_url end |
#canonical_base_from_config ⇒ Object
65 66 67 |
# File 'lib/nexmo_developer/app/helpers/application_helper.rb', line 65 def canonical_base_from_config CONFIG['base_url'] end |
#canonical_path ⇒ Object
26 27 28 |
# File 'lib/nexmo_developer/app/helpers/application_helper.rb', line 26 def canonical_path request.path.chomp("/#{params[:code_language]}") end |
#canonical_url ⇒ Object
30 31 32 33 34 |
# File 'lib/nexmo_developer/app/helpers/application_helper.rb', line 30 def canonical_url return @canonical_url if @canonical_url canonical_path.prepend(canonical_base) end |
#dashboard_cookie(campaign) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/nexmo_developer/app/helpers/application_helper.rb', line 42 def (campaign) # This is the first touch time so we only want to set it if it's not already set ('ft', Time.now.getutc.to_i) unless [:ft] # These are the things we'll be tracking through the customer dashboard ('utm_source', 'developer.nexmo.com') ('utm_medium', 'referral') ('utm_campaign', campaign) # We don't use term or content as it's not paid, but they may have been set by other things # If they were, delete them so our data isn't tainted .delete('utm_term', domain: :all) .delete('utm_content', domain: :all) end |
#search_enabled? ⇒ Boolean
8 9 10 |
# File 'lib/nexmo_developer/app/helpers/application_helper.rb', line 8 def search_enabled? defined?(ALGOLIA_CONFIG) && ENV['ALGOLIA_SEARCH_KEY'] end |
#set_utm_cookie(name, value) ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/nexmo_developer/app/helpers/application_helper.rb', line 57 def (name, value) [name] = { value: value, expires: 1.year.from_now, domain: :all, } end |
#theme ⇒ Object
12 13 14 15 16 |
# File 'lib/nexmo_developer/app/helpers/application_helper.rb', line 12 def theme return unless ENV['THEME'] "theme--#{ENV['THEME']}" end |