refactor for better plugin integration

This commit is contained in:
2012-12-17 14:19:04 +01:00
parent e02a93bda1
commit c1ff4a9e50
7 changed files with 41 additions and 5 deletions
+2 -1
View File
@@ -22,7 +22,7 @@ PATH
cmtool (0.5.0)
bourbon
coffee-script
devise
devise (= 2.0.4)
devise_simply_stored
email_validator
haml-rails
@@ -30,6 +30,7 @@ PATH
paperclip
rails (~> 3.2.2)
sass-rails
slim-rails
tinymce-rails
GEM
@@ -2,5 +2,13 @@
body
padding-top: 60px
dl
&.dl-horizontal
dt
&:after
content: ' :'
dd
&:after
content: '\a0'
@import "bootstrap-responsive"
+1 -1
View File
@@ -5,7 +5,7 @@
span.icon-bar
span.icon-bar
span.icon-bar
a.brand href=root_path = application_title
a.brand href=cmtool.root_path = application_title
.nav-collapse
- if user_signed_in?
ul.nav
+2 -1
View File
@@ -20,12 +20,13 @@ Gem::Specification.new do |s|
s.add_dependency 'email_validator'
s.add_dependency 'bourbon'
s.add_dependency 'haml-rails'
s.add_dependency 'slim-rails'
s.add_dependency 'sass-rails'
s.add_dependency 'tinymce-rails'
s.add_dependency 'paperclip'
s.add_dependency 'coffee-script'
s.add_dependency "jquery-rails"
s.add_dependency 'devise'
s.add_dependency 'devise', '2.0.4'
s.add_dependency 'devise_simply_stored'
#s.add_development_dependency "sqlite3"
+3
View File
@@ -16,6 +16,9 @@ module Cmtool
isolate_namespace Cmtool
initializer "cmtool.build_menu" do
require 'email_validator'
require 'bourbon'
require 'slim-rails'
require 'haml-rails'
Cmtool::Menu.register do
group label: :site do
title t('cmtool.menu.site.title')
+2 -2
View File
@@ -169,12 +169,12 @@ module Cmtool
@items = @before + @items + @after
end
def append_to(label, &block)
def append_to(label, options = {}, &block)
item = items.find{|i| i.options[:label] == label}
if item
register = item.instance_variable_get('@register')
if register
register.instance_variable_get('@items') << Cmtool::Menu::Divider.new
register.instance_variable_get('@items') << Cmtool::Menu::Divider.new unless options[:skip_divider].present?
register.instance_eval(&block)
end
else
+23
View File
@@ -38,6 +38,14 @@ describe Cmtool::Menu do
Cmtool::Menu.items.size.should == 5
end
it "should have publications as second item" do
Cmtool::Menu.items[1].options[:label].should == :publications
end
it "should have three publications item by default" do
Cmtool::Menu.items[1].items.size.should == 3
end
end
describe 'New register block' do
@@ -73,5 +81,20 @@ describe Cmtool::Menu do
end
Cmtool::Menu.items.size.should == 1
end
it "should have added a divider and a link to publications" do
Cmtool::Menu.items[1].items.size.should == 5
end
it "should not add a divider when skip_divider option is given" do
Cmtool::Menu.reset!
Cmtool::Menu.register &@base_block
Cmtool::Menu.register do
append_to :publications, skip_divider: true do
resource_link Cmtool::Directory
end
end
Cmtool::Menu.items[1].items.size.should == 4
end
end
end