From zaydana at gmail.com Wed May 2 09:44:37 2007 From: zaydana at gmail.com (James Nelson) Date: Wed, 2 May 2007 21:44:37 +0800 Subject: [typo] edge rails fix Message-ID: <6e69c7930705020644x5f161499v99aae49101a3a88b@mail.gmail.com> There was a problem when running in edge rails, due to the localization plugin occuring twice in environment.rb. The fix was to change line 21 in environment.rb from : config.plugins.push("#{dir}") if File.directory?("#{RAILS_ROOT}/vendor/plugins/#{dir}/lib") to: config.plugins.push("#{dir}") if (File.directory?("#{RAILS_ROOT}/vendor/plugins/#{dir}/lib") && dir != 'localization') For the record, i'm using typo 4.1. -- - James -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/typo-list/attachments/20070502/5323488f/attachment.html From zaydana at gmail.com Wed May 2 10:36:38 2007 From: zaydana at gmail.com (James Nelson) Date: Wed, 2 May 2007 22:36:38 +0800 Subject: [typo] more edge rails compatability Message-ID: <6e69c7930705020736t11e52a56x2399ca57833889b4@mail.gmail.com> in theme_helper.rb, line 17 (in typo 4.1), @base_path needs to be replaced with @view_paths[0] I don't know if this is the best way to do it, but it works. -- - James -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/typo-list/attachments/20070502/17584a19/attachment-0001.html From zaydana at gmail.com Fri May 4 15:12:45 2007 From: zaydana at gmail.com (James Nelson) Date: Sat, 5 May 2007 03:12:45 +0800 Subject: [typo] Audioscrobbler plugin Message-ID: <6e69c7930705041212o3b2ae2fckb0336e540c497f7f@mail.gmail.com> Hi people I've been trying for a while now to get the audioscrobbler plugin to work with the new audioscrobbler feeds, but without much success. My problem is mostly that I can't seem to figure out how the plugin system works. For a start, any RAILS_DEFAULT_LOGGER call I put in the audioscrobbler plugin code under lib in the plugin directory (or in init.rb) doesn't seem to get called. Its like the actual plugin code isn't being loaded. However, the actual view is appearing (empty) in my application. Any ideas? -- - James -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/typo-list/attachments/20070505/463906d9/attachment.html From pdcawley at bofh.org.uk Sat May 5 02:30:17 2007 From: pdcawley at bofh.org.uk (Piers Cawley) Date: Sat, 05 May 2007 07:30:17 +0100 Subject: [typo] more edge rails compatability In-Reply-To: <6e69c7930705020736t11e52a56x2399ca57833889b4@mail.gmail.com> (James Nelson's message of "Wed, 2 May 2007 22:36:38 +0800") References: <6e69c7930705020736t11e52a56x2399ca57833889b4@mail.gmail.com> Message-ID: "James Nelson" writes: > in theme_helper.rb, line 17 (in typo 4.1), @base_path needs to be replaced > with @view_paths[0] > > I don't know if this is the best way to do it, but it works. Does it still work with 1.2.3 though? Or are we going to have another bunch of 'big bang' type changes when the edge becomes the release? -- Piers Cawley http://www.bofh.org.uk/ From zaydana at gmail.com Sat May 5 03:10:27 2007 From: zaydana at gmail.com (James Nelson) Date: Sat, 5 May 2007 15:10:27 +0800 Subject: [typo] more edge rails compatability In-Reply-To: References: <6e69c7930705020736t11e52a56x2399ca57833889b4@mail.gmail.com> Message-ID: <6e69c7930705050010y1740042eoa3ff7f49fd375c9f@mail.gmail.com> Well, The first one I posted, which can't really be applied to typo trunk because it has already changed since the last release, will be fine on the current rails version. Basically you just need to make sure the same plugin isn't added to the plugin list more than once. @base_path to @view_paths[0]e however won't work with 1.2.3. I wonder tho if you could make it work in either by checking which variable exists... On 5/5/07, Piers Cawley wrote: > > "James Nelson" writes: > > > in theme_helper.rb, line 17 (in typo 4.1), @base_path needs to be > replaced > > with @view_paths[0] > > > > I don't know if this is the best way to do it, but it works. > > Does it still work with 1.2.3 though? Or are we going to have another > bunch of 'big bang' type changes when the edge becomes the release? > > -- > Piers Cawley > http://www.bofh.org.uk/ > _______________________________________________ > Typo-list mailing list > Typo-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/typo-list > -- - James -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/typo-list/attachments/20070505/32914196/attachment.html From alxx at indigenious.ro Sat May 5 11:41:34 2007 From: alxx at indigenious.ro (Alex Deva) Date: Sat, 5 May 2007 18:41:34 +0300 Subject: [typo] localization in general, Romanian localization file Message-ID: <221724F1-C6FE-44A4-87AE-5BDF274FCA56@indigenious.ro> Hi, A. I'm not sure who to tell about this, but I've created a localization file in Romanian, and I'd like to make it available for inclusion in the next release. Will an administrator tell me where to send my lang/ro_RO.rb please? :) Incidentally, I've also fixed a few other files whose strings weren't localized. At the time I'm writing this mail, they are: vendor/plugins/xml_sidebar/views/content.rhtml vendor/plugins/category_sidebar/views/content.rhtml app/helpers/articles_helper.rb views/shared/_search.rhtml I'll keep on patching them. If anyone's interested, I can make them available too. B. Another thing which is, in my opinion, not very nice is that there are some Javascript strings which can't easily be localized using the _() notation. Among others, that's why you'll always see "x hours ago" in English, regardless of your configured language. To fix this, I've done the following 5 steps: 1. Patched localization.rb by adding: def self.all_keys @@l10s[lang].keys end 2. Added a method in articles_controller.rb: def localized_js # We only retrieve translations which have to do with the Javascript strings; we don't want to overload the browser. js_content = Localization.all_keys.collect { |key| if key =~ / ^js_(.+)/ ; $1 end }.compact render :content_type => 'text/javascript', :text => 'var LocalizedStrings = {' + js_content.collect { |key| lkey="js_#{key}"; "\"#{key}\" : \"#{_(lkey)}\"" }.join(', ') + '} String.prototype.localize = function() { var s; if(LocalizedStrings && (s=LocalizedStrings[this]) ) return s; return this; }' end 3. Added a line in the default.rhtml of the active theme (maybe there's a better place for this, but I couldn't find it yet): 4. Added translations in the file like this: l.store 'js_hours', 'ore' 5. In all Javascript code, I replaced strings like this: Before: "hours" After: "js_hours".localize() C. In Romanian (and other languages), words used to express time difference from now (like 'ago' and 'from now') prepend the numeral, contrary to the English rules. That is why I also had to change some logic in the function get_local_time_for_date() (file typo.js) and translate 'ago' and 'from now' as the empty string. That's it for now. Sorry for sending all this in an email. If an admin feels I should be submitting these as patches, please tell me how. I've only been using Typo for a few hours. Thanks! Alex Deva Indigenious Development www.indigenious.ro -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/typo-list/attachments/20070505/e5d58965/attachment.html From pdcawley at bofh.org.uk Sun May 6 05:44:07 2007 From: pdcawley at bofh.org.uk (Piers Cawley) Date: Sun, 06 May 2007 10:44:07 +0100 Subject: [typo] States! Message-ID: I have, in my local directory a rewrite of the whole ContentState debacle. The State pattern is definitely the way to go for handling publication state; dealing with the kind of tangled conditional logic that we'd have to replace the state objects with gives me the heebie jeebies. However, as I'm sure anyone who's looked at the existing code will agree, what we have good be a good deal better. The problem is that I got seduced by the (oh so handy but not quite what I need) existence of ActiveRecord::Base.composed_of and instead of writing my own class method to handle marshalling state objects to and from the database, I used what Rails provided. When you find yourself overriding 'new', it's probably a good time to take a good hard think about what you're trying to achieve. Anyhoo. A few days ago I was taking part in a discussion about eliminating conditional code on a blog[1] and I found myself sketching a rather nicer way of setting up state objects. So, I've implemented it in typo and I must say I'm rather pleased with it - I expect to be committing it soon, once I've given it a more comprehensive test. Here's a taster of the new style: class Article self.has_state :state, :valid_states => [:new, :draft, :just_published, :published, :publication_pending, :just_withdrawn, :withdrawn] :handles => [:before_save, :after_save, :withdraw, :published=] module States class New < State def before_save content.state = :draft end def published=(boolean) return if boolean.nil? content.state = boolean ? :just_published : :draft end end class JustPublished < State def enter_hook class << content; self; end.after_save {|content| content.send_pings} content.state = :published end end class Published < State def enter_hook content[:published] = true content[:published_at] ||= Time.now end def withdraw content.state = :just_withdrawn end end ... end include States The has_state method deals with all the composed_of type ugliness and setting up instantiation of state objects and method delgation, and we can get rid of nasties like ContentState::Factory, which can only be a good thing. 1. http://giantrobots.thoughtbot.com/2007/5/1/coding-without-ifs -- Piers Cawley http://www.bofh.org.uk/ From neuro at 7el.net Sun May 6 06:21:16 2007 From: neuro at 7el.net (Frederic de Villamil) Date: Sun, 6 May 2007 12:21:16 +0200 Subject: [typo] localization in general, Romanian localization file In-Reply-To: <221724F1-C6FE-44A4-87AE-5BDF274FCA56@indigenious.ro> References: <221724F1-C6FE-44A4-87AE-5BDF274FCA56@indigenious.ro> Message-ID: Hi, For the localization file in .ro, open a ticket on the trac and add it as an attachment, I'll add it to the trunk after. For the js change, create a patch, open a ticket on the trac and add it as an attachment, and maybe I'll add it after a few testing. Cheers, Fr?d?ric Le 5 mai 07 ? 17:41, Alex Deva a ?crit : > Hi, > > A. I'm not sure who to tell about this, but I've created a > localization file in Romanian, and I'd like to make it available > for inclusion in the next release. Will an administrator tell me > where to send my lang/ro_RO.rb please? :) > > Incidentally, I've also fixed a few other files whose strings > weren't localized. At the time I'm writing this mail, they are: > vendor/plugins/xml_sidebar/views/content.rhtml > vendor/plugins/category_sidebar/views/content.rhtml > app/helpers/articles_helper.rb > views/shared/_search.rhtml > > I'll keep on patching them. If anyone's interested, I can make them > available too. > > B. Another thing which is, in my opinion, not very nice is that > there are some Javascript strings which can't easily be localized > using the _() notation. Among others, that's why you'll always see > "x hours ago" in English, regardless of your configured language. > > To fix this, I've done the following 5 steps: > > 1. Patched localization.rb by adding: > def self.all_keys > @@l10s[lang].keys > end > > 2. Added a method in articles_controller.rb: > def localized_js > > # We only retrieve translations which have to do with the > Javascript strings; we don't want to overload the browser. > js_content = Localization.all_keys.collect { |key| if key =~ / > ^js_(.+)/ ; $1 end }.compact > > render :content_type => 'text/javascript', :text => 'var > LocalizedStrings = {' + > js_content.collect { |key| lkey="js_#{key}"; "\"#{key}\" : > \"#{_(lkey)}\"" }.join(', ') + > '} > String.prototype.localize = function() { > var s; > if(LocalizedStrings && (s=LocalizedStrings > [this]) ) return s; > return this; > }' > end > > 3. Added a line in the default.rhtml of the active theme (maybe > there's a better place for this, but I couldn't find it yet): >