Developer help

From mx Help Wiki
Revision as of 17:05, 8 March 2007 by Matt (Talk | contribs)

Jump to: navigation, search

in progress...

Contents

Understanding Rails in general

A nice article regarding Rails from the designers standpoint.

File layout

The application follows the traditional Rails layout.

Public accessibility

There are two different approaches to making your data public. Both approaches require a layout.rhtml.

  • just use the shared public controllers
  • create a "home" controller

At present there are 3 locations where a project-specific set of public accessible files may reside:

/app/controllers/public/site/foo
/app/views/public/site/foo
/public/site/foo

Well try and mock up and include a basic site named 'foo' and include it in the source shortly.

Shared controllers

Controllers that sit at the base of

app/controllers/public

are shared by all projects. Controllers in

/app/controllers/public/site/foo

are specific to a project. In the above example 'foo' is the same as the unix-name that you give your project when you click 'settings' while logged in mx. Using a public controller is straightforward- all you need to do is point your link in your layout to that controller, for instance you could add something like this to your layout:

<tr>
 <td class="menu" valign="top">
   <a href="http://your_url.blah/public/ref/list_by_author">references</a>
   <a href="http://your_url.blah/public/ref">bibliography</a>
   <a href="http://your_url.blah/public/taxon_name/browse?family=">taxa</a>
   <a href="http://your_url.blah/public/repository">repositories</a>
   <a href="http://your_url.blah/public/taxon_name">search</a>
   <a href="http://your_url.blah/public/clave">keys</a>
   <a href="http://your_url.blah/site/evaniid/about_authors.html">about</a>
   <a href="http://your_url.blah">home</a>
 </td>
</tr>


In the above example the controllers that you are accessing are prefixed with public. For instance

 /public/ref
 /public/taxon_name
 /public/repository

are all shared controllers.

You'll also notice that some links have

/site

following the URL. These are links static html files that are found in

/public/site/foo

The 'home' controller

If you want a little more control or customization you can create a home_controller.rb file in

/app/controllers/public/site/foo

With this approach you can essentially ignore the

/public/site/foo

folder, instead placing all layout files, static or otherwise in

/app/views/public/site/foo

A home_controller.rb file for a project with unix name 'foo' and might look something like this:

 class Public::Site::Foo::HomeController < ApplicationController
   layout 'public/site/Foo/layout'
 
   def index
     # grab some random images to display on our hompage
     @ids = ImageDescription.random_set(1, 3, 1)
   end
 
   def about
    # these actions simply render the file in the given layout with the same name, for example:
    # /app/views/public/site/foo/about.rhtml
    # would be rendered calling this link
   end
   def links
    # see above
   end
   def keys
     # here we grab information from project 1
     redirect_to "/projects/1/public/clave/list"
   end
   def images
     redirect_to "/projects/1/public/image/list"
   end
   def taxon_pages
     redirect_to "/projects/1/public/public_content/list"
   end
   def association
     # and here we grab information from project 4
     redirect_to "/projects/4/public/association"
   end
 end
Personal tools