Use the same page header/footer across apps within a domain?

Let’s say I have four different rails apps which use different
databases…
blog.mydomain.com
store.mydomain.com
links.mydomain.com
news.mydomain.com

I’d like each app to have a consistent look and feel starting with using
the same header, footer and stylesheets on the pages that are displayed
in the browser. Is there someway to do that?

Can the header and footer code sit in a separate partials directory
which they can all share?

Would using sub-directories instead of sub-domains make this easier to
manage?

I’d like to avoid having to duplicate the header and footer assets for
each Rails app.

I’m curious what others have come up with to solve similar issues.

Thanks,
Dan P.

Do you use a vps ?
maybe “ln -s” will be your answer, dunno really if it will work, later i
try it.
If yes you can point the layout folder to the unique layout folder :stuck_out_tongue:
hope you got it

Dan P. wrote:

Let’s say I have four different rails apps which use different
databases…
blog.mydomain.com
store.mydomain.com
links.mydomain.com
news.mydomain.com

I’d like each app to have a consistent look and feel starting with using
the same header, footer and stylesheets on the pages that are displayed
in the browser. Is there someway to do that?

Can the header and footer code sit in a separate partials directory
which they can all share?

I could imagine you create a plugin, that contains the method and data
that you place in these headers and footers.

Then your layouts could say
<%= mydomain_header %>

.
.
.

<%= mydomain_footer %>

and these methods are taken from the plugin code.

The plugin code could be checked out as external projects from
subversion repository for example, to synchronize them as you like.

Haven’t thought through how you would provide for dynamic content; I
don’t know if the headers and footers have dynamic content (Logged in
users?)

Your stylesheets could be accessed through
http://mydomain.com/styles/style.css. Don’t know if you find it
difficult to set up a server for this or you already have one.

Stephan

Stephan W. wrote:

I could imagine you create a plugin, that contains the method and data
that you place in these headers and footers.

Sorry, to clarify, to be placed in the lib directory … (not
vendor/plugins)

Stephan

You might find it useful to take a look at the theme_support plugin
(http://www.agilewebdevelopment.com/plugins/theme_support) to see an
example of how to extend the places that Rails will search for
layouts and views. From that starting point, it shouldn’t be hard to
come up with a shared path you could use for your various apps.

An alternative approach if you are using subversion would be to use
svn:externals to share paths like app/views/layouts and public/
stylesheets. This approach would probably be more straightforward.


Building an e-commerce site with Rails?
http://www.agilewebdevelopment.com/rails-ecommerce

Meet up at RailsConf:
http://railsconf2007.conferencemeetup.com/

Dan P. wrote:

Let’s say I have four different rails apps which use different
databases…
blog.mydomain.com
store.mydomain.com
links.mydomain.com
news.mydomain.com

I’d like each app to have a consistent look and feel starting with using
the same header, footer and stylesheets on the pages that are displayed
in the browser. Is there someway to do that?

Can the header and footer code sit in a separate partials directory
which they can all share?

Not as far as I know, but you might be able to implement and API on one
“master” domain that spits back HTML.

Would using sub-directories instead of sub-domains make this easier to
manage?

Yes.

I’d like to avoid having to duplicate the header and footer assets for
each Rails app.

I’m curious what others have come up with to solve similar issues.

Thanks,
Dan P.

Another way might be to use symbolic links for a shared directory (if
all your sites are on one server), or maybe configure apache to retrieve
content from another site using mod_proxy?

We’ve used symlinks to share things in the past between projects so
that we only have one copy – models, images, etc. should work as
well for your views.

Steven


Steven S., CEO, FiveRuns
http://www.fiveruns.com

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs