Radiant integration with another Rails app?

Does anyone have a successful example out there of putting Radiant in
the vendor directory of an existing full-scale Rails app and having
it play nicely?

I’ve tried unsuccessfully in the past, however with the final polish
on 0.6 (and now 0.61) I’m ready to give it another shot.

I have an app I would like to do this with that I’ll be working on in
a week or two.

For my use here are the two main issues that I know of are:

  1. Routes… I can load my app’s routes first I essentially override
    everything but the final Radiant default “page not found” route.

  2. Rendering of snippets or page parts with Radius tags in them
    straight in to my Rails app view… In particular, I imagine making a
    helper in my app for calling the Radiant content. Is there a way to
    render the snippet or part directly without creating a new
    PageContext every time it goes to render (I’d be doing this all
    through a Rails helper method I imagine…)

  3. Less important to me, but interesting… the reuse of Layouts. Can
    I pull a layout as a Rails layout, ERB render and then do a final
    Radius render? Anyone tried this?

Anybody doing any of this yet?

Thanks,

Loren

Hi Loren,

Nice to talk to you again! :wink:

I’m working on the same thing right now. I currently have a Radiant
extension that allows Radiant to live in /vendor while having a Rails
app at it’s current location with only a slight modification required
for config/routes.rb to work properly.

It also has the ability to insert a snippet using a helper as you
suggested, although I don’t know how robust it is depending on what
radius tags are in that snippet. And yes, as you mentioned, it
creates a Page object to do this.

I’m also very interested in allowing Rails pages to leverage Radiant
layouts, and that is the next thing I plan to work on. Let me know
if you’re interested in seeing the extension I have so far. I plan
on creating a Rubyforge project for it, but I haven’t gotten around
to that yet. Perhaps we can work together to get this done. I also
think that Sean was working on the layout problem, too. So maybe he
already has made some progress in that area.

Thanks,
Matt

Hey Matt,

Funny – I knew I talked to someone about this at RailsConf and I
just couldn’t remember who… Now I remember our discussion well.

Yes, I’d very much like to help out in whatever way I can. I really
want to see this happen and end-up with something that makes the
integration dead simple to accomplish.

Love to see what you’ve got so far and talk more. It’d be especially
nice to see how you’re using it in your existing app. I still have
your card here, I’ll give you a shout later today or tomorrow to talk
approaches and see in what way I might be able to pitch-in, etc.

Maybe it’d be nice to set a date and time for you, Sean and myself
(and anyone else interested) to meet-up in #radiantcms IRC on this
topic…

Glad there is something already happening on this front!

Loren

Hello everybody
I have a site with a node page called news, inside that I have some
subpages and some other nodes with subpages in them.
I am using children:each to show all subpages of news, but I need to see
subpages of other nodes too called for example sction1 and section2. So
I put another cycle children:each inside the first one.
It is ok, but I see the nodes pages too.
I am trying to use unless_url matches=“section\d$” to match all pages
that ends with that url to avoid displaying nodes pages, but it doesn’t
work. Is there some special way to use regexp inside radiant?
Or maybe exist tag like unless_parent but matching if a page
has_children?
Thanks to everybody


Francesco L.
Ymir s.r.l.
Viale Verona 190/11
38100 Trento

I’m working right now to get a project created on RubyForge and
trying to come up with a reasonable name for the extension. How does
‘RadiantFromRails’ sound?

I’m up for getting together with you and Sean on IRC. I’d really
like to hear Sean’s thoughts about how he might approach the issue of
layouts as I haven’t really spent any time thinking about the
implementation yet.

Matt,

RadiantFromRails sounds good to me.

Let me know when you get it set up, I’m anxious to give it a spin.
Once I am sitting down to do that I’ll feed my experience back to you
on how it goes.

Do you have a client use case for the integration? I think you said
you did, but it’d be good to know your requirements as it seems that
a completely general purpose integration method could be a stretch…

Feel free to AIM, call or email me if you’d like to bat any part of
the implementation details around with someone.

Loren

Francesco,

