Project

emenu

0.0
No commit activity in last 3 years
No release in over 3 years
Enterprise class menus with simple ruby based configuration, easy to make, easy to maintain
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.0.0
~> 1.6.4
>= 0
~> 2.3.0

Runtime

~> 3.0.3
~> 3.1.1
 Project Readme

Enterprise Menu¶ ↑

It extracts logic needed for building effective and maintainable menus for complex enterprise scenarios.

Use it if you:

  • have myriad of options to cover

  • have complex business (il)logic that depends on user role

Live example can be tried at emenu.kresimirbojcic.com/cars. Open it in a new tab or otherwise prepare to click ‘Back’ quite a few times.

It renders menu based on configuration and persists state with minimal session info and some tiny jQuery posts. Main goal is to hide as much as possible of the HTML/jQuery ugliness from your tender eyes. Evenly important, at least for me, is to make you balls-of-brass-kind-of-guy when customer is asking for yet another exception/addition in menu layout.

menu.item :transportation do
  item :cars, cars_path
  item :trains do
    item :fast_trains , fast_trains_path
    item :slow_trains, slow_trains_path
  end
  item :planes do
    item :boeing do
      item :boeing747 do
        item :older_ready_to_crash, older_ready_to_crash_path
        item :brand_new, brand_new_path
      end
      item :boeing474, boeing474_path
    end
    item :airbus, airbus_path
  end
end
#second menu group named Orders
menu.item :orders do
  item :bread, bread_path
  item :butter, butter_path
  item :chunky_bacon, chunky_bacon_path
end

end

Supported¶ ↑

  • Unlimited menu levels

  • Separate sets of menu for different roles

  • Exclusion of menu items based on authorisation

WARNING: This is release early as it gets so many things are missing. I am planing on releasing often to make this gem worthwhile your time.

Usage¶ ↑

Put in your Gemfile:

gem 'emenu'

Then type in your console:

bundle && rails g emenu:install

If you are using Haml, put this in layout:

= stylesheet_link_tag 'reset.css', 'emenu.css'
= javascript_include_tag 'jquery-1.4.2.min.js', 'emenu.js'
...
#content
 #left
   =menu_will_render

Otherwise put this in you layout:

<%= stylesheet_link_tag 'reset.css', 'emenu.css'%>
<%= javascript_include_tag 'jquery-1.4.2.min.js', 'emenu.js' %>
...
<div id="content">
  <div id="left">
    <%= menu_will_render %>
  </div>
</div>

Add app/navigation to your autoload paths:

config.autoload_paths += %W(#{config.root}/app/navigation)

Set up menu configuration in app/navigation/navigation.rb and you are ready to go.

Gotchas¶ ↑

Theme used is small part of themeforest.net/item/smooth-admin/101529. It’s just for demonstration and if you plan to use it in your projects you’ll have to pay for it. Since you can already steel it from original theme page I don’t think I am doing anything wrong including it as a demo. On the other hand the author has not given me permission to do so(yet). All in all it might get a bit uglier if I have to make my own theme…

Be aware that I’ve monkey patched String class with ‘indent’ method for my testing purposes.

TODO¶ ↑

  • Add quick links support that change according to main menu selection

  • Put authorisation hook that will enable complex authorisation rules for all menu items in one method

Contributing to emenu¶ ↑

  • Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet

  • Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it

  • Fork the project

  • Start a feature/bugfix branch

  • Commit and push until you are happy with your contribution

  • Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright © 2011 Kresimir Bojcic. See LICENSE.txt for further details.