Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 373
- Log:
Initial import of Radiant 0.9.1, which is now packaged as a gem. This is an
import of the tagged 0.9.1 source checked out from GitHub, which isn't quite
the same as the gem distribution - but it doesn't seem to be available in an
archived form and the installed gem already has modifications, so this is
the closest I can get.
- Author:
- rool
- Date:
- Mon Mar 21 13:40:05 +0000 2011
- Size:
- 7042 Bytes
1 | class Author < ActiveRecord::Base |
2 | has_many :posts |
3 | has_many :very_special_comments, :through => :posts |
4 | has_many :posts_with_comments, :include => :comments, :class_name => "Post" |
5 | has_many :popular_grouped_posts, :include => :comments, :class_name => "Post", :group => "type", :having => "SUM(comments_count) > 1", :select => "type" |
6 | has_many :posts_with_comments_sorted_by_comment_id, :include => :comments, :class_name => "Post", :order => 'comments.id' |
7 | has_many :posts_sorted_by_id_limited, :class_name => "Post", :order => 'posts.id', :limit => 1 |
8 | has_many :posts_with_categories, :include => :categories, :class_name => "Post" |
9 | has_many :posts_with_comments_and_categories, :include => [ :comments, :categories ], :order => "posts.id", :class_name => "Post" |
10 | has_many :posts_containing_the_letter_a, :class_name => "Post" |
11 | has_many :posts_with_extension, :class_name => "Post" do #, :extend => ProxyTestExtension |
12 | def testing_proxy_owner |
13 | proxy_owner |
14 | end |
15 | def testing_proxy_reflection |
16 | proxy_reflection |
17 | end |
18 | def testing_proxy_target |
19 | proxy_target |
20 | end |
21 | end |
22 | has_one :post_about_thinking, :class_name => 'Post', :conditions => "posts.title like '%thinking%'" |
23 | has_one :post_about_thinking_with_last_comment, :class_name => 'Post', :conditions => "posts.title like '%thinking%'", :include => :last_comment |
24 | has_many :comments, :through => :posts |
25 | has_many :comments_containing_the_letter_e, :through => :posts, :source => :comments |
26 | has_many :comments_with_order_and_conditions, :through => :posts, :source => :comments, :order => 'comments.body', :conditions => "comments.body like 'Thank%'" |
27 | has_many :comments_with_include, :through => :posts, :source => :comments, :include => :post |
28 | |
29 | has_many :thinking_posts, :class_name => 'Post', :conditions => { :title => 'So I was thinking' }, :dependent => :delete_all |
30 | has_many :welcome_posts, :class_name => 'Post', :conditions => { :title => 'Welcome to the weblog' } |
31 | |
32 | has_many :comments_desc, :through => :posts, :source => :comments, :order => 'comments.id DESC' |
33 | has_many :limited_comments, :through => :posts, :source => :comments, :limit => 1 |
34 | has_many :funky_comments, :through => :posts, :source => :comments |
35 | has_many :ordered_uniq_comments, :through => :posts, :source => :comments, :uniq => true, :order => 'comments.id' |
36 | has_many :ordered_uniq_comments_desc, :through => :posts, :source => :comments, :uniq => true, :order => 'comments.id DESC' |
37 | has_many :readonly_comments, :through => :posts, :source => :comments, :readonly => true |
38 | |
39 | has_many :special_posts |
40 | has_many :special_post_comments, :through => :special_posts, :source => :comments |
41 | |
42 | has_many :sti_posts, :class_name => 'StiPost' |
43 | has_many :sti_post_comments, :through => :sti_posts, :source => :comments |
44 | |
45 | has_many :special_nonexistant_posts, :class_name => "SpecialPost", :conditions => "posts.body = 'nonexistant'" |
46 | has_many :special_nonexistant_post_comments, :through => :special_nonexistant_posts, :source => :comments, :conditions => "comments.post_id = 0" |
47 | has_many :nonexistant_comments, :through => :posts |
48 | |
49 | has_many :hello_posts, :class_name => "Post", :conditions => "posts.body = 'hello'" |
50 | has_many :hello_post_comments, :through => :hello_posts, :source => :comments |
51 | has_many :posts_with_no_comments, :class_name => 'Post', :conditions => 'comments.id is null', :include => :comments |
52 | |
53 | has_many :hello_posts_with_hash_conditions, :class_name => "Post", |
54 | :conditions => {:body => 'hello'} |
55 | has_many :hello_post_comments_with_hash_conditions, :through => |
56 | :hello_posts_with_hash_conditions, :source => :comments |
57 | |
58 | has_many :other_posts, :class_name => "Post" |
59 | has_many :posts_with_callbacks, :class_name => "Post", :before_add => :log_before_adding, |
60 | :after_add => :log_after_adding, |
61 | :before_remove => :log_before_removing, |
62 | :after_remove => :log_after_removing |
63 | has_many :posts_with_proc_callbacks, :class_name => "Post", |
64 | :before_add => Proc.new {|o, r| o.post_log << "before_adding#{r.id || '<new>'}"}, |
65 | :after_add => Proc.new {|o, r| o.post_log << "after_adding#{r.id || '<new>'}"}, |
66 | :before_remove => Proc.new {|o, r| o.post_log << "before_removing#{r.id}"}, |
67 | :after_remove => Proc.new {|o, r| o.post_log << "after_removing#{r.id}"} |
68 | has_many :posts_with_multiple_callbacks, :class_name => "Post", |
69 | :before_add => [:log_before_adding, Proc.new {|o, r| o.post_log << "before_adding_proc#{r.id || '<new>'}"}], |
70 | :after_add => [:log_after_adding, Proc.new {|o, r| o.post_log << "after_adding_proc#{r.id || '<new>'}"}] |
71 | has_many :unchangable_posts, :class_name => "Post", :before_add => :raise_exception, :after_add => :log_after_adding |
72 | |
73 | has_many :categorizations |
74 | has_many :categories, :through => :categorizations |
75 | |
76 | has_many :categories_like_general, :through => :categorizations, :source => :category, :class_name => 'Category', :conditions => { :name => 'General' } |
77 | |
78 | has_many :categorized_posts, :through => :categorizations, :source => :post |
79 | has_many :unique_categorized_posts, :through => :categorizations, :source => :post, :uniq => true |
80 | |
81 | has_many :nothings, :through => :kateggorisatons, :class_name => 'Category' |
82 | |
83 | has_many :author_favorites |
84 | has_many :favorite_authors, :through => :author_favorites, :order => 'name' |
85 | |
86 | has_many :tagging, :through => :posts # through polymorphic has_one |
87 | has_many :taggings, :through => :posts, :source => :taggings # through polymorphic has_many |
88 | has_many :tags, :through => :posts # through has_many :through |
89 | has_many :post_categories, :through => :posts, :source => :categories |
90 | |
91 | has_many :event_authors |
92 | has_many :events, :through => :event_authors |
93 | |
94 | has_one :essay, :primary_key => :name, :as => :writer |
95 | |
96 | belongs_to :author_address, :dependent => :destroy |
97 | belongs_to :author_address_extra, :dependent => :delete, :class_name => "AuthorAddress" |
98 | |
99 | attr_accessor :post_log |
100 | |
101 | def after_initialize |
102 | @post_log = [] |
103 | end |
104 | |
105 | def label |
106 | "#{id}-#{name}" |
107 | end |
108 | |
109 | private |
110 | def log_before_adding(object) |
111 | @post_log << "before_adding#{object.id || '<new>'}" |
112 | end |
113 | |
114 | def log_after_adding(object) |
115 | @post_log << "after_adding#{object.id}" |
116 | end |
117 | |
118 | def log_before_removing(object) |
119 | @post_log << "before_removing#{object.id}" |
120 | end |
121 | |
122 | def log_after_removing(object) |
123 | @post_log << "after_removing#{object.id}" |
124 | end |
125 | |
126 | def raise_exception(object) |
127 | raise Exception.new("You can't add a post") |
128 | end |
129 | end |
130 | |
131 | class AuthorAddress < ActiveRecord::Base |
132 | has_one :author |
133 | |
134 | def self.destroyed_author_address_ids |
135 | @destroyed_author_address_ids ||= Hash.new { |h,k| h[k] = [] } |
136 | end |
137 | |
138 | before_destroy do |author_address| |
139 | if author_address.author |
140 | AuthorAddress.destroyed_author_address_ids[author_address.author.id] << author_address.id |
141 | end |
142 | true |
143 | end |
144 | end |
145 | |
146 | class AuthorFavorite < ActiveRecord::Base |
147 | belongs_to :author |
148 | belongs_to :favorite_author, :class_name => "Author" |
149 | end |