It will help if you can post the code snippet with the nested
<r:children:each … tags in it to look at. If I am understanding
what you’re describing correctly, yes I’d expect it to work as well.

If you’re still stuck post that section of code and maybe I can help
more.

Loren

Matt Parrish wrote:

I’m working right now to get a project created on RubyForge and
trying to come up with a reasonable name for the extension. How does
‘RadiantFromRails’ sound?

I’m up for getting together with you and Sean on IRC. I’d really
like to hear Sean’s thoughts about how he might approach the issue of
layouts as I haven’t really spent any time thinking about the
implementation yet.

If you get a plugin going, I’d be happy for it to live in the Radiant
SVN repository.


John L.
http://wiseheartdesign.com

John,

Are you suggesting that I develop from the Radiant SVN repository?
Or are you saying that you’d be happy to host a copy of stable releases?

Also, the name I settled on was Radiant on Rails and it is a Radiant
Extension.

Thanks,
Matt

Did you consider wrapping it up as a plugin? Off the top of my head
that seems like it could be the cleanest way to go, but I say that
without seeing how you have it setup now.

What is a basic sketch of the install process as it is?

Some way to embed in a straight Rails app is in my view a key piece
of the puzzle that is Radiant’s future. I have frequent applications
now that would use Radiant in this embedded way if an easy and
unobtrusive way to do so was already established.

So as for going in the Radiant SVN I think it belongs there and I’m
willing to pitch-in on the development effort if you want/need that.
There are “in development” pieces in there already, so I think it’s a
fine place for it. – But that just “like my opinion, dude”.

:slight_smile:

Loren

On May 30, 2007, at 2:01 PM, Mario T. Lanza wrote:

I’m also very interested in allowing Rails pages to leverage Radiant
layouts, and that is the next thing I plan to work on.

I find this is a very natural means of doing just what I have been
attempting to do all along. The only piece that I am missing is the
ability to take advantage of Radiant from the Rails side, which
apparently is a much sought-after piece that is now in the works.

I also wonder if the ability to take advantage of Rails partials in
Pages/Snippets/Parts would be useful to Extension designers. It would
primarily support creating models and tags which produce a kind of
‘widgety’ thing - not necessarily for public/generic consumption, but
for allowing Radiant Extension builders (developers working for CMS
users) to encapsulate something, leveraging the power of Ruby/Rails
while still protecting the CMS user from having the full power of Erb.

But are we going away from the ‘original intent’? There’s fascinating
conversation about the meaning of a piece of literature: is it found
in the text, in the author, or in the reader?

adam

I’m also very interested in allowing Rails pages to leverage Radiant
layouts, and that is the next thing I plan to work on.

I’m very happy to see this project forming. After tossing around many
ideas for integrating custom Rails views within a Radiant site, I’ve
formulated a pattern.

I simply create an extension and build the functionality exactly like
I’m building a Rails app. I modify the routes in the extension
initializer being careful to differentiate between back-end
functionality (for the admin interface) and front-end functionality (for
the sites users). Admin functionality is put in “admin” subfolders just
as is already done with the Radiant admin stuff. For example, here are
the routes I currently use for an in-progress extension that has both
front-end and back-end interfaces.

define_routes do |map|

#back-end interfaces
map.admin_event ‘admin/event/:action/:id’, :controller =>
‘admin/event’
map.admin_offering ‘admin/offering/:action/:id’, :controller =>
‘admin/offering’

#front-end interfaces
map.offering ‘offering/:action/:id’, :controller => ‘offering’
map.event ‘event/:action/:id’, :controller => ‘event’
map.registration ‘registration/:action/:id’, :controller =>
‘registration’
map.invitation ‘invitation/:action/:id’, :controller => ‘invitation’
map.evite ‘evite/:action/:id’, :controller => ‘invitation’

end

There models are common, but there is a distinction between the
front-end and back-end controllers and views.

I find this is a very natural means of doing just what I have been
attempting to do all along. The only piece that I am missing is the
ability to take advantage of Radiant from the Rails side, which
apparently is a much sought-after piece that is now in the works.

At this point I am creating Rails layouts that are identical to their
Radiant counterparts. It’s not DRY, but it is workable for the time
being.

