From e02a93bda187445c54e0952b592be50a01bd21d2 Mon Sep 17 00:00:00 2001 From: Benjamin ter Kuile Date: Sat, 15 Dec 2012 12:53:03 +0100 Subject: [PATCH] cleaner menu layout, moved into partial --- Gemfile.lock | 19 ----------- app/views/cmtool/application/_menu.html.slim | 32 +++++++++++++++++ .../layouts/cmtool/application.html.slim | 34 +------------------ lib/cmtool/engine.rb | 1 + 4 files changed, 34 insertions(+), 52 deletions(-) create mode 100644 app/views/cmtool/application/_menu.html.slim diff --git a/Gemfile.lock b/Gemfile.lock index 67351c5..4fac080 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -81,12 +81,10 @@ GEM childprocess (0.3.6) ffi (~> 1.0, >= 1.0.6) cocaine (0.4.2) - coderay (1.0.8) coffee-script (2.2.0) coffee-script-source execjs coffee-script-source (1.4.0) - commonjs (0.2.6) couchrest (1.1.3) mime-types (~> 1.15) multi_json (~> 1.0) @@ -125,11 +123,6 @@ GEM railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) json (1.6.7) - less (2.2.2) - commonjs (~> 0.2.6) - less-rails (2.2.6) - actionpack (>= 3.1) - less (~> 2.2.0) libwebsocket (0.1.7.1) addressable websocket @@ -137,7 +130,6 @@ GEM i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) - method_source (0.8.1) mime-types (1.19) multi_json (1.5.0) nokogiri (1.5.5) @@ -149,10 +141,6 @@ GEM cocaine (~> 0.4.0) mime-types polyglot (0.3.3) - pry (0.9.10) - coderay (~> 1.0.5) - method_source (~> 0.8) - slop (~> 3.3.1) rack (1.4.1) rack-cache (1.2) rack (>= 0.4) @@ -178,7 +166,6 @@ GEM rake (10.0.3) rdoc (3.12) json (~> 1.4) - ref (1.0.2) rest-client (1.6.7) mime-types (>= 1.16) rspec-core (2.12.2) @@ -211,7 +198,6 @@ GEM activesupport (~> 3.0) railties (~> 3.0) slim (~> 1.0) - slop (3.3.3) sprockets (2.2.2) hike (~> 1.2) multi_json (~> 1.0) @@ -221,8 +207,6 @@ GEM capybara (>= 1.0.0) rspec-rails (>= 2.5.0) temple (0.5.5) - therubyracer (0.11.0) - ref thin (1.5.0) daemons (>= 1.0.9) eventmachine (>= 0.12.6) @@ -256,13 +240,10 @@ DEPENDENCIES factory_girl_rails haml-rails jquery-rails - less-rails paperclip - pry sass-rails simply_stored! slim-rails steak - therubyracer thin tinymce-rails diff --git a/app/views/cmtool/application/_menu.html.slim b/app/views/cmtool/application/_menu.html.slim new file mode 100644 index 0000000..251757c --- /dev/null +++ b/app/views/cmtool/application/_menu.html.slim @@ -0,0 +1,32 @@ +.navbar.navbar-fixed-top + .navbar-inner + .container + a.btn.btn-navbar data-target=".nav-collapse" data-toggle="collapse" + span.icon-bar + span.icon-bar + span.icon-bar + a.brand href=root_path = application_title + .nav-collapse + - if user_signed_in? + ul.nav + - Cmtool::Menu.items.each do |menu_item| + - if menu_item.group? + li.dropdown class=(menu_item.controller_names.include?(controller_name) ? 'active' : '') + a.dropdown-toggle href="#" data-toggle="dropdown" + span = menu_item.title + b.caret + ul.child-menu.dropdown-menu + - menu_item.items.compact.each do |child_item| + - if child_item.divider? + li.divider + - else + li[ class=(controller_name == child_item.controller_name ? 'active' : '') ] = link_to child_item.title, child_item.path + - elsif menu_item.resource_link? + li[ class=(menu_item.controller_name == controller_name ? 'active' : '')]= link_to menu_item.title, menu_item.path + .btn-group.pull-right + a.btn.dropdown-toggle[data-toggle="dropdown" href="#"] + i.icon-user + = current_user.email + span.caret + ul.dropdown-menu + li.log-out= link_to t('helpers.links.logout'), destroy_user_session_path diff --git a/app/views/layouts/cmtool/application.html.slim b/app/views/layouts/cmtool/application.html.slim index 7acf864..f153d3a 100644 --- a/app/views/layouts/cmtool/application.html.slim +++ b/app/views/layouts/cmtool/application.html.slim @@ -23,39 +23,7 @@ html lang="en" }); body - .navbar.navbar-fixed-top - .navbar-inner - .container - a.btn.btn-navbar data-target=".nav-collapse" data-toggle="collapse" - span.icon-bar - span.icon-bar - span.icon-bar - a.brand href=root_path = application_title - .container.nav-collapse - - if user_signed_in? - ul.nav - - Cmtool::Menu.items.each do |menu_item| - - if menu_item.group? - li.dropdown class=(menu_item.controller_names.include?(controller_name) ? 'active' : '') - a.dropdown-toggle href="#" data-toggle="dropdown" - span = menu_item.title - b.caret - ul.child-menu.dropdown-menu - - menu_item.items.compact.each do |child_item| - - if child_item.divider? - li.divider - - else - li[ class=(controller_name == child_item.controller_name ? 'active' : '') ] = link_to child_item.title, child_item.path - - elsif menu_item.resource_link? - li[ class=(menu_item.controller_name == controller_name ? 'active' : '')]= link_to menu_item.title, menu_item.path - .btn-group.pull-right - a.btn.dropdown-toggle[data-toggle="dropdown" href="#"] - i.icon-user - = current_user.email - span.caret - ul.dropdown-menu - li.log-out= link_to t('helpers.links.logout'), destroy_user_session_path - + = render 'cmtool/application/menu' .container .content diff --git a/lib/cmtool/engine.rb b/lib/cmtool/engine.rb index 226073f..3e7621f 100644 --- a/lib/cmtool/engine.rb +++ b/lib/cmtool/engine.rb @@ -15,6 +15,7 @@ module Cmtool class Engine < ::Rails::Engine isolate_namespace Cmtool initializer "cmtool.build_menu" do + require 'email_validator' Cmtool::Menu.register do group label: :site do title t('cmtool.menu.site.title')