Skip to content

Commit

Permalink
Merge branch 'rel-0.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
technoweenie committed Feb 13, 2008
2 parents 1cd5005 + b9b0761 commit 2772ec1
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 18 deletions.
18 changes: 9 additions & 9 deletions CHANGELOG
Expand Up @@ -2,9 +2,9 @@

* Experimental comment preview. [court3nay]

* Add multi-site admin interface [Vincent, j2m]
* Add multi-site admin interface. [Vincent, j2m]

* Update Wordpress converter to support Wordpress 2.3+ [Aubrey]
* Update Wordpress converter to support Wordpress 2.3+. [Aubrey]

* refactor so that admin/comments is more restful, allow inline comment editing in the admin. [court3nay]

Expand All @@ -23,23 +23,23 @@
# use this order: :text, :title, :id, :class, :rel
link_to_article article, "click here", "this article", "article-1", "articles", "whatever-rel-means"

* encode search/tag urls properly [rob-twf]
* encode search/tag urls properly. [rob-twf]

* update article forms to explain new tag syntax (comma and space delimited tags) [xavier, rick]

* start converting tests to rspec
* start converting tests to rspec.

* tweak mephisto_init to support the new ActionController::Dispatcher class. [Rob Anderton]

* Don't generate an article event for unversioned changes. [Marcus Brito]

* Switch to will_paginate plugin [Mislav]
* Switch to will_paginate plugin. [Mislav]

* unit test fixes for those not using mysql or psql [Mislav]
* unit test fixes for those not using mysql or psql. [Mislav]

* add comment moderation links to the overview [court3nay]
* add comment moderation links to the overview. [court3nay]

* convert tests to use test/spec instead of simply bdd [Chris McGrath]
* convert tests to use test/spec instead of simply bdd. [Chris McGrath]

* move xmlrpc stuff to plugin. rails doesn't include AWS anymore. May need some simple autodetection so the plugin just prints a warning if AWS isn't found.

Expand All @@ -49,7 +49,7 @@

* Fix controllers so include_into works with them.

* Change plugin class/module to Mephisto::Plugin and Mephisto::Plugins. Sorry for the breakage (still technically experimental!)
* Change plugin class/module to Mephisto::Plugin and Mephisto::Plugins. Sorry for the breakage (still technically experimental!).

* Fix admin overview date timezone. [Ben Wyrosdick]

Expand Down
8 changes: 4 additions & 4 deletions app/views/admin/articles/_page_nav.rhtml
Expand Up @@ -38,23 +38,23 @@
<li><a href="#">&nbsp;</a></li>
</ul>
<ul id="attributes">
<% if @article && controller.controller_name == 'articles' && controller.action_name == 'edit' %>
<% if @article && controller.controller_name == 'articles' && controller.action_name == 'edit' -%>
<li><label for="search">Revision:</label></li>
<li>
<select name="filter" id="revisionnum">
<option value="0">Newest</option>
<%= options_from_collection_for_select @article.versions.reverse, :version, :version, params[:version].to_i %>
</select>
</li>
<% end %>
<% end -%>
<% if controller.controller_name == 'comments' && controller.action_name == 'index' -%>
<li><label for="comments_view">Show comments:</label></li>
<li>
<select id="comments-view">
<%= options_for_select ['All', 'Unapproved', 'Approved'], params[:filter].to_s.humanize %>
</select>
</li>
<% end %>
<% end -%>
</ul>
</div>
<% end unless @article.new_record? && @article.comments.empty? -%>
<% end unless @article && @article.new_record? && @article.comments.size == 0 -%>
38 changes: 33 additions & 5 deletions vendor/plugins/aaa/init.rb
Expand Up @@ -3,26 +3,54 @@

Module.class_eval do
# A hash that maps Class names to an array of Modules to mix in when the class is instantiated.
@@class_mixins = {}
@@class_mixins = {} unless defined?(@@class_mixins)
mattr_reader :class_mixins

# Specifies that this module should be included into the given classes when they are instantiated.
#
# module FooMethods
# include_into "Foo", "Bar"
# end
#
# You can also specify a hash to have your module's methods alias_method_chained to the target
# class' methods.
#
# module FooMethods
# include_into "Foo", :method => :feature
# end
#
# This will alias Foo#method to the newly included FooMethods#method_with_feature. The former
# method Foo#method will continue to be available as Foo#method_without_feature.
#
def include_into(*klasses)
klasses.flatten!
aliases = klasses.last.is_a?(Hash) ? klasses.pop : {}
klasses.each do |klass|
(@@class_mixins[klass] ||= []) << name.to_s
(@@class_mixins[klass] ||= []) << [name.to_s, aliases]
@@class_mixins[klass].uniq!
end
end

# add any class mixins that have been registered for this class
def auto_include!
mixins = @@class_mixins[name]
send(:include, *mixins.collect { |name| name.constantize }) if mixins
if mixins = @@class_mixins[name]
mixins.each do |name, aliases|
include name.constantize
aliases.each { |args| alias_chain *args }
end
end
end

def alias_chain(target, feature)
(class << self; self end).class_eval <<-EOC, __FILE__, __LINE__
def method_added_with_#{target}_#{feature}(method)
if method == :#{target} && !method_defined?(:#{target}_without_#{feature})
alias_method_chain :#{target}, :#{feature}
end
method_added_without_#{target}_#{feature}(method)
end
alias_method_chain :method_added, :#{target}_#{feature}
EOC
end
end

Expand Down
45 changes: 45 additions & 0 deletions vendor/plugins/aaa/test/include_into_test.rb
@@ -0,0 +1,45 @@
ENV['RAILS_ENV'] = 'test'
RAILS_ROOT = File.join(File.dirname(__FILE__), '../../../../')

require 'rubygems'
require 'active_support'
require 'test/unit'

require File.join(File.dirname(__FILE__), '..', 'init.rb')

module Chocolate
include_into 'Cookie', 'Coffee', :taste => :chocolate
def taste_with_chocolate; "#{self.class.name} with chocolate!" end
end

module Latte
include_into 'Coffee', 'Chai'
end

class Cookie
def taste; "just a #{self.class.name}" end
end

class Coffee
def taste; "just a #{self.class.name}" end
end

class Chai
end

class IncludeIntoTest < Test::Unit::TestCase
def test_module_should_be_included_to_given_classes
assert Cookie.included_modules.include?(Chocolate)
assert Coffee.included_modules.include?(Chocolate)
end

def test_methods_should_be_alias_chained_in_given_classes
assert_equal 'Cookie with chocolate!', Cookie.new.taste
assert_equal 'Coffee with chocolate!', Coffee.new.taste
end

def test_should_work_without_alias_option
assert Coffee.included_modules.include?(Latte)
assert Chai.included_modules.include?(Latte)
end
end

0 comments on commit 2772ec1

Please sign in to comment.