Add title to CodeOcean pages
This commit is contained in:
@ -1,20 +0,0 @@
|
||||
- if current_user.try(:admin?) or current_user.try(:teacher?)
|
||||
.container
|
||||
ul.breadcrumb
|
||||
- if model = Kernel.const_get(controller_path.classify) rescue nil
|
||||
- object = model.find_by(id: params[:id])
|
||||
- if model.try(:nested_resource?)
|
||||
li.breadcrumb-item = model.model_name.human(count: 2)
|
||||
- if object
|
||||
li.breadcrumb-item = object
|
||||
- else
|
||||
li.breadcrumb-item = link_to_if(policy(model).index?, model.model_name.human(count: 2), send(:"#{model.model_name.collection}_path"))
|
||||
- if object
|
||||
li.breadcrumb-item = link_to_if(policy(object).show?, object, send(:"#{model.model_name.singular}_path", object))
|
||||
li.breadcrumb-item.active
|
||||
- if I18n.translation_present?("shared.#{params[:action]}")
|
||||
= t("shared.#{params[:action]}")
|
||||
- else
|
||||
= t("#{controller_name}.index.#{params[:action]}")
|
||||
- else
|
||||
li.breadcrumb-item.active = t("breadcrumbs.#{controller_name}.#{params[:action]}")
|
32
app/views/application/_breadcrumbs_and_title.html.slim
Normal file
32
app/views/application/_breadcrumbs_and_title.html.slim
Normal file
@ -0,0 +1,32 @@
|
||||
- if model = Kernel.const_get(controller_path.classify) rescue nil
|
||||
- object = model.find_by(id: params[:id])
|
||||
- if model.try(:nested_resource?)
|
||||
- root_element = model.model_name.human(count: 2)
|
||||
- if object
|
||||
- current_element = object
|
||||
- else
|
||||
- root_element = link_to_if(policy(model).index?, model.model_name.human(count: 2), send(:"#{model.model_name.collection}_path"))
|
||||
- if object
|
||||
- current_element = link_to_if(policy(object).show?, object, send(:"#{model.model_name.singular}_path", object))
|
||||
- if I18n.translation_present?("shared.#{params[:action]}")
|
||||
- active_action = t("shared.#{params[:action]}")
|
||||
- else
|
||||
- active_action = t("#{controller_name}.index.#{params[:action]}")
|
||||
- else
|
||||
- active_action = t("breadcrumbs.#{controller_name}.#{params[:action]}")
|
||||
|
||||
|
||||
- title = "#{active_action} - #{application_name}"
|
||||
- content_for :breadcrumbs do
|
||||
- if current_user.try(:admin?) or current_user.try(:teacher?) && !@embed_options[:hide_navbar]
|
||||
.container
|
||||
ul.breadcrumb
|
||||
- if root_element.present?
|
||||
li.breadcrumb-item = root_element
|
||||
- if current_element.present?
|
||||
li.breadcrumb-item = current_element
|
||||
- title = "#{object} - #{title}"
|
||||
- else
|
||||
- title = "#{model.model_name.human(count: 2)} - #{title}"
|
||||
li.breadcrumb-item.active = active_action
|
||||
- content_for :title, title
|
@ -3,7 +3,9 @@ html lang='en'
|
||||
head
|
||||
meta charset='utf8'
|
||||
meta name='viewport' content='width=device-width, initial-scale=1'
|
||||
title = application_name
|
||||
= render('breadcrumbs_and_title')
|
||||
title
|
||||
= yield(:title)
|
||||
link href=asset_path('favicon.png') rel='icon' type='image/png'
|
||||
= action_cable_meta_tag
|
||||
= stylesheet_pack_tag('application', media: 'all', 'data-turbolinks-track': true)
|
||||
@ -49,7 +51,7 @@ html lang='en'
|
||||
= render('session')
|
||||
div data-controller=controller_name
|
||||
= render('flash')
|
||||
= render('breadcrumbs') if (current_user.try(:admin?) or current_user.try(:teacher?)) && !@embed_options[:hide_navbar]
|
||||
= yield(:breadcrumbs)
|
||||
- if (controller_name == "exercises" && action_name == "implement")
|
||||
.container-fluid
|
||||
= yield
|
||||
|
Reference in New Issue
Block a user