Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Admin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
osuny
Admin
Commits
f9e9a658
Commit
f9e9a658
authored
3 years ago
by
Arnaud Levy
Browse files
Options
Downloads
Patches
Plain Diff
nav
parent
de278407
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/views/application/_nav.html.erb
+1
-0
1 addition, 0 deletions
app/views/application/_nav.html.erb
config/navigation.rb
+7
-77
7 additions, 77 deletions
config/navigation.rb
with
8 additions
and
77 deletions
app/views/application/_nav.html.erb
+
1
−
0
View file @
f9e9a658
...
...
@@ -3,5 +3,6 @@
<a
class=
"navbar-brand"
href=
"/"
>
<%=
render
'logo'
%>
</a>
<%=
render_navigation
%>
</div>
</nav>
This diff is collapsed.
Click to expand it.
config/navigation.rb
+
7
−
77
View file @
f9e9a658
# -*- coding: utf-8 -*-
# Configures your navigation
SimpleNavigation
::
Configuration
.
run
do
|
navigation
|
# Specify a custom renderer if needed.
# The default renderer is SimpleNavigation::Renderer::List which renders HTML lists.
# The renderer can also be specified as option in the render_navigation call.
#navigation.renderer = Your::Custom::Renderer
# Specify the class that will be applied to active navigation items. Defaults to 'selected'
#navigation.selected_class = 'selected'
# Specify the class that will be applied to the current leaf of
# active navigation items. Defaults to 'simple-navigation-active-leaf'
#navigation.active_leaf_class = 'simple-navigation-active-leaf'
# Specify if item keys are added to navigation items as id. Defaults to true
#navigation.autogenerate_item_ids = true
# You can override the default logic that is used to autogenerate the item ids.
# To do this, define a Proc which takes the key of the current item as argument.
# The example below would add a prefix to each key.
#navigation.id_generator = Proc.new {|key| "my-prefix-#{key}"}
# If you need to add custom html around item names, you can define a proc that
# will be called with the name you pass in to the navigation.
# The example below shows how to wrap items spans.
#navigation.name_generator = Proc.new {|name, item| tag.span(name) }
# Specify if the auto highlight feature is turned on (globally, for the whole navigation). Defaults to true
#navigation.auto_highlight = true
# Specifies whether auto highlight should ignore query params and/or anchors when
# comparing the navigation items with the current URL. Defaults to true
#navigation.ignore_query_params_on_auto_highlight = true
#navigation.ignore_anchors_on_auto_highlight = true
# If this option is set to true, all item names will be considered as safe (passed through html_safe). Defaults to false.
#navigation.consider_item_names_as_safe = false
# Define the primary navigation
# navigation.renderer = ::Appstack::SimpleNavigationRenderer
navigation
.
auto_highlight
=
true
navigation
.
highlight_on_subpath
=
true
navigation
.
selected_class
=
'active'
navigation
.
items
do
|
primary
|
# Add an item to the primary navigation. The following params apply:
# key - a symbol which uniquely defines your navigation item in the scope of the primary_navigation
# name - will be displayed in the rendered navigation. This can also be a call to your I18n-framework.
# url - the address that the generated item links to. You can also use url_helpers (named routes, restful routes helper, url_for etc.)
# options - can be used to specify attributes that will be included in the rendered navigation item (e.g. id, class etc.)
# some special options that can be set:
# :html - Specifies html attributes that will be included in the rendered navigation item
# :if - Specifies a proc to call to determine if the item should
# be rendered (e.g. <tt>if: -> { current_user.admin? }</tt>). The
# proc should evaluate to a true or false value and is evaluated in the context of the view.
# :unless - Specifies a proc to call to determine if the item should not
# be rendered (e.g. <tt>unless: -> { current_user.admin? }</tt>). The
# proc should evaluate to a true or false value and is evaluated in the context of the view.
# :method - Specifies the http-method for the generated link - default is :get.
# :highlights_on - if autohighlighting is turned off and/or you want to explicitly specify
# when the item should be highlighted, you can set a regexp which is matched
# against the current URI. You may also use a proc, or the symbol <tt>:subpath</tt>.
#
primary
.
item
:key_1
,
'name'
,
url
,
options
# Add an item which has a sub navigation (same params, but with block)
primary
.
item
:key_2
,
'name'
,
url
,
options
do
|
sub_nav
|
# Add an item to the sub navigation (same params again)
sub_nav
.
item
:key_2_1
,
'name'
,
url
,
options
end
# You can also specify a condition-proc that needs to be fullfilled to display an item.
# Conditions are part of the options. They are evaluated in the context of the views,
# thus you can use all the methods and vars you have available in the views.
primary
.
item
:key_3
,
'Admin'
,
url
,
html:
{
class:
'special'
},
if:
->
{
current_user
.
admin?
}
primary
.
item
:key_4
,
'Account'
,
url
,
unless:
->
{
logged_in?
}
# you can also specify html attributes to attach to this particular level
# works for all levels of the menu
#primary.dom_attributes = {id: 'menu-id', class: 'menu-class'}
# You can turn off auto highlighting for a specific level
#primary.auto_highlight = false
primary
.
item
:home
,
t
(
'extranet.home'
),
root_path
primary
.
item
:years
,
Education
::
AcademicYear
.
model_name
.
human
(
count:
2
),
academic_years_path
primary
.
item
:organizations
,
University
::
Organization
.
model_name
.
human
(
count:
2
),
organizations_path
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment