Class: ExtendController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- ExtendController
- Defined in:
- lib/nexmo_developer/app/controllers/extend_controller.rb
Constant Summary
Constants included from ApplicationHelper
Instance Method Summary collapse
Methods inherited from ApplicationController
#authenticate_admin!, #not_found, #redirect_vonage_domain
Methods included from ApplicationHelper
#active_sidenav_item, #canonical_base, #canonical_base_from_config, #canonical_path, #canonical_url, #dashboard_cookie, #search_enabled?, #set_utm_cookie, #theme
Instance Method Details
#index ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/nexmo_developer/app/controllers/extend_controller.rb', line 4 def index document_paths = Dir.glob("#{Rails.configuration.docs_base_path}/_extend/**/*.md") @extensions = document_paths.map do |document_path| document = File.read(document_path) frontmatter = YAML.safe_load(document) next unless frontmatter['published'] title = frontmatter['title'] description = frontmatter['description'] = frontmatter['tags'] || [] image = frontmatter['image'] || '' route = File.basename(document_path, '.*') { title: title, description: description, tags: , image: image, route: route } end.compact render layout: 'landing' end |
#show ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/nexmo_developer/app/controllers/extend_controller.rb', line 23 def show document_path = "#{Rails.configuration.docs_base_path}/_extend/#{params[:title]}.md" document = File.read(document_path) body = Nexmo::Markdown::Renderer.new.call(document) frontmatter = YAML.safe_load(document) title = frontmatter['title'] description = frontmatter['description'] = frontmatter['tags'] || [] image = frontmatter['image'] || '' cta = frontmatter['cta'] || 'Use This' link = frontmatter['link'] || '' @extension = { title: title, body: body, image: image, description: description, tags: , link: link, cta: cta } render layout: 'page' end |