clean code + use the last version of locomotive liquid

This commit is contained in:
dinedine 2010-09-01 00:04:21 +02:00
parent 35b4e5358c
commit d2ca6254b3
5 changed files with 12 additions and 27 deletions

View File

@ -3,8 +3,8 @@ source 'http://rubygems.org'
gem 'rails', '3.0.0.rc'
gem 'liquid', :path => '../gems/liquid' # local
# gem 'liquid', :git => 'git://github.com/locomotivecms/liquid.git', :ref => '9ec570927f5281e1f397'
# gem 'liquid', :path => '../gems/liquid' # local
gem 'liquid', :git => 'git://github.com/locomotivecms/liquid.git', :ref => 'b03cdc289ac36c339545'
gem 'bson_ext', '1.0.4'
gem 'mongoid', '2.0.0.beta.16'

View File

@ -11,6 +11,13 @@ GIT
specs:
custom_fields (0.0.0.1)
GIT
remote: git://github.com/locomotivecms/liquid.git
revision: b03cdc2
ref: b03cdc289ac36c339545
specs:
liquid (2.1.3)
GIT
remote: http://github.com/ianwhite/pickle.git
revision: 65ba8b7
@ -21,11 +28,6 @@ GIT
rspec (>= 1.3)
yard
PATH
remote: /Users/didier/Desktop/NoCoffee/LocomotiveCMS/gems/liquid
specs:
liquid (2.1.3)
GEM
remote: http://rubygems.org/
specs:
@ -117,7 +119,7 @@ GEM
growl-glue (1.0.7)
haml (3.0.15)
has_scope (0.5.0)
heroku (1.9.13)
heroku (1.9.14)
json_pure (>= 1.2.0, < 1.5.0)
launchy (~> 0.3.2)
rest-client (~> 1.4.0)
@ -167,7 +169,7 @@ GEM
pickle (>= 0.3.0)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.12)
rack-mount (0.6.13)
rack (>= 1.0.0)
rack-test (0.5.4)
rack (>= 1.0)

View File

@ -3,10 +3,8 @@ class EditableElement
include Mongoid::Document
## fields ##
# field :kind
field :slug
field :block
# field :content
field :default_content
field :hint
field :disabled, :type => Boolean, :default => false
@ -20,12 +18,4 @@ class EditableElement
## methods ##
# def content
# self.read_attribute(:content).blank? ? self.default_content : self.read_attribute(:content)
# end
#
# def short_text?; self._type == 'EditableShortText'; end
#
# def long_text?; self._type == 'EditableLongText'; end
end

View File

@ -62,8 +62,6 @@ module Models
def merge_editable_elements_from_page(source)
source.editable_elements.each do |el|
puts "\t*** merging #{el.class} / #{el.slug} / #{el.block} / #{el.disabled?} / #{el.from_parent?}"
next if el.disabled?
existing_el = self.find_editable_element(el.block, el.slug)
@ -72,8 +70,7 @@ module Models
new_attributes = el.attributes.merge(:from_parent => true)
new_attributes[:default_content] = el.content
foo = self.editable_elements.build(new_attributes, el.class)
puts "\t\t*** building #{foo.inspect} / #{foo.valid?} / #{foo.errors.full_messages.inspect}"
self.editable_elements.build(new_attributes, el.class)
else
existing_el.attributes = { :disabled => false, :default_content => el.content }
end
@ -83,8 +80,6 @@ module Models
def remove_disabled_editable_elements
return unless self.editable_elements.any? { |el| el.disabled? }
puts "*** removing #{self.editable_elements.find_all { |el| el.disabled? }.size} elements"
# super fast way to remove useless elements all in once (TODO callbacks)
self.collection.update(self._selector, '$pull' => { 'editable_elements' => { 'disabled' => true } })
end

View File

@ -93,11 +93,9 @@ module Models
end
direct_descendants.each do |page|
puts "*** #{page.fullpath} descendant of #{self.fullpath}"
page.send(:_parse_and_serialize_template, { :cached_parent => self, :cached_pages => cached })
page.send(:_update_direct_template_descendants, template_descendants, cached)
puts "-------- done -----------"
end
end