Changeset 5022
- Timestamp:
- 09/05/06 22:28:13 (2 years ago)
- Files:
-
- plugins/simply_helpful/init.rb (modified) (1 diff)
- plugins/simply_helpful/lib/simply_helpful (added)
- plugins/simply_helpful/lib/simply_helpful.rb (added)
- plugins/simply_helpful/lib/simply_helpful/av_extensions.rb (moved) (moved from plugins/simply_helpful/lib/av_extensions.rb) (2 diffs)
- plugins/simply_helpful/lib/simply_helpful/jsg_extensions.rb (moved) (moved from plugins/simply_helpful/lib/jsg_extensions.rb) (1 diff)
- plugins/simply_helpful/lib/simply_helpful/record_identification_helper.rb (moved) (moved from plugins/simply_helpful/lib/record_identification_helper.rb) (1 diff)
- plugins/simply_helpful/lib/simply_helpful/record_identifier.rb (moved) (moved from plugins/simply_helpful/lib/record_identifier.rb) (1 diff)
- plugins/simply_helpful/lib/simply_helpful/record_tag_helper.rb (moved) (moved from plugins/simply_helpful/lib/record_tag_helper.rb) (1 diff)
- plugins/simply_helpful/test/record_identifier_test.rb (added)
- plugins/simply_helpful/test/simply_helpful_test.rb (modified) (1 diff)
- plugins/simply_helpful/test/test_helper.rb (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/simply_helpful/init.rb
r5019 r5022 1 # Include hook code here 2 require 'jsg_extensions' 3 require 'av_extensions' 4 ActionController::Base.helper(RecordIdentificationHelper, RecordTagHelper) 1 require 'simply_helpful' 2 ActionController::Base.helper(SimplyHelpful::RecordIdentificationHelper, SimplyHelpful::RecordTagHelper) plugins/simply_helpful/lib/simply_helpful/av_extensions.rb
r5019 r5022 1 1 module ActionView 2 2 module Partials 3 def render_partial_with_record_iden fification(partial_path, local_assigns = nil, deprecated_local_assigns = nil)3 def render_partial_with_record_identification(partial_path, local_assigns = nil, deprecated_local_assigns = nil) 4 4 if partial_path.is_a?(String) || partial_path.is_a?(Symbol) || partial_path.nil? 5 5 render_partial_without_record_idenfification( 6 6 partial_path, local_assigns, deprecated_local_assigns 7 7 ) 8 elsif partial_path. class.to_s == "Array"8 elsif partial_path.is_a?(Array) 9 9 if partial_path.any? 10 path = SimplyHelpful::RecordIdentifier.partial_path(partial_path.first) 11 collection = partial_path 10 12 render_partial_collection( 11 RecordIdentifier.partial_path(partial_path.first), partial_path, nil, local_assigns.value13 path, collection, nil, local_assigns.value 12 14 ) 13 15 else … … 16 18 else 17 19 render_partial_without_record_idenfification( 18 RecordIdentifier.partial_path(partial_path), local_assigns, deprecated_local_assigns20 SimplyHelpful::RecordIdentifier.partial_path(partial_path), local_assigns, deprecated_local_assigns 19 21 ) 20 22 end 21 23 end 22 23 alias_method_chain :render_partial, :record_idenfification 24 alias_method_chain :render_partial, :record_identification 24 25 end 25 26 end plugins/simply_helpful/lib/simply_helpful/jsg_extensions.rb
r5019 r5022 9 9 JavaScriptElementProxy.new(self, id) 10 10 else 11 JavaScriptElementProxy.new(self, RecordIdentifier.dom_id(id))11 JavaScriptElementProxy.new(self, SimplyHelpful::RecordIdentifier.dom_id(id)) 12 12 end 13 13 end plugins/simply_helpful/lib/simply_helpful/record_identification_helper.rb
r5019 r5022 1 module RecordIdentificationHelper 2 def partial_path(klass) 3 RecordIdentifier.partial_path(klass) 4 end 1 module SimplyHelpful 2 module RecordIdentificationHelper 3 def partial_path(klass) 4 RecordIdentifier.partial_path(klass) 5 end 6 7 def dom_class(record) 8 RecordIdentifier.dom_class(record) 9 end 5 10 6 def dom_class(record) 7 RecordIdentifier.dom_class(record) 8 end 9 10 def dom_id(record) 11 RecordIdentifier.dom_id(record) 11 def dom_id(record) 12 RecordIdentifier.dom_id(record) 13 end 12 14 end 13 15 end plugins/simply_helpful/lib/simply_helpful/record_identifier.rb
r5019 r5022 1 module RecordIdentifier 2 extend self 1 module SimplyHelpful 2 module RecordIdentifier 3 extend self 3 4 4 def partial_path(record_or_class)5 klass = record_or_class.is_a?(Class) ? record_or_class : record_or_class.class6 "#{klass.to_s.downcase.pluralize}/#{klass.to_s.downcase}"7 end5 def partial_path(record_or_class) 6 klass = record_or_class.is_a?(Class) ? record_or_class : record_or_class.class 7 "#{klass.to_s.downcase.pluralize}/#{klass.to_s.downcase}" 8 end 8 9 9 def dom_class(record)10 record.class.to_s.downcase11 end10 def dom_class(record) 11 record.class.to_s.downcase 12 end 12 13 13 def dom_id(record) 14 record.new_record? ? "new_#{dom_class(record)}" : "#{dom_class(record)}_#{record.id}" 14 def dom_id(record, prefix = nil) 15 prefix ||= 'new' unless record.id 16 [prefix, record.class.name.underscore, record.id].compact * '_' 17 end 15 18 end 16 19 end plugins/simply_helpful/lib/simply_helpful/record_tag_helper.rb
r5019 r5022 1 module RecordTagHelper 2 def div_for(record, options = {}) 3 content_tag(:div, capture { yield }, options.merge({ :class => dom_class(record), :id => dom_id(record) })) 4 end 1 module SimplyHelpful 2 module RecordTagHelper 3 def div_for(record, options = {}) 4 content_tag(:div, capture { yield }, options.merge({ :class => dom_class(record), :id => dom_id(record) })) 5 end 6 end 5 7 end plugins/simply_helpful/test/simply_helpful_test.rb
r5019 r5022 1 require 'test/unit'1 require File.dirname(__FILE__) + '/test_helper' 2 2 3 3 class SimplyHelpfulTest < Test::Unit::TestCase 4 # Replace this with your real tests. 5 def test_this_plugin 6 flunk 4 def default_test 7 5 end 8 6 end