Forum: Radiant CMS Using a Rails plugin in Radiant extensions

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Bdf2290f0b1d87cb0853966e7e51606b?d=identicon&s=25 Andrew O'Brien (Guest)
on 2007-06-05 01:16
(Received via mailing list)
I'm trying to make a radiant friendly wrapping around the
Authorization plugin
(http://www.writertopia.com/developers/authorization) and I was
wondering: what's the best way to use a Rails plugin inside of a
Radiant extension?

I noticed there's a vendor/plugin directory in the standard project
layout, but it doesn't seem to be in the include path.  I also tried
adding a vendor/plugins directory to the extension (since it would be
kind of nice to bundle them together anyway), but that didn't quite
worked either.

Any suggestions?

Thanks,
Andrew

Oh, and in case you're wondering, I'm trying to add a controller to
allow role creation and assignment, as well as compatibility with
Radiant's existing authorization system.
8802b1fa1b53e2197beea9454244f847?d=identicon&s=25 Sean Cribbs (Guest)
on 2007-06-05 01:23
(Received via mailing list)
I included attachment_fu in my page_attachments extension.  It was kind
of tricky, but here's the basic strategy:

1) Import the plugin's lib/ directory into the lib/ directory of your
extension via svn:externals, piston, or an export.
2) Copy the contents of the init.rb file into the 'activate' method of
your extension.

You may have to fiddle with things to make sure they work right.  Here's
another potential strategy, YMMV:
(in 'activate')
1) Wherever you stored it, push the plugin's lib/ directory into the
load path.
2) Load or require the plugin's init.rb.

In either strategy, the plugin should probably be dealt with first (i.e.
placed first in the activate method) if your extension depends on it
during its activation.

Sean
Bdf2290f0b1d87cb0853966e7e51606b?d=identicon&s=25 Andrew O'Brien (Guest)
on 2007-06-05 18:00
(Received via mailing list)
Ah yes, the activation method -- that's probably a better place than
the top of the file...

My tests are passing, so things seem to be working better.  One
problem I'm having though is that it seems to be initializing
constants twice.  E.g.:

/Users/aobrien/WorkingDirectory/tgi_cms/vendor/extensions/subscription_manager/vendor/plugins/authorization/lib/publishare/parser.rb:4:
warning: already initialized constant VALID_PREPOSITIONS

It does this for all of the constants in the plugin.  They're
definitely specific to the Authorization plugin and not initialized
beforehand (I've tried inserting "raise" commands if the constant is
already defined) and the file is only required once (according to the
"puts" commands I put in).

They're just warnings, so I can probably live with them, but if this
rings any bells with anyone, I'd be glad to hear.

Thanks,
Andrew
8802b1fa1b53e2197beea9454244f847?d=identicon&s=25 Sean Cribbs (Guest)
on 2007-06-05 18:19
(Received via mailing list)
You might try wrapping your plugin initialization code in a block like
so:

unless defined?(VALID_PREPOSITIONS)
# init.rb contents goes here
end

Any constant defined in the plugin should do, including any class.

Sean
Bdf2290f0b1d87cb0853966e7e51606b?d=identicon&s=25 Andrew O'Brien (Guest)
on 2007-06-05 19:14
(Received via mailing list)
Actually -- I take that back.  Stupid mistake on my part.  I had the
artifact of another extension that had a local copy of the plugin in
it's directory.  That would explain why it only looked like the files
were being required once - that other extension was requiring exact
copies of the same files.

My bad and thanks for the help,
Andrew
This topic is locked and can not be replied to.