navigator
A Rails domain specific language for menu navigation.
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (12.0%) to scientific vocabulary
Keywords
dsl
menu-navigation
Last synced: 6 months ago
·
JSON representation
·
Repository
A Rails domain specific language for menu navigation.
Basic Info
- Host: GitHub
- Owner: bkuhlmann
- License: other
- Language: Ruby
- Default Branch: main
- Homepage: https://alchemists.io/projects/navigator
- Size: 788 KB
Statistics
- Stars: 16
- Watchers: 3
- Forks: 2
- Open Issues: 0
- Releases: 0
Topics
dsl
menu-navigation
Created about 14 years ago
· Last pushed 9 months ago
Metadata Files
Readme
Funding
License
Citation
README.adoc
:toc: macro :toclevels: 5 :figure-caption!: = Navigator ‼️ *This gem is deprecated and will be fully destroyed on 2026-01-15. There is no replacement. Please update accordingly.* ‼️ Navigator is a Rails Engine that provides a domain specific language for menu navigation. Great for situations in which you need dynamic, server-side, rendering of site navigation menus complete with active page highlighting. You can also style your navigation menus with plain CSS or any CSS framework of your choice. toc::[] == Features * Provides a DSL for building navigation menus. * Supports auto-detection/highlighting of active menu items based on current path (customizable for non-path usage too). * Supports sub-menus, nested tags, HTML attributes, etc. * Supports the following HTML tags: ** div ** section ** header ** h1 - h6 ** nav ** ul ** li ** a ** img ** b ** em ** s ** small ** span ** strong ** sub ** sup ** form ** label ** select ** option ** input ** button * Provides `+link+`, `+image+`, and `+item+` convenience methods for succinct ways to build commonly used menu elements. == Requirements . link:https://www.ruby-lang.org[Ruby] . link:https://rubyonrails.org[Ruby on Rails] == Setup To install, run: .... gem install navigator .... Add the following to your Gemfile: .... gem "navigator" .... == Usage The following are examples using the navigation view helper: === Unordered List (simple) Code: [source,ruby] ---- navigation do item "Dashboard", "/dashboard" item "News", "/posts" end ---- Result: [source,html] -------- === Unordered List (with attributes) Code: [source,ruby] ---- navigation "ul", attributes: {class: "nav"} do item "Dashboard", "/dashboard", item_attributes: {class: "active"} item "News", "/posts" end ---- Result: [source,html] ---- ---- === Unordered List (with multiple data attributes) Code: [source,ruby] ---- navigation do item "Home", "/home", item_attributes: {data: {id: 1, type: "public"}} end ---- Result: [source,html] ---- ---- _TIP: Nested data– attributes can be applied to any menu item in the same manner as Rails view helpers._ === Nav (with links) Code: [source,ruby] ---- navigation "nav" do a "Dashboard", attributes: {href: "/dashboard"} a "News", attributes: {href: "/posts"} end ---- Result: [source,html] ---- ---- === Foundation Menu Code: [source,ruby] ---- navigation "nav", attributes: {class: "top-bar", "data-topbar" => nil} do ul attributes: {class: "title-area"} do li attributes: {class: "name"} do h1 do a "Demo", attributes: {href: "/home"} end end end section attributes: {class: "top-bar-section"} do ul attributes: {class: "left"} do item "Home", "/" item "About", "/about" end ul attributes: {class: "right"} do item "v1.0.0", '#' end ul attributes: {class: "right"} do item "Login", "/login", link_attributes: {class: "button tiny round"} end end end ---- Result: [source,html] ---- ---- === Bootstrap Dropdown Code: [source,ruby] ---- navigation "nav" do item "Dashboard", admin_dashboard_path li attributes: {class: "dropdown"} do a "Manage", attributes: {href: "#", class: "dropdown-toggle", "data-toggle" => "dropdown"} do b attributes: {class: "caret"} end ul attributes: {class: "dropdown-menu"} do item "Dashboard", admin_dashboard_path item "Users", admin_users_path end end end ---- Result: [source,html] ---- ---- === Menu Helpers There are several convenience methods, in addition to the standard HTML tags, that can make for shorter lines of code. The following describes each: When building links, the default is: [source,ruby] ---- navigation "nav", activator: activator do a "Home", attributes: {href: home_path} end ---- ...but can be written as: [source,ruby] ---- navigation "nav", activator: activator do link "Home", home_path end ---- When building images, the default is: [source,ruby] ---- navigation "nav", activator: activator do img attributes: {src: "https://placehold.it/50x50", alt: "Example"} end ---- ..but can be written as: [source,ruby] ---- navigation "nav", activator: activator do image "https://placehold.it/50x50", "Example" end ---- When building menu items, the default is: [source,ruby] ---- navigation "nav", activator: activator do li do a "Home", attributes: {href: home_path} end end ---- ...but can be written as: [source,ruby] ---- navigation "nav", activator: activator do item "Home", "/dashboard" end ---- These are just a few, simple, examples of what can be achieved. See the specs for additional usage and customization. === Customization The `+navigation+` view helper can accept an optional `+Navigator::TagActivator+` instance. Code: [source,ruby] ---- activator = Navigator::TagActivator.new search_value: request.env["PATH_INFO"] navigation "nav", activator: activator do link "Home", home_path link "About", about_path end ---- Result: [source,html] ---- ---- This is the default behavior for all navigation menus and is how menu items automatically get the "`active`" class when the item URL (in this case "`/home`") matches the `+request.env[“PATH_INFO"]+` to indicate current page/active tab. `+Navigator::TagActivator+` instances can be configured as follows: * search_key = Optional. The HTML tag attribute to search for. Default: :href. * search_value = Required. The value to match against the search_key value in order to update the value of the target_key. Default: nil. * target_key = Optional. The HTML tag attribute key value to update when the search_value and search_key value match. Default: :class. * target_value = Optional. The value to be applied to the target_key value. If no value exists, then the value is added. Otherwise, if a value exists then the value is appended to the existing value. Default: "`active`". This customization allows for more sophisticated detection/updating of active HTML tags. For example, the example code (above) could be rewritten to use `data` attributes and customized styles. Code: [source,ruby] ---- activator = Navigator::TagActivator.new search_key: "data-id", search_value: "123", target_key: "data-style" target_value: "current" navigation "nav", activator: activator do link "Home", home_path, attributes: {data: {id: "123", data-style="info"}} link "About", about_path attributes: {data: {id: "789"}} end ---- Result: [source,html] ---- ---- Lastly, the search value can be a _regular expression_ to make things easier when dealing with complicated routes, sub- menus, etc. Code: [source,ruby] ---- profile_activator = Navigator::TagActivator.new search_value: /^profile.+/ navigation do item "Dashboard", dashboard_path li activator: profile_activator do link "Profile", '#' ul do item "Addresses", profile_addresses_path item "Emails", profile_emails_path end end end ---- Result: [source,html] ---- ---- Assuming either the `Addresses` or `Emails` menu item was clicked, the `Profile` menu item would be active due to the regular expression (i.e. `/^profile.+/) matching one of the the `profile/` paths. == Development To contribute, run: [source,bash] ---- git clone https://github.com/bkuhlmann/navigator cd navigator bin/setup ---- You can also use the IRB console for direct access to all objects: [source,bash] ---- bin/console ---- == Tests To test, run: [source,bash] ---- bin/rake ---- To test the dummy application, run: [source,bash] ---- cd spec/dummy bin/rails server ---- == link:https://alchemists.io/policies/license[License] == link:https://alchemists.io/policies/security[Security] == link:https://alchemists.io/policies/code_of_conduct[Code of Conduct] == link:https://alchemists.io/policies/contributions[Contributions] == link:https://alchemists.io/policies/developer_certificate_of_origin[Developer Certificate of Origin] == link:https://alchemists.io/projects/navigator/versions[Versions] == link:https://alchemists.io/community[Community] == Credits * Built with link:https://alchemists.io/projects/gemsmith[Gemsmith]. * Engineered by link:https://alchemists.io/team/brooke_kuhlmann[Brooke Kuhlmann].
Owner
- Name: Brooke Kuhlmann
- Login: bkuhlmann
- Kind: user
- Location: Boulder, CO USA
- Company: Alchemists
- Website: https://alchemists.io
- Repositories: 56
- Profile: https://github.com/bkuhlmann
Quality over quantity.
Citation (CITATION.cff)
cff-version: 1.2.0
message: Please use the following metadata when citing this project in your work.
title: Navigator
abstract: A Rails domain specific language for menu navigation.
version: 11.2.1
license: Hippocratic-2.1
date-released: 2025-06-05
authors:
- family-names: Kuhlmann
given-names: Brooke
affiliation: Alchemists
orcid: https://orcid.org/0000-0002-5810-6268
keywords:
- ruby
- engine
- menus
- navigation
repository-code: https://github.com/bkuhlmann/navigator
repository-artifact: https://rubygems.org/gems/navigator
url: https://alchemists.io/projects/navigator
GitHub Events
Total
- Watch event: 1
- Delete event: 140
- Push event: 29
- Create event: 10
Last Year
- Watch event: 1
- Delete event: 140
- Push event: 29
- Create event: 10
Committers
Last synced: about 1 year ago
Top Committers
| Name | Commits | |
|---|---|---|
| Brooke Kuhlmann | b****e@a****o | 621 |
| Brooke Kuhlmann | b****e@r****m | 161 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- rubygems 111,499 total
- Total dependent packages: 0
- Total dependent repositories: 1
- Total versions: 75
- Total maintainers: 1
rubygems.org: navigator
A Rails domain specific language for menu navigation.
- Homepage: https://alchemists.io/projects/navigator
- Documentation: http://www.rubydoc.info/gems/navigator/
- License: Hippocratic-2.1
-
Latest release: 11.2.1
published 9 months ago
Rankings
Downloads: 8.6%
Stargazers count: 14.0%
Forks count: 15.0%
Average: 15.0%
Dependent packages count: 15.8%
Dependent repos count: 21.7%
Maintainers (1)
Funding
- https://github.com/sponsors/bkuhlmann
Last synced:
6 months ago
Dependencies
Gemfile
rubygems
- amazing_print ~> 1.4 development
- caliber ~> 0.11 development
- capybara ~> 3.1 development
- debug ~> 1.6 development
- git-lint ~> 4.0 development
- guard-rspec ~> 4.7 development
- pg ~> 1.2 development
- rake ~> 13.0 development
- reek ~> 6.1 development
- rspec-rails ~> 5.0 development
- simplecov ~> 0.21 development
navigator.gemspec
rubygems
- rails ~> 7.0
- refinements ~> 9.6