Changeset 503
- Timestamp:
- 2007-05-10 13:35:42 (2 years ago)
- Files:
-
- trunk/TODO (modified) (1 diff)
- trunk/app/models/version.rb (modified) (2 diffs)
- trunk/config/version.rb (modified) (1 diff)
- trunk/db/migrate/000_zena/015_add_dyn_attributes.rb (modified) (1 diff)
- trunk/db/schema.rb (modified) (2 diffs)
- trunk/lib/multiversion.rb (modified) (2 diffs)
- trunk/lib/parser/lib/rules/zena.rb (modified) (1 diff)
- trunk/lib/parser/test/zafu.yml (modified) (1 diff)
- trunk/test/helpers/basic.yml (modified) (1 diff)
- trunk/test/helpers/zafu_ajax.yml (modified) (1 diff)
- trunk/test/helpers/zena_parser_test.rb (modified) (1 diff)
- trunk/test/unit/dyn_attributes_test.rb (added)
- trunk/test/unit/multiversion_test.rb (modified) (1 diff)
- trunk/test/unit/version_test.rb (modified) (1 diff)
- trunk/vendor/plugins/ar_mysql_full_text/lib/ar_mysql_full_text.rb (modified) (1 diff)
- trunk/vendor/plugins/dyn_attributes (added)
- trunk/vendor/plugins/dyn_attributes/MIT-LICENSE (added)
- trunk/vendor/plugins/dyn_attributes/README (added)
- trunk/vendor/plugins/dyn_attributes/init.rb (added)
- trunk/vendor/plugins/dyn_attributes/lib (added)
- trunk/vendor/plugins/dyn_attributes/lib/dyn_attributes.rb (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/TODO
r472 r503 1 1 == MOST IMPORTANT: 2 prepare a boot script for zena so it is restarted on hardware reboot : 3 'send a mail' 4 rm -rf log/mongrel.*.pid 5 mongrel_rails cluster::start 6 2 * use connection.quote !!! 7 3 8 4 == Todo trunk/app/models/version.rb
r502 r503 37 37 validate_on_update :can_update_content 38 38 after_save :save_content 39 39 uses_dynamic_attributes 40 40 # not tested belongs_to :comment_group, :class_name=>'Group', :foreign_key=>'cgroup_id' 41 41 # not tested has_many :comments, :order=>'created_at' … … 119 119 def content_class 120 120 nil 121 end 122 123 def clone 124 obj = super 125 # clone dynamic attributes 126 obj.dyn = self.dyn 127 obj 121 128 end 122 129 trunk/config/version.rb
r479 r503 3 3 MAJOR = 0 4 4 MINOR = 8 5 TINY = 15 TINY = 2 6 6 7 7 STRING = [MAJOR, MINOR, TINY].join('.') trunk/db/migrate/000_zena/015_add_dyn_attributes.rb
r502 r503 7 7 t.column 'value', :text 8 8 end 9 add_index 'dyn_attributes', 'owner_id' 10 add_index 'dyn_attributes', 'owner_table' 9 11 end 10 12 11 13 def self.down 14 remove_index 'dyn_attributes', 'owner_id' 15 remove_index 'dyn_attributes', 'owner_table' 12 16 drop_table 'dyn_attributes' 13 17 end trunk/db/schema.rb
r486 r503 83 83 t.column "site_id", :integer 84 84 end 85 86 create_table "dyn_attributes", :force => true do |t| 87 t.column "owner_id", :integer 88 t.column "owner_table", :string 89 t.column "key", :string 90 t.column "value", :text 91 end 92 93 execute "ALTER TABLE dyn_attributes ENGINE = MyISAM" 94 execute "CREATE INDEX index_dyn_attributes_on_owner_id ON dyn_attributes (owner_id)" 95 execute "ALTER TABLE dyn_attributes ENGINE = MyISAM" 96 execute "CREATE INDEX index_dyn_attributes_on_owner_table ON dyn_attributes (owner_table)" 85 97 86 98 create_table "groups", :force => true do |t| … … 164 176 end 165 177 178 create_table "tmp", :id => false, :force => true do |t| 179 t.column "a", :string, :limit => 50 180 t.column "b", :string, :limit => 50 181 end 182 166 183 create_table "trans_phrases", :force => true do |t| 167 184 t.column "phrase", :string, :limit => 100, :default => "", :null => false trunk/lib/multiversion.rb
r502 r503 381 381 # Any attribute starting with 'c_' belongs to the 'version' or 'redaction' content 382 382 def method_missing(meth, *args) 383 if meth.to_s =~ /^(v_|c_ )(([\w_\?]+)(=?))$/383 if meth.to_s =~ /^(v_|c_|d_)(([\w_\?]+)(=?))$/ 384 384 target = $1 385 method = $2 .to_sym386 value = $3 .to_sym385 method = $2 386 value = $3 387 387 mode = $4 388 388 if mode == '=' … … 408 408 end 409 409 elsif target == 'd_' 410 recipient.dyn[method ] = args[0]410 recipient.dyn[method[0..-2]] = args[0] 411 411 else 412 412 begin trunk/lib/parser/lib/rules/zena.rb
r501 r503 497 497 render_html_tag(expand_with) 498 498 else 499 add_params(res, id_hash) 500 end 499 add_params(expand_with, id_hash) 500 end 501 else 502 # error, no list 503 "<span class='parser_error'>each not in list context</span>" 501 504 end 502 505 end trunk/lib/parser/test/zafu.yml
r497 r503 241 241 names: 242 242 src: "<p do='void' name='root'><p do='inspect' name='first'/><p do='inspect' name='second'/></p>" 243 res: "<p>[inspect { > :name=>'root/first'}]<p/>[/inspect][inspect{> :name=>'root/second'}]<p/>[/inspect]</p>"243 res: "<p>[inspect {= :name=>'first'} {> :name=>'root/first'}]<p/>[/inspect][inspect {= :name=>'second'} {> :name=>'root/second'}]<p/>[/inspect]</p>" 244 244 245 245 default_tag: trunk/test/helpers/basic.yml
r498 r503 287 287 src: "<z:children><z:each join=', '><z:show attr='name'/></z:each></z:children>" 288 288 res: "bird, flower" 289 290 edit_not_each:291 src: "<li class='blah'>this is a post <z:edit>edit post</z:edit></li>"292 tem: "/<li class='blah'>this is a post </li>/"293 294 edit_each_no_form:295 src: "<z:each><li>blah <z:edit>do this and that</z:edit></li>"296 tem: "/<li>blah </li>"297 298 each_add_with_form:299 context:300 node: 'wiki'301 src: "<z:children><z:each><li do='show' attr='name'>blah</li>\n</z:each><z:add><li>add new</li></z:add><z:form><li><form>this is the form</form></li></z:form></z:children>"302 res: "/<li>bird.*<li>flower.*<li.*list_add.*list_form.*toggle.*<li .*list_form.*style.*none.*Ajax.Request.*input type='hidden' name='template_url' value='/each/add/with/form/list'/"303 304 each_edit_with_form:305 context:306 node: 'wiki'307 src: "<z:children><z:each><li><z:show attr='name'>blah</z:show> <z:edit>edit</z:edit></li>\n</z:each><z:form><li><form>this is the form</form></li></z:form></z:children>"308 res: "/<li id='/each/edit/with/form/list30'>bird <a href=\"#\" onclick=\"new Ajax.Request\('/nodes/30/edit\?template_url=%2Feach%2Fedit%2Fwith%2Fform%2Flist/"309 289 310 290 set_attribute: trunk/test/helpers/zafu_ajax.yml
r501 r503 9 9 tem: "<span id='/show/edit/list_name<%= @node[:zip] %>'><%= link_to_remote(@node.name, :url => edit_node_path(@node[:zip]) + \"?attribute=name&identifier=%2Fshow%2Fedit%2Flist_name#{@node[:zip]}\", :method => :get) %></span>" 10 10 res: "/span id='/show/edit/list_name22'>.*Ajax\.Request\('/nodes/22/edit\?attribute=name/" 11 12 edit_not_each: 13 src: "<li class='blah'>this is a post <z:edit>edit post</z:edit></li>" 14 tem: "/<li class='blah'>this is a post </li>/" 15 16 edit_each_no_form: 17 src: "<z:children><li do='each'>blah <z:edit>do this and that</z:edit></li></z:children>" 18 tem: "/<li>blah </li>/" 19 20 each_add_with_form: 21 context: 22 node: 'wiki' 23 src: "<z:children><z:each><li do='show' attr='name'>blah</li>\n</z:each><z:add><li>add new</li></z:add><z:form><li><form>this is the form</form></li></z:form></z:children>" 24 res: "/<li.*list30.*>bird.*<li.*list31.*>flower.*<li.*list_add.*list_form.*toggle.*<li .*list_form.*style.*none.*Ajax.Request.*input type='hidden' name='template_url' value='/each/add/with/form/list'/" 25 26 each_edit_with_form: 27 context: 28 node: 'wiki' 29 src: "<z:children><z:each><li><z:show attr='name'>blah</z:show> <z:edit>edit</z:edit></li>\n</z:each><z:form><li><form>this is the form</form></li></z:form></z:children>" 30 res: "/<li id='/each/edit/with/form/list30'>bird <a href=\"#\" onclick=\"new Ajax.Request\('/nodes/30/edit\?template_url=%2Feach%2Fedit%2Fwith%2Fform%2Flist/" trunk/test/helpers/zena_parser_test.rb
r500 r503 9 9 10 10 def test_single 11 do_test('zafu_ajax', ' show_edit')11 do_test('zafu_ajax', 'edit_each_no_form') 12 12 end 13 13 trunk/test/unit/multiversion_test.rb
r495 r503 575 575 assert_equal 1, trad.size 576 576 end 577 578 def test_dynamic_attributes 579 login(:lion) 580 node = secure(Node) { nodes(:status) } 581 node.d_bolo = 'spaghetti bolognese' 582 assert node.save, "Can save node" 583 584 # reload 585 node = secure(Node) { nodes(:status) } 586 assert_equal 'spaghetti bolognese', node.d_bolo 587 end 577 588 end trunk/test/unit/version_test.rb
r484 r503 146 146 end 147 147 148 def test_dynamic_attributes 149 login(:tiger) 150 node = secure(Node) { nodes(:status) } 151 version = node.send(:redaction) 152 assert_nothing_raised { version.dyn['zucchini'] = 'courgettes' } 153 assert_nothing_raised { version.d_zucchini = 'courgettes' } 154 assert_equal 'courgettes', version.d_zucchini 155 assert node.save 156 157 node = secure(Node) { nodes(:status) } 158 version = node.version 159 assert_equal 'courgettes', version.d_zucchini 160 end 161 162 def test_clone 163 login(:tiger) 164 node = secure(Node) { nodes(:status) } 165 assert node.update_attributes(:d_whatever => 'no idea') 166 assert_equal 'no idea', node.d_whatever 167 version1_id = node.version[:id] 168 assert node.publish 169 170 node = secure(Node) { nodes(:status) } 171 assert node.update_attributes(:d_other => 'funny') 172 version2_id = node.version[:id] 173 assert_not_equal version1_id, version2_id 174 assert_equal 'no idea', node.d_whatever 175 assert_equal 'funny', node.d_other 176 end 148 177 end trunk/vendor/plugins/ar_mysql_full_text/lib/ar_mysql_full_text.rb
r455 r503 51 51 next if row[2] == "PRIMARY" # skip the primary key 52 52 current_index = row[2] 53 indexes << MySQLIndexDefinition.new(row[0], row[2], row[1] == "0", [], row[10]) 53 index_type = row[10] 54 index_type = '' if index_type == 'BTREE' 55 indexes << MySQLIndexDefinition.new(row[0], row[2], row[1] == "0", [], index_type) 54 56 end 55 57