I’m eagerly anticipating seeing this extension so I can DRY things up.

Mario

Loren J. wrote:

Did you consider wrapping it up as a plugin? Off the top of my head
that seems like it could be the cleanest way to go, but I say that
without seeing how you have it setup now.

I think I agree with Loren that Radiant as a plugin is a much nicer way
to go (vs. dropping it in your vendor directory). This way you could
install the pluginized version of Radiant with a simple:

script/plugin install radiant

I’m willing to consider changes to Radiant make this integration easier.

Are you suggesting that I develop from the Radiant SVN repository?
Or are you saying that you’d be happy to host a copy of stable
releases?

Perhaps you could work with Loren on this for the time being. He just
recently joined core and it sounds like you have the same goals. When
you have something ready you guys could drop it in:

http://dev.radiantcms.org/svn/radiant/trunk/plugins/radiant/

I’d suggest that the plugin would have the following directory
structure:

plugins/
radiant/
init.rb
lib/
vendor/
radiant/ <<< an svn:external to trunk/radiant

All of this talk makes me think that we need to move all of the Radiant
models into the the top level Radiant module to avoid namespace
collisions.


John L.
http://wiseheartdesign.com

I like the idea of being able to install Radiant as a plugin as that
will make it easier to integrate with an existing Rails application.
However, when starting from scratch, the current method seems just as
easy.

As for the RadiantOnRails extension, I’ll release that on RubyForge
for use with 0.6.1 and work with Loren on getting it to a Plugin-ized
version within Radiant SVN repository.

Loren, congrats on the promotion to Radiant Core team member! :slight_smile:

Matt Parrish
http://www.pearware.org

It looks like we’re both looking for the same goals out of this
project. The number one feature for us is to reuse the Radiant
layouts to keep that DRY. And that’s where this project will be
going next.

As for the rails portion of the site, the other thing this extension
allows for, is to be able to use the traditional RAILS_ROOT/app/
[controllers|helpers|models|views] folders instead of burying
everything into /vendor/extensions. I think this also helps to
create a cleaner split between Rails and Radiant code and also makes
it easier to integrate Radiant into an existing Rails app.

Matt Parrish
http://www.pearware.org

The RadiantOnRails extension is now live on RubyForge at http://
www.rubyforge.org/projects/radiantonrails. This extension allows for
Radiant to co-exist with a Rails application. You can checkout the
code with the following command:

svn checkout svn://rubyforge.org/var/svn/radiantonrails/trunk

Or, to install the extension, follow the instructions from the
Radiant website (http://dev.radiantcms.org/radiant/wiki/Extensions)
using the name ‘radiant_on_rails’ for the extension_name.

Matt Parrish
http://www.pearware.org

Matt Parrish wrote:

The RadiantOnRails extension is now live on RubyForge at http://
www.rubyforge.org/projects/radiantonrails. This extension allows for
Radiant to co-exist with a Rails application. You can checkout the
code with the following command:

svn checkout svn://rubyforge.org/var/svn/radiantonrails/trunk

Or, to install the extension, follow the instructions from the
Radiant website (http://dev.radiantcms.org/radiant/wiki/Extensions)
using the name ‘radiant_on_rails’ for the extension_name.

Matt Parrish
http://www.pearware.org

I already have a Rails app and would like to retrofit it with Radiant
using this extension. How would the process differ from starting with a
Radiant app and building it out into a Rails app?

Read through the Readme in the extension now posted on RubyForge (see
Matt’s original post for address, etc) and you’ll find that the
“installation” is very straight forward and will be the same whether
it’s with a fresh Rails app or an existing one.

Give it a shot…

On May 31, 2007, at 1:14 PM, Matt Parrish wrote:

radiant_on_rails

Excellent.

aiwilliams

You’re absolutely right, sorry I hadn’t looked closely enough.

You could gem install Radiant and generate an instance and then merge
the necessary bits from the environment.rb it generates into your
existing app.

If I get a chance I’ll try and determine what those necessary bits
are later today and email back what I learn.

Loren