From e735aa36e30492532e8a92439ee652f258825c60 Mon Sep 17 00:00:00 2001 From: Dirk Kelly Date: Tue, 22 Feb 2011 00:45:53 +0800 Subject: [PATCH 01/26] accented character caused an exception on my biggeted machine. Removed to avoid in the future --- spec/factories.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/factories.rb b/spec/factories.rb index 9f9f253a..23a61783 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -40,7 +40,7 @@ Factory.define "frenchy user", :parent => :account do |a| end Factory.define "brazillian user", :parent => :account do |a| - a.name "José Carlos" + a.name "Jose Carlos" a.email "jose@carlos.com.br" a.locale 'pt-BR' end From ba6ce5c861698944bc88f14dac9e6ed99d783c64 Mon Sep 17 00:00:00 2001 From: Dirk Kelly Date: Tue, 22 Feb 2011 00:46:10 +0800 Subject: [PATCH 02/26] updates to gem versions --- Gemfile | 1 + Gemfile.lock | 22 ++++++++++++++-------- locomotive_cms.gemspec | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Gemfile b/Gemfile index fc485caa..76b061d7 100644 --- a/Gemfile +++ b/Gemfile @@ -52,6 +52,7 @@ group :test do gem 'rspec-rails', '2.3.1' gem 'factory_girl_rails' gem 'pickle' + gem 'xpath', :git => 'https://github.com/wunderbread/xpath.git' gem 'capybara' gem 'database_cleaner' diff --git a/Gemfile.lock b/Gemfile.lock index d22d7a07..8d6e0ac0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -4,11 +4,18 @@ GIT specs: mocha (0.9.12.20110213002255) +GIT + remote: https://github.com/wunderbread/xpath.git + revision: d04da707886287e7dfe82705fda5b3d4f65e94c3 + specs: + xpath (0.1.2) + nokogiri (~> 1.4) + GEM remote: http://rubygems.org/ specs: RedCloth (4.2.7) - ZenTest (4.4.2) + ZenTest (4.5.0) abstract (1.0.0) actionmailer (3.0.4) actionpack (= 3.0.4) @@ -45,7 +52,7 @@ GEM bson (1.2.2) bson_ext (1.2.2) builder (2.1.2) - capybara (0.4.1.2) + capybara (0.4.0) celerity (>= 0.7.9) culerity (>= 0.2.4) mime-types (>= 1.16) @@ -53,7 +60,7 @@ GEM rack (>= 1.0.0) rack-test (>= 0.5.4) selenium-webdriver (>= 0.0.27) - xpath (~> 0.1.3) + xpath (~> 0.1.2) celerity (0.8.8) childprocess (0.1.7) ffi (~> 0.6.3) @@ -75,7 +82,7 @@ GEM locomotive_carrierwave mongoid (~> 2.0.0.rc.6) daemons (1.1.0) - database_cleaner (0.6.3) + database_cleaner (0.6.4) delayed_job (2.1.2) activesupport (~> 3.0) daemons @@ -88,7 +95,7 @@ GEM diff-lcs (1.1.2) erubis (2.6.6) abstract (>= 1.0.0) - excon (0.5.4) + excon (0.5.6) factory_girl (1.3.3) factory_girl_rails (1.0.1) factory_girl (~> 1.3) @@ -242,10 +249,8 @@ GEM warden (0.10.7) rack (>= 1.0.0) will_paginate (3.0.pre2) - xpath (0.1.3) - nokogiri (~> 1.3) yard (0.6.4) - yui-compressor (0.9.3) + yui-compressor (0.9.4) PLATFORMS ruby @@ -291,3 +296,4 @@ DEPENDENCIES unicorn warden will_paginate + xpath! diff --git a/locomotive_cms.gemspec b/locomotive_cms.gemspec index 6714bcad..c0714364 100644 --- a/locomotive_cms.gemspec +++ b/locomotive_cms.gemspec @@ -34,7 +34,7 @@ Gem::Specification.new do |s| s.add_dependency "locomotive_carrierwave", "0.5.0.1.beta2" s.add_dependency "custom_fields", "1.0.0.beta.4" - s.add_dependency "fog", "0.3.7" + s.add_dependency "fog", "0.5.3" s.add_dependency "mimetype-fu" s.add_dependency "actionmailer-with-request" s.add_dependency "heroku" From f18456c629ae05dd77d5354a879ee5c3d8f2899a Mon Sep 17 00:00:00 2001 From: Dirk Kelly Date: Tue, 22 Feb 2011 08:23:46 +0800 Subject: [PATCH 03/26] not required delayed_job_mongoid --- lib/locomotive/engine.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/locomotive/engine.rb b/lib/locomotive/engine.rb index f34d1a5f..a125ef5c 100644 --- a/lib/locomotive/engine.rb +++ b/lib/locomotive/engine.rb @@ -16,7 +16,7 @@ require 'actionmailer_with_request' require 'heroku' require 'httparty' require 'redcloth' -require 'delayed_job_mongoid' +#require 'delayed_job_mongoid' require 'zip/zipfilesystem' require 'jammit-s3' From 333b6fab5cef8a0cd990a9af6a3e45690d61196e Mon Sep 17 00:00:00 2001 From: Dirk Kelly Date: Tue, 22 Feb 2011 08:32:40 +0800 Subject: [PATCH 04/26] dont require delayed job --- lib/locomotive.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/locomotive.rb b/lib/locomotive.rb index 830edcc5..58c98f2e 100644 --- a/lib/locomotive.rb +++ b/lib/locomotive.rb @@ -17,7 +17,7 @@ require 'locomotive/routing' require 'locomotive/regexps' require 'locomotive/render' require 'locomotive/import' -require 'locomotive/delayed_job' +#require 'locomotive/delayed_job' require 'locomotive/middlewares' require 'locomotive/session_store' From 6070da8a5cb0132eeb10074415c78853c77c8e70 Mon Sep 17 00:00:00 2001 From: Dirk Kelly Date: Fri, 25 Feb 2011 11:47:12 +0800 Subject: [PATCH 05/26] added some helper methods to content_types liquid drops (via @KarlBright) --- lib/locomotive/liquid/drops/contents.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/locomotive/liquid/drops/contents.rb b/lib/locomotive/liquid/drops/contents.rb index cfa58cf6..65a2e1c2 100644 --- a/lib/locomotive/liquid/drops/contents.rb +++ b/lib/locomotive/liquid/drops/contents.rb @@ -28,6 +28,18 @@ module Locomotive def each(&block) self.collection.each(&block) end + + def size + self.collection.size + end + + def empty? + self.collection.empty? + end + + def any? + self.collection.any? + end def api { 'create' => @context.registers[:controller].send('admin_api_contents_url', @content_type.slug) } From 0b11a3813b639d7ba526a0663f2667ac3b6452a8 Mon Sep 17 00:00:00 2001 From: Dirk Kelly Date: Mon, 28 Feb 2011 12:09:33 +0800 Subject: [PATCH 06/26] simplified the theme_image_tag a little --- lib/locomotive/liquid/filters/html.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/locomotive/liquid/filters/html.rb b/lib/locomotive/liquid/filters/html.rb index acfca793..963cfd30 100644 --- a/lib/locomotive/liquid/filters/html.rb +++ b/lib/locomotive/liquid/filters/html.rb @@ -43,10 +43,8 @@ module Locomotive # input: name of file including folder # example: 'about/myphoto.jpg' | theme_image # def theme_image_tag(input, *args) - return '' if input.nil? - input = "images/#{input}" unless input.starts_with?('/') image_options = inline_options(args_to_options(args)) - "" + "" end # Write an image tag From e059ce2023fe697ee10e9161ba2732417cecdbd9 Mon Sep 17 00:00:00 2001 From: Dirk Kelly Date: Mon, 28 Feb 2011 13:42:50 +0800 Subject: [PATCH 07/26] Making the error message a bit more useful --- app/controllers/admin/imports_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/admin/imports_controller.rb b/app/controllers/admin/imports_controller.rb index c611ce23..ab717bf1 100644 --- a/app/controllers/admin/imports_controller.rb +++ b/app/controllers/admin/imports_controller.rb @@ -34,7 +34,7 @@ module Admin rescue Exception => e logger.error "[Locomotive import] #{e.message} / #{e.backtrace}" - @error = t('errors.messages.invalid_theme_file') + @error = e.message flash[:alert] = t('flash.admin.imports.create.alert') render 'new' From ed88eb82b0376ec78357ea9d0389475eaad5abc9 Mon Sep 17 00:00:00 2001 From: Dirk Kelly Date: Wed, 2 Mar 2011 08:12:42 +0800 Subject: [PATCH 08/26] added inheritable? to the parent check on editable_contents --- app/models/extensions/page/editable_elements.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/extensions/page/editable_elements.rb b/app/models/extensions/page/editable_elements.rb index 8398f4cc..0716f62c 100644 --- a/app/models/extensions/page/editable_elements.rb +++ b/app/models/extensions/page/editable_elements.rb @@ -62,7 +62,7 @@ module Models def merge_editable_elements_from_page(source) source.editable_elements.each do |el| - next if el.disabled? + next if el.disabled? or !el.inheritable? existing_el = self.find_editable_element(el.block, el.slug) From 778a55245cb551f7a20d7f472d24d52da7a22e0f Mon Sep 17 00:00:00 2001 From: Dirk Kelly Date: Wed, 2 Mar 2011 08:13:03 +0800 Subject: [PATCH 09/26] added the inheritable attribute to editable elements --- app/models/editable_element.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/editable_element.rb b/app/models/editable_element.rb index 109bc121..0ba60c27 100644 --- a/app/models/editable_element.rb +++ b/app/models/editable_element.rb @@ -8,6 +8,7 @@ class EditableElement field :default_content field :hint field :disabled, :type => Boolean, :default => false + field :inheritable, :type => Boolean, :default => true field :from_parent, :type => Boolean, :default => false ## associations ## From 04b0849dc5619f73e91879409f8f24055cc4f183 Mon Sep 17 00:00:00 2001 From: Dirk Kelly Date: Wed, 2 Mar 2011 08:14:58 +0800 Subject: [PATCH 10/26] Added the liquid tag for content, retrieves an editable element from self or parent if inherited: true --- lib/locomotive/liquid/tags/editable/ouput.rb | 49 ++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 lib/locomotive/liquid/tags/editable/ouput.rb diff --git a/lib/locomotive/liquid/tags/editable/ouput.rb b/lib/locomotive/liquid/tags/editable/ouput.rb new file mode 100644 index 00000000..1964f92a --- /dev/null +++ b/lib/locomotive/liquid/tags/editable/ouput.rb @@ -0,0 +1,49 @@ +module Locomotive + module Liquid + module Tags + module Editable + class Content < ::Liquid::Tag + + Syntax = /(#{::Liquid::Expression}+)?/ + + def initialize(tag_name, markup, tokens, context) + if markup =~ Syntax + @slug = $1 + @options = { :inherit => false } + markup.scan(::Liquid::TagAttributes) { |key, value| @options[key.to_sym] = value.gsub(/"|'/, '') } + else + raise ::Liquid::SyntaxError.new("Syntax Error in 'content' - Valid syntax: slug") + end + + super + end + + def render(context) + page = context.registers[:page] + element = find_element(page) + + if element.nil? && @options[:inherit] != false + while page.parent.present? && element.nil? + page = page.parent + element = find_element(page) + end + end + + if element.present? + return element.content + else + raise ::Liquid::SyntaxError.new("Error in 'content' - Can't find editable element called `#{@slug}`") + end + end + + def find_element(page) + page.editable_elements.where(:slug => @slug).first + end + + end + + ::Liquid::Template.register_tag('content', Content) + end + end + end +end \ No newline at end of file From 77d7587150c09f56cd337e192ca065f18b3e7584 Mon Sep 17 00:00:00 2001 From: Dirk Kelly Date: Wed, 2 Mar 2011 08:15:54 +0800 Subject: [PATCH 11/26] allow inheritable to be sent through as a tag --- lib/locomotive/liquid/tags/editable/base.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/locomotive/liquid/tags/editable/base.rb b/lib/locomotive/liquid/tags/editable/base.rb index b2621185..e359e02f 100644 --- a/lib/locomotive/liquid/tags/editable/base.rb +++ b/lib/locomotive/liquid/tags/editable/base.rb @@ -9,7 +9,7 @@ module Locomotive def initialize(tag_name, markup, tokens, context) if markup =~ Syntax @slug = $1.gsub('\'', '') - @options = {} + @options = { :inheritable => true } markup.scan(::Liquid::TagAttributes) { |key, value| @options[key.to_sym] = value.gsub(/^'/, '').gsub(/'$/, '') } else raise ::Liquid::SyntaxError.new("Syntax Error in 'editable_xxx' - Valid syntax: editable_xxx (, )") @@ -27,6 +27,7 @@ module Locomotive :slug => @slug, :hint => @options[:hint], :default_content => @nodelist.first.to_s, + :inheritable => @options[:inheritable], :disabled => false, :from_parent => false }, document_type) From cc51e75f5c66f64b3debf98a472c642bf9b7cfd5 Mon Sep 17 00:00:00 2001 From: Dirk Kelly Date: Wed, 2 Mar 2011 08:22:41 +0800 Subject: [PATCH 12/26] change the tag name for retrieving a value to be 'content' {% content somecooltitlebro, inherit: true %} --- lib/locomotive/liquid/tags/editable.rb | 3 ++- lib/locomotive/liquid/tags/editable/{ouput.rb => content.rb} | 0 2 files changed, 2 insertions(+), 1 deletion(-) rename lib/locomotive/liquid/tags/editable/{ouput.rb => content.rb} (100%) diff --git a/lib/locomotive/liquid/tags/editable.rb b/lib/locomotive/liquid/tags/editable.rb index 82609f12..ed857c94 100644 --- a/lib/locomotive/liquid/tags/editable.rb +++ b/lib/locomotive/liquid/tags/editable.rb @@ -1,4 +1,5 @@ require 'locomotive/liquid/tags/editable/base' require 'locomotive/liquid/tags/editable/short_text' require 'locomotive/liquid/tags/editable/long_text' -require 'locomotive/liquid/tags/editable/file' \ No newline at end of file +require 'locomotive/liquid/tags/editable/file' +require 'locomotive/liquid/tags/editable/content' \ No newline at end of file diff --git a/lib/locomotive/liquid/tags/editable/ouput.rb b/lib/locomotive/liquid/tags/editable/content.rb similarity index 100% rename from lib/locomotive/liquid/tags/editable/ouput.rb rename to lib/locomotive/liquid/tags/editable/content.rb From f4c242ce1aba298c023934ba5bb0d1304bbead41 Mon Sep 17 00:00:00 2001 From: Dirk Kelly Date: Wed, 2 Mar 2011 09:11:40 +0800 Subject: [PATCH 13/26] speccing out the content tag --- .../liquid/tags/editable/content_spec.rb | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 spec/lib/locomotive/liquid/tags/editable/content_spec.rb diff --git a/spec/lib/locomotive/liquid/tags/editable/content_spec.rb b/spec/lib/locomotive/liquid/tags/editable/content_spec.rb new file mode 100644 index 00000000..d5405545 --- /dev/null +++ b/spec/lib/locomotive/liquid/tags/editable/content_spec.rb @@ -0,0 +1,97 @@ +require 'spec_helper' + +describe Locomotive::Liquid::Tags::Editable::Content do + + before :each do + Locomotive::Liquid::Tags::Editable::Content.any_instance.stubs(:end_tag).returns(true) + end + + context 'syntax' do + + it 'should have a valid syntax' do + ["slug", "slug, inherit: true"].each do |markup| + lambda do + Locomotive::Liquid::Tags::Editable::Content.new('content', markup, ["{% content %}"], {}) + end.should_not raise_error + end + end + + end + + context 'output' do + + before :each do + EditableElement.any_instance.stubs(:content).returns("test string") + end + + context 'inheriting from a parent' do + + before :each do + @parent = Factory.build(:page) + @child = Factory.build(:page) + + @child.stubs(:parent).returns(@parent) + end + + it 'should return the parents field if inherit is set' do + @element = @parent.editable_elements.create(:slug => 'test') + @child.stubs(:raw_template).returns("{% content test, inherit: true %}") + template = Liquid::Template.parse(@child.raw_template) + text = template.render!(liquid_context(:page => @child)) + text.should match /test string/ + end + + it 'should raise an exception if it cant find the field' do + @child.stubs(:raw_template).returns("{% content test, inherit: true %}") + template = Liquid::Template.parse(@child.raw_template) + lambda do + template.render!(liquid_context(:page => @child)) + end.should raise_error + end + + after :each do + @parent.editable_elements.destroy_all + end + + end + + context 'reading from the same page' do + + before :each do + @page = Factory.build(:page) + end + + it 'should return the previously defined field' do + @element = @page.editable_elements.create(:slug => 'test') + @page.stubs(:raw_template).returns("{% content test %}") + template = Liquid::Template.parse(@page.raw_template) + text = template.render!(liquid_context(:page => @page)) + text.should match /test string/ + end + + it 'should raise an exception if it wasnt defined' do + @page.stubs(:raw_template).returns("{% content test %}") + template = Liquid::Template.parse(@page.raw_template) + lambda do + template.render!(liquid_context(:page => @page)) + end.should raise_error + end + + after :each do + @page.editable_elements.destroy_all + end + + end + + end + + # ___ helpers methods ___ # + + def liquid_context(options = {}) + ::Liquid::Context.new({}, {}, + { + :page => options[:page] + }, true) + end + +end From adbae00457c9c7a685330a23e20e1170577d3433 Mon Sep 17 00:00:00 2001 From: Dirk Kelly Date: Wed, 2 Mar 2011 09:13:45 +0800 Subject: [PATCH 14/26] changed the editable inheritance tag to be assignable, avoiding confusion between that and the content tag inheritance --- app/models/editable_element.rb | 2 +- app/models/extensions/page/editable_elements.rb | 2 +- lib/locomotive/liquid/tags/editable/base.rb | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/editable_element.rb b/app/models/editable_element.rb index 0ba60c27..10321173 100644 --- a/app/models/editable_element.rb +++ b/app/models/editable_element.rb @@ -8,7 +8,7 @@ class EditableElement field :default_content field :hint field :disabled, :type => Boolean, :default => false - field :inheritable, :type => Boolean, :default => true + field :assignable, :type => Boolean, :default => true field :from_parent, :type => Boolean, :default => false ## associations ## diff --git a/app/models/extensions/page/editable_elements.rb b/app/models/extensions/page/editable_elements.rb index 0716f62c..1246d3af 100644 --- a/app/models/extensions/page/editable_elements.rb +++ b/app/models/extensions/page/editable_elements.rb @@ -62,7 +62,7 @@ module Models def merge_editable_elements_from_page(source) source.editable_elements.each do |el| - next if el.disabled? or !el.inheritable? + next if el.disabled? or !el.assignable? existing_el = self.find_editable_element(el.block, el.slug) diff --git a/lib/locomotive/liquid/tags/editable/base.rb b/lib/locomotive/liquid/tags/editable/base.rb index e359e02f..c1bc1b4c 100644 --- a/lib/locomotive/liquid/tags/editable/base.rb +++ b/lib/locomotive/liquid/tags/editable/base.rb @@ -9,7 +9,7 @@ module Locomotive def initialize(tag_name, markup, tokens, context) if markup =~ Syntax @slug = $1.gsub('\'', '') - @options = { :inheritable => true } + @options = { :assignable => true } markup.scan(::Liquid::TagAttributes) { |key, value| @options[key.to_sym] = value.gsub(/^'/, '').gsub(/'$/, '') } else raise ::Liquid::SyntaxError.new("Syntax Error in 'editable_xxx' - Valid syntax: editable_xxx (, )") @@ -27,7 +27,7 @@ module Locomotive :slug => @slug, :hint => @options[:hint], :default_content => @nodelist.first.to_s, - :inheritable => @options[:inheritable], + :assignable => @options[:assignable], :disabled => false, :from_parent => false }, document_type) From 74277b48ed8348fbe6fb4ce6fd7b8848c98e4437 Mon Sep 17 00:00:00 2001 From: Dirk Kelly Date: Wed, 2 Mar 2011 10:05:50 +0800 Subject: [PATCH 15/26] the rescue wasn't trying the name, causing private method call exceptions --- lib/locomotive/liquid/tags/editable/base.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/locomotive/liquid/tags/editable/base.rb b/lib/locomotive/liquid/tags/editable/base.rb index c1bc1b4c..03e82ad7 100644 --- a/lib/locomotive/liquid/tags/editable/base.rb +++ b/lib/locomotive/liquid/tags/editable/base.rb @@ -38,11 +38,11 @@ module Locomotive current_page = context.registers[:page] element = current_page.find_editable_element(context['block'].try(:name), @slug) - - if element + + if element.present? render_element(context, element) else - Locomotive.logger "[editable element] missing element #{context[:block].name} / #{@slug}" + Locomotive.logger "[editable element] missing element `#{context['block'].try(:name)}` / #{@slug} on #{current_page.fullpath}" '' end end From 95cd56cba2e2015626117ec06b2e2bbe1f5820d0 Mon Sep 17 00:00:00 2001 From: Dirk Kelly Date: Wed, 2 Mar 2011 11:28:54 +0800 Subject: [PATCH 16/26] sending a default tag will call the method on the page. Ignoring the default text in the tags. {% editable_short_text coolertitle, default: title %}{% endeditable_short_text %} --- lib/locomotive/liquid/tags/editable/base.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/locomotive/liquid/tags/editable/base.rb b/lib/locomotive/liquid/tags/editable/base.rb index 03e82ad7..ef6b3813 100644 --- a/lib/locomotive/liquid/tags/editable/base.rb +++ b/lib/locomotive/liquid/tags/editable/base.rb @@ -26,7 +26,7 @@ module Locomotive :block => @context[:current_block].try(:name), :slug => @slug, :hint => @options[:hint], - :default_content => @nodelist.first.to_s, + :default_content => default_content, :assignable => @options[:assignable], :disabled => false, :from_parent => false @@ -56,6 +56,15 @@ module Locomotive def document_type raise 'FIXME: has to be overidden' end + + + def default_content + if @options[:default].present? + @context[:page].send(@options[:default]) + else + @nodelist.first.to_s + end + end end From ea81025d3373c7b3295aa82b30ccb39d0f09d2d6 Mon Sep 17 00:00:00 2001 From: Dirk Kelly Date: Wed, 2 Mar 2011 14:38:32 +0800 Subject: [PATCH 17/26] storing default_attribute on the editable_element if a default attribute has been parsed. --- app/models/editable_element.rb | 1 + lib/locomotive/liquid/tags/editable/base.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/app/models/editable_element.rb b/app/models/editable_element.rb index 10321173..60c563c8 100644 --- a/app/models/editable_element.rb +++ b/app/models/editable_element.rb @@ -6,6 +6,7 @@ class EditableElement field :slug field :block field :default_content + field :default_attribute field :hint field :disabled, :type => Boolean, :default => false field :assignable, :type => Boolean, :default => true diff --git a/lib/locomotive/liquid/tags/editable/base.rb b/lib/locomotive/liquid/tags/editable/base.rb index ef6b3813..aaa04c50 100644 --- a/lib/locomotive/liquid/tags/editable/base.rb +++ b/lib/locomotive/liquid/tags/editable/base.rb @@ -26,6 +26,7 @@ module Locomotive :block => @context[:current_block].try(:name), :slug => @slug, :hint => @options[:hint], + :default_attribute => @options[:default], :default_content => default_content, :assignable => @options[:assignable], :disabled => false, From 97e3ddb6e39c59dc58a2dea707c7d39c2b3cd609 Mon Sep 17 00:00:00 2001 From: Dirk Kelly Date: Wed, 2 Mar 2011 14:38:57 +0800 Subject: [PATCH 18/26] reading that default attribute on inheriting editable_elements and calling the method on that page (instead of getting it from the parent) --- app/models/extensions/page/editable_elements.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/extensions/page/editable_elements.rb b/app/models/extensions/page/editable_elements.rb index 1246d3af..1e4d85ae 100644 --- a/app/models/extensions/page/editable_elements.rb +++ b/app/models/extensions/page/editable_elements.rb @@ -68,8 +68,12 @@ module Models if existing_el.nil? # new one from parents new_attributes = el.attributes.merge(:from_parent => true) - new_attributes[:default_content] = el.content - + if new_attributes['default_attribute'].present? + new_attributes['default_content'] = self.send(new_attributes['default_attribute']) || el.content + else + new_attributes['default_content'] = el.content + end + self.editable_elements.build(new_attributes, el.class) else existing_el.attributes = { :disabled => false, :default_content => el.content } From 9145540ef0065f70a500d7b8b0588b13c8a346b5 Mon Sep 17 00:00:00 2001 From: Dirk Kelly Date: Thu, 3 Mar 2011 07:50:22 +0800 Subject: [PATCH 19/26] the import build_parent_template regex was missing nested layouts. Test theme has two new pages to test this. --- lib/locomotive/import/pages.rb | 5 +---- spec/fixtures/themes/default.zip | Bin 409020 -> 410691 bytes spec/lib/locomotive/import_spec.rb | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/locomotive/import/pages.rb b/lib/locomotive/import/pages.rb index 610ae68f..38722f53 100644 --- a/lib/locomotive/import/pages.rb +++ b/lib/locomotive/import/pages.rb @@ -91,13 +91,10 @@ module Locomotive def build_parent_template(template) # just check if the template contains the extends keyword - fullpath = template.scan(/\{% extends (\w+) %\}/).flatten.first + fullpath = template.scan(/\{%\s*extends\s*\'([^\']+)\'\s*%\}/).flatten.first if fullpath # inheritance detected - fullpath.gsub!("'", '') - return if fullpath == 'parent' - self.add_page(fullpath) end end diff --git a/spec/fixtures/themes/default.zip b/spec/fixtures/themes/default.zip index 916d4cac79ad0ed76d7cfd176824b81b7a6d3e09..9bf39d8ffecbd0827d8105fc353b99884dc8c0b8 100644 GIT binary patch delta 8524 zcmbtZ30zcF7oW#4mwg)$*&X&}V1{LI0B2a;SOx(>5kW+70gW=WGBw35x8&0aFPasa zSf-+6imBxSSeB${YKys~zZTo9KK;tfzPr5l=Dh)Iarg~C_1v@l&pG#=b3FXJN5^tc zhrDd5rL6>i4(Kb_Is|*{yijYv-`k9v1QXpP*63$l>)NbX`|yjkhCnAJp|vefk|zDG zuS_P)>@ORMv!uM-kd`rObg{aq*j|D;@RyTDRUtOxJ*mpWoXY7kUjIP}a|3|0BbC7E zgvVSMZ>aPG_O+`|u6!cTH*R6Er@?NISylk{|`kvI>DH9_8Gkschcaa_P&dNH&5S&qij6a0FA}B;|4TSlfjF%sF z$Q&LXyJWbtg9$Y*klFSFVO5K9vn+>Tcxh5zHb!LcZ?Yj{r5FuuS-ht?8YZlkmJR6# zD5{-5XU$^-m%LM?by~YH6q8TQVq}=U2Y{4r9l^2W5?fe@@D{S zUc(H5+gunY5tW#fiLid=p-u8Le&+^bw=x(9 z5t)aEd1yNpwd&o4F{jX^2P7b9)bQ=0ECTb!jVHlu|9B|#Zl*;*0^GcY$s|T`By5xd zx;HTL%$zayi*7bCog1fRdANMB<>YT~J-tFEOWgkS(v}s&R?G?BFlW2{(z_sa;v?%e z&Dc0?L(??hO-<{IpRX=koM-P+f$s?`>tUDP-U4SfAcSnRa9IPBO0*5U#3FRIf!P^> zNed4$*&-5;j{ifWGh6S_+#8+WnKAYRcwC8qN{QM%mFJMNc zRPWXAm7NUldx3D19`l0&J(bcTkscfeFL?F7EZl~kdNr^F?k$git* zCJv6A`si%0l&&K`?cI4`$!j{}hLeZqgwF9Vdq357;_BlYPHk#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I-IW)OGB71c;|pPFoifJHao9T^Q+7Gntc#NBa41`@z9!Wtb5V7@yt8i;ru zj<7~|TrnFxrsqY1=>$Ahw0w7DG+^Bc&qsnnQa8sHcgvw63YdvEmY#fXq)iQ27eW+V z36Dep14+QPj1~{SfMi;bO^Sy_AKk-doUcX4iPdzD#vU!m7}XdM4GNta@iA$L2D!wD zzjpF*V_o)bG?-1$V*SUDi4Van9mpO12nR-^BYa*5Qi#9poX}>$n+L~$Du>Of5o^8I zV!*8N*bB=%J}hK35cQ~c#{rHfnTqZ)O0Yw=)6w#o@SED`hsPR2yy-mqq{=8^6($`Dijtmf(I9hR@78e`y+Gn=o zdwVVV1@pXH>#tC6s7(Sg(h67>Io1icg0JY;^cJ`{324Ysa;yf9!WS`GyC}D?V+f3P zM?q*cZDD9Zkks)@27$s4-AOj^SG05jU5fP$pM2S>QX>{9a8)u;3V{@pt%gUFfr22j zEw}YDpS?*uWH-`3g-i+vcY3!YJ(HG#AVtb3BqUBGuto-C)^cKn;=mN#lL7*SYEKFY zJCL$qvK$G+qKB_Xl6bIM>sQ*g@Fy3EEg0nsiI&v{1g=cZ1Gh~MFd8iQdoH(-ws`!ks2KFB7r$+ysn7ja7o1 tl{KsY_^Dty!GFQ)?E(!2QPz-zP)@*+sJj^8!}Boub16_D=vU$Y{2zmnb0q)( diff --git a/spec/lib/locomotive/import_spec.rb b/spec/lib/locomotive/import_spec.rb index 425ee5d9..485fc379 100644 --- a/spec/lib/locomotive/import_spec.rb +++ b/spec/lib/locomotive/import_spec.rb @@ -53,7 +53,7 @@ describe Locomotive::Import::Job do end it 'inserts all the pages' do - @site.pages.count.should == 9 + @site.pages.count.should == 11 end it 'inserts the index and 404 pages' do From be4169c9915cee7e354862dd274b5543b17544cc Mon Sep 17 00:00:00 2001 From: Dirk Kelly Date: Thu, 3 Mar 2011 08:05:04 +0800 Subject: [PATCH 20/26] Beginning to improve the error messages with variables to make the import function more verbose on problems --- app/models/extensions/page/parse.rb | 2 +- config/locales/default.de.yml | 2 +- config/locales/default.en.yml | 2 +- config/locales/default.fr.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/extensions/page/parse.rb b/app/models/extensions/page/parse.rb index 7395b241..229e4e1e 100644 --- a/app/models/extensions/page/parse.rb +++ b/app/models/extensions/page/parse.rb @@ -39,7 +39,7 @@ module Models rescue ::Liquid::SyntaxError => error @parsing_errors << :liquid_syntax rescue ::Locomotive::Liquid::PageNotFound => error - @parsing_errors << :liquid_extend + @parsing_errors << I18n.t(:liquid_extend, :fullpath => self.fullpath,:scope => [:errors, :messages]) end end end diff --git a/config/locales/default.de.yml b/config/locales/default.de.yml index cb8a9b55..65b326be 100644 --- a/config/locales/default.de.yml +++ b/config/locales/default.de.yml @@ -33,7 +33,7 @@ de: extname_changed: "Die neue Datei hat nicht die originale Dateiendung" array_too_short: "ist zu kurz (minimale Element-Zahl ist %{count})" liquid_syntax: "Liquid Syntax-Fehler, bitte überprüfe die Syntax" - liquid_extend: "Die Seite verwendet eine Vorlage, die gar nicht existiert" + liquid_extend: "Die Seite '%{fullpath}' verwendet eine Vorlage, die gar nicht existiert" invalid_theme_file: "darf nicht leer sein oder ist keine zip-Datei" attributes: diff --git a/config/locales/default.en.yml b/config/locales/default.en.yml index 4a346137..ae882b4b 100644 --- a/config/locales/default.en.yml +++ b/config/locales/default.en.yml @@ -12,7 +12,7 @@ en: extname_changed: "New file does not have the original extension" array_too_short: "is too small (minimum element number is %{count})" liquid_syntax: "Liquid Syntax error, please check the syntax" - liquid_extend: "The page extends a template which does not exist" + liquid_extend: "The page '%{fullpath}' extends a template which does not exist" invalid_theme_file: "can't be blank or isn't a zip file" attributes: diff --git a/config/locales/default.fr.yml b/config/locales/default.fr.yml index c94ed7bd..63cad4f9 100644 --- a/config/locales/default.fr.yml +++ b/config/locales/default.fr.yml @@ -33,7 +33,7 @@ fr: extname_changed: "Nouveau fichier n'a pas l'extension original" array_too_short: "est trop petit (le nombre minimum d'éléments est %{count})" liquid_syntax: "Erreur de syntaxe dans les sections de page, veuillez vérifier la syntaxe" - liquid_extend: "La page étend le contenu d'une page qui n'existe pas" + liquid_extend: "La page '%{fullpath}' étend le contenu d'une page qui n'existe pas" invalid_theme_file: "doit être rempli ou n'est pas un fichier zip" attributes: From c998d4150c1d252f8e2695e90a1eca3e59c7a8d2 Mon Sep 17 00:00:00 2001 From: Dirk Kelly Date: Thu, 3 Mar 2011 08:06:54 +0800 Subject: [PATCH 21/26] Added fullpath and the error message to liquid syntax error. Translations are pretty dodgy (sorry) --- app/models/extensions/page/parse.rb | 2 +- config/locales/default.de.yml | 2 +- config/locales/default.en.yml | 2 +- config/locales/default.fr.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/extensions/page/parse.rb b/app/models/extensions/page/parse.rb index 229e4e1e..ec304ee5 100644 --- a/app/models/extensions/page/parse.rb +++ b/app/models/extensions/page/parse.rb @@ -37,7 +37,7 @@ module Models begin self._parse_and_serialize_template rescue ::Liquid::SyntaxError => error - @parsing_errors << :liquid_syntax + @parsing_errors << I18n.t(:liquid_syntax, :fullpath => self.fullpath, :error => error.to_s,:scope => [:errors, :messages]) rescue ::Locomotive::Liquid::PageNotFound => error @parsing_errors << I18n.t(:liquid_extend, :fullpath => self.fullpath,:scope => [:errors, :messages]) end diff --git a/config/locales/default.de.yml b/config/locales/default.de.yml index 65b326be..f1f1d48f 100644 --- a/config/locales/default.de.yml +++ b/config/locales/default.de.yml @@ -32,7 +32,7 @@ de: protected_page: "Du kannst keine Index oder 404 Seiten löschen" extname_changed: "Die neue Datei hat nicht die originale Dateiendung" array_too_short: "ist zu kurz (minimale Element-Zahl ist %{count})" - liquid_syntax: "Liquid Syntax-Fehler, bitte überprüfe die Syntax" + liquid_syntax: "Liquid Syntax-Fehler, bitte überprüfe die Syntax ('%{error}'/'%{fullpath}')" liquid_extend: "Die Seite '%{fullpath}' verwendet eine Vorlage, die gar nicht existiert" invalid_theme_file: "darf nicht leer sein oder ist keine zip-Datei" diff --git a/config/locales/default.en.yml b/config/locales/default.en.yml index ae882b4b..1a4f76a0 100644 --- a/config/locales/default.en.yml +++ b/config/locales/default.en.yml @@ -11,7 +11,7 @@ en: protected_page: "You can not remove index or 404 pages" extname_changed: "New file does not have the original extension" array_too_short: "is too small (minimum element number is %{count})" - liquid_syntax: "Liquid Syntax error, please check the syntax" + liquid_syntax: "Liquid Syntax error ('%{error}' on '%{fullpath}')" liquid_extend: "The page '%{fullpath}' extends a template which does not exist" invalid_theme_file: "can't be blank or isn't a zip file" diff --git a/config/locales/default.fr.yml b/config/locales/default.fr.yml index 63cad4f9..f82e2e5a 100644 --- a/config/locales/default.fr.yml +++ b/config/locales/default.fr.yml @@ -32,7 +32,7 @@ fr: protected_page: "Vous ne pouvez pas supprimer les pages index et 404" extname_changed: "Nouveau fichier n'a pas l'extension original" array_too_short: "est trop petit (le nombre minimum d'éléments est %{count})" - liquid_syntax: "Erreur de syntaxe dans les sections de page, veuillez vérifier la syntaxe" + liquid_syntax: "Erreur de syntaxe dans les sections de page, veuillez vérifier la syntaxe ('%{error}'/'%{fullpath}')" liquid_extend: "La page '%{fullpath}' étend le contenu d'une page qui n'existe pas" invalid_theme_file: "doit être rempli ou n'est pas un fichier zip" From 9aa68c46116761152d2a3b46f123005ff82a9d01 Mon Sep 17 00:00:00 2001 From: Dirk Kelly Date: Thu, 3 Mar 2011 13:23:37 +0800 Subject: [PATCH 22/26] oversight on the fact you shouldn't have to put template in quotes. return of the gsub --- lib/locomotive/import/pages.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/locomotive/import/pages.rb b/lib/locomotive/import/pages.rb index 38722f53..8a73317c 100644 --- a/lib/locomotive/import/pages.rb +++ b/lib/locomotive/import/pages.rb @@ -91,9 +91,10 @@ module Locomotive def build_parent_template(template) # just check if the template contains the extends keyword - fullpath = template.scan(/\{%\s*extends\s*\'([^\']+)\'\s*%\}/).flatten.first + fullpath = template.scan(/\{%\s*extends\s*([^\']+)\s*%\}/).flatten.first if fullpath # inheritance detected + fullpath.gsub!("'", '') return if fullpath == 'parent' self.add_page(fullpath) end From 2482567db3500672ce44a0534aedf3c863f91941 Mon Sep 17 00:00:00 2001 From: Dirk Kelly Date: Thu, 3 Mar 2011 15:35:37 +0800 Subject: [PATCH 23/26] avoid updating child pages which have a default_attribute on change of a template they inherit from --- app/models/extensions/page/editable_elements.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/extensions/page/editable_elements.rb b/app/models/extensions/page/editable_elements.rb index 1e4d85ae..e0a6d746 100644 --- a/app/models/extensions/page/editable_elements.rb +++ b/app/models/extensions/page/editable_elements.rb @@ -75,8 +75,10 @@ module Models end self.editable_elements.build(new_attributes, el.class) - else + elsif existing_el.default_attribute.nil? existing_el.attributes = { :disabled => false, :default_content => el.content } + else + existing_el.attributes = { :disabled => false } end end end From af59f2ea7e54689782c5619c8db1c6a3425a3dd3 Mon Sep 17 00:00:00 2001 From: Dirk Kelly Date: Fri, 4 Mar 2011 17:53:02 +0800 Subject: [PATCH 24/26] rails 3 upgrade --- Gemfile.lock | 68 ++++++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8d6e0ac0..74cc13c0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -17,13 +17,13 @@ GEM RedCloth (4.2.7) ZenTest (4.5.0) abstract (1.0.0) - actionmailer (3.0.4) - actionpack (= 3.0.4) + actionmailer (3.0.5) + actionpack (= 3.0.5) mail (~> 2.2.15) actionmailer-with-request (0.1.1) - actionpack (3.0.4) - activemodel (= 3.0.4) - activesupport (= 3.0.4) + actionpack (3.0.5) + activemodel (= 3.0.5) + activesupport (= 3.0.5) builder (~> 2.1.2) erubis (~> 2.6.6) i18n (~> 0.4) @@ -31,26 +31,26 @@ GEM rack-mount (~> 0.6.13) rack-test (~> 0.5.7) tzinfo (~> 0.3.23) - activemodel (3.0.4) - activesupport (= 3.0.4) + activemodel (3.0.5) + activesupport (= 3.0.5) builder (~> 2.1.2) i18n (~> 0.4) - activerecord (3.0.4) - activemodel (= 3.0.4) - activesupport (= 3.0.4) + activerecord (3.0.5) + activemodel (= 3.0.5) + activesupport (= 3.0.5) arel (~> 2.0.2) tzinfo (~> 0.3.23) - activeresource (3.0.4) - activemodel (= 3.0.4) - activesupport (= 3.0.4) - activesupport (3.0.4) + activeresource (3.0.5) + activemodel (= 3.0.5) + activesupport (= 3.0.5) + activesupport (3.0.5) archive-tar-minitar (0.5.2) - arel (2.0.8) + arel (2.0.9) autotest (4.4.6) ZenTest (>= 4.4.1) bcrypt-ruby (2.1.4) - bson (1.2.2) - bson_ext (1.2.2) + bson (1.2.4) + bson_ext (1.2.4) builder (2.1.2) capybara (0.4.0) celerity (>= 0.7.9) @@ -121,10 +121,10 @@ GEM growl-glue (1.0.7) haml (3.0.25) has_scope (0.5.0) - heroku (1.16.2) - json_pure (>= 1.2.0, < 1.5.0) - launchy (~> 0.3.2) - rest-client (>= 1.4.0, < 1.7.0) + heroku (1.6.3) + json (>= 1.1.0) + launchy (>= 0.3.2) + rest-client (>= 1.2.0, < 2.0.0) httparty (0.7.4) crack (= 0.1.8) i18n (0.5.0) @@ -137,7 +137,7 @@ GEM json (1.5.1) json_pure (1.4.6) kgio (2.3.2) - launchy (0.3.7) + launchy (0.4.0) configuration (>= 0.0.5) rake (>= 0.8.1) linecache (0.43) @@ -160,8 +160,8 @@ GEM mime-types (1.16) mimemagic (0.1.8) mimetype-fu (0.1.2) - mongo (1.2.2) - bson (>= 1.2.2) + mongo (1.2.4) + bson (>= 1.2.4) mongoid (2.0.0.rc.7) activemodel (~> 3.0) mongo (~> 1.2) @@ -181,17 +181,17 @@ GEM rack (>= 1.0.0) rack-test (0.5.7) rack (>= 1.0) - rails (3.0.4) - actionmailer (= 3.0.4) - actionpack (= 3.0.4) - activerecord (= 3.0.4) - activeresource (= 3.0.4) - activesupport (= 3.0.4) + rails (3.0.5) + actionmailer (= 3.0.5) + actionpack (= 3.0.5) + activerecord (= 3.0.5) + activeresource (= 3.0.5) + activesupport (= 3.0.5) bundler (~> 1.0) - railties (= 3.0.4) - railties (3.0.4) - actionpack (= 3.0.4) - activesupport (= 3.0.4) + railties (= 3.0.5) + railties (3.0.5) + actionpack (= 3.0.5) + activesupport (= 3.0.5) rake (>= 0.8.7) thor (~> 0.14.4) rake (0.8.7) From 2c1a6c381cfb30e3163d1d7a68d4941ae4b92529 Mon Sep 17 00:00:00 2001 From: Dirk Kelly Date: Fri, 4 Mar 2011 17:53:20 +0800 Subject: [PATCH 25/26] the template parsers was broken on ree, made it a bit simpler, just look for slashes --- lib/locomotive/import/pages.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/locomotive/import/pages.rb b/lib/locomotive/import/pages.rb index 8a73317c..a10f1db6 100644 --- a/lib/locomotive/import/pages.rb +++ b/lib/locomotive/import/pages.rb @@ -91,10 +91,9 @@ module Locomotive def build_parent_template(template) # just check if the template contains the extends keyword - fullpath = template.scan(/\{%\s*extends\s*([^\']+)\s*%\}/).flatten.first + fullpath = template.scan(/\{% extends \'?([\w|\/]+)\'? %\}/).flatten.first if fullpath # inheritance detected - fullpath.gsub!("'", '') return if fullpath == 'parent' self.add_page(fullpath) end From b4f871c5f640466f20ca2d2631f602700b6adf39 Mon Sep 17 00:00:00 2001 From: Dirk Kelly Date: Mon, 7 Mar 2011 19:59:36 +0800 Subject: [PATCH 26/26] support for content_types breaking over multiple lines --- public/stylesheets/admin/menu.css | 30 ++++++++++++++------- public/stylesheets/sass/admin/_helpers.scss | 10 +++++++ public/stylesheets/sass/admin/menu.scss | 22 +++++++++------ 3 files changed, 45 insertions(+), 17 deletions(-) diff --git a/public/stylesheets/admin/menu.css b/public/stylesheets/admin/menu.css index 2a3c63a1..fba1dfe3 100644 --- a/public/stylesheets/admin/menu.css +++ b/public/stylesheets/admin/menu.css @@ -8,7 +8,8 @@ position: relative; top: -1px; z-index: 998; - height: 60px; + min-height: 60px; + width: 950px; margin: 0px; padding: 0 8px; background: transparent url(/images/admin/menu/shadow.png) repeat-y 0 0; @@ -24,12 +25,24 @@ border-top-right-radius: 3px ; -moz-border-radius-top-right: 3px ; -webkit-border-top-right-radius: 3px ; - height: 60px; } + width: 826px; + padding-right: 124px; + padding-top: 8px; + padding-bottom: 8px; + min-height: 44px; } + #submenu > ul:after { + content: "."; + display: block; + height: 0; + clear: both; + visibility: hidden; } #submenu > ul a { text-decoration: none; } #submenu > ul > li { - margin: 15px 7px 0 8px; - float: left; } + margin: 7px 7px 7px 8px; + height: 30px; + float: left; + position: relative; } #submenu > ul > li.hoverable > a span em { display: inline-block; background: transparent url(/images/admin/menu/icons.png) no-repeat 0 -16px; @@ -101,10 +114,9 @@ position: absolute; top: 0px; right: 22px; - height: 60px; + height: 100%; padding-left: 20px; - z-index: 1; - background: transparent url(/images/admin/menu/submenu/action-border.png) repeat-y left 0; } + z-index: 1; } #submenu > .action a { margin-top: 18px; display: inline-block; @@ -136,7 +148,7 @@ border-color: black; } #submenu .popup { position: absolute; - top: 42px; + top: 26px; min-width: 250px; background: #fff; box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5); @@ -311,7 +323,7 @@ body.contents #submenu > ul { background: -moz-linear-gradient(0% 100% 90deg, #212229, #1e1e24); background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#1e1e24), to(#212229)); } body.contents #submenu > .action { - background-image: url(/images/admin/menu/submenu/black-action-border.png) !important; } + background: transparent url(/images/admin/menu/submenu/action-border.png) repeat-y left 0; } #menu li.assets a em { position: relative; diff --git a/public/stylesheets/sass/admin/_helpers.scss b/public/stylesheets/sass/admin/_helpers.scss index c24aeada..278c7fc2 100644 --- a/public/stylesheets/sass/admin/_helpers.scss +++ b/public/stylesheets/sass/admin/_helpers.scss @@ -1,5 +1,15 @@ /* ___ rounded ___ */ +@mixin clearfix { + &:after { + content: "."; + display: block; + height: 0; + clear: both; + visibility: hidden; + }; +} + @mixin rounded($side, $radius: 10px, $important: false) { @if $important == true { $important: !important; } diff --git a/public/stylesheets/sass/admin/menu.scss b/public/stylesheets/sass/admin/menu.scss index 67443840..230bec14 100644 --- a/public/stylesheets/sass/admin/menu.scss +++ b/public/stylesheets/sass/admin/menu.scss @@ -9,7 +9,8 @@ position: relative; top: -1px; z-index: 998; - height: 60px; + min-height: 60px; + width: 950px; margin: 0px; padding: 0 8px; background: transparent url(/images/admin/menu/shadow.png) repeat-y 0 0; @@ -17,16 +18,22 @@ /* ___ submenu items ___ */ & > ul { + @include clearfix; @include reset; border-top: 1px solid rgba(255, 255, 255, 0.4); background: transparent url(/images/admin/menu/submenu/shadow.png) repeat-x 0 0; @include rounded(top-right, 3px); - - height: 60px; + width: 826px; + padding-right: 124px; + padding-top: 8px; + padding-bottom: 8px; + min-height: 44px; & > li { - margin: 15px 7px 0 8px; + margin: 7px 7px 7px 8px; + height: 30px; float: left; + position: relative; &.hoverable > a span { em { @@ -105,10 +112,9 @@ & > .action { @include absolute-position(top, 0px, right, 22px); - height: 60px; + height: 100%; padding-left: 20px; z-index: 1; - background: transparent url(/images/admin/menu/submenu/action-border.png) repeat-y left 0; a { margin-top: 18px; @@ -150,7 +156,7 @@ .popup { position: absolute; - top: 42px; + top: 26px; min-width: 250px; background: #fff; @include box-shadow(0px, 0px, 10px, rgba(0, 0, 0, 0.5)); @@ -253,7 +259,7 @@ } & > .action { - background-image: url(/images/admin/menu/submenu/black-action-border.png) !important; + background: transparent url(/images/admin/menu/submenu/action-border.png) repeat-y left 0; } }