Re: [Radiant] Registering observers in a radiant extension

2011-02-23 Thread William Ross
On 21 Feb 2011, at 09:57, swartz wrote:

 Is there a better way to register an observer for a Radiant extension
 than editing environment.rb?
 
 I have tried adding extension_config block to my extension like so
 
  extension_config do |config|
config.active_record.observers = :mymodel_observer
  end
 
 But that did not work.

In edge - but iirc not in 0.9.1 - you can put anything you want to run early 
into [extension root]/config/initializers. You should be able to define 
observers from there.

best,

will





Re: [Radiant] Conditional tags wiki info: typo or user ignorance?

2011-02-23 Thread William Ross
On 23 Feb 2011, at 17:01, rosslaird wrote:

 In the radiant wiki over on github (I am posting this here because the
 wiki on github seems to have very low readership), the conditional
 tags page show this example code:
 
 head
 r:if_url matches=^/$
  titleRadiant Handbook/title
 /r:if_url
 r:unless_url matches=^/$
  titler:title/ - Radiant Handbook/title
 /r:unless_url
 /head
 
 The documentation goes on to say that the code above would set the
 page title as “Radiant Handbook” on the homepage, but for all subpages
 it would use the title of the page, then “… – Radiant Handbook”.
 
 Now, when I look at the url regexp in the first bit (if_url matches),
 then I look at the regexp in the second bit (unless_url), these two
 expressions look *exactly the same* to me. Each one is ^/$. Am I
 blind, or are they the same? And if they are the same, should they be?
 And if not, what should they be?

The lack of an else clause in radius makes for rather clumsy notation 
sometimes: this is really just an if/then/else construction to check for 
rootpageness. In radius that has to be written as if and then unless with the 
same condition. In this example the path stays the same so that the same 
condition is applied first positively then negatively.

 I am trying to show an About Me link (in an id that slides in and
 out with JS) on my site on every page except the /about page (which
 already is about me...). It seems that if_url and unless_url are the
 way to go here, but I can't seem to get it to work. And I'm wondering
 is the reason for that has to do with the example code I've been
 adapting. I just changed the unless_url link to r:unless_url
 matches=^/about/$, but no dice. The About Me link still shows on
 that page.

Your regex should work for /about/, but it does depend on the url that is 
requested. It's a rails quirk that /about and /about/ are considered the same 
path, for example. Partial matches are fine so if the site is simple you might 
have better results with r:unless_url matches=^/about. Depending on the 
server, you may also want to set ignore_case=true.

best,

will