Difference between revisions of "Developer help"

From mx Help Wiki
Jump to: navigation, search
m (New page: <i> in progress... </i> == File layout == <p> The application follows the traditional Rails layout. </p> == Public accessibility == There are two different approaches to making your d...)
 
(Books, Cheat sheets, etc.)
 
(13 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
<i> in progress... </i>
 
<i> in progress... </i>
 +
 +
== Understanding Rails in general ==
 +
 +
[http://64.233.169.104/search?q=cache:w0lweaiHJq4J:glu.ttono.us/articles/2006/03/21/rails-for-designers+rails+for+designers&hl=en&ct=clnk&cd=1&gl=us| A nice article regarding Rails from the designers standpoint].
 +
 +
== Books, Cheat sheets, etc. ==
 +
 +
* [http://dizzy.co.uk/ruby_on_rails/cheatsheets/rails-migrations Rails migrations cheat sheet]
 +
* [http://www.addedbytes.com/cheat-sheets/ Cheat sheets (originally from ILoveJackDaniels)]
 +
 +
== Rake tasks ==
 +
 +
There are a lot of rake tasks available for rails in general, and several for mx in particular. To see all the tasks available do
 +
 +
rake --tasks
 +
 +
Rake tasks specific to mx are in the 'mx' namespace ("mx:").  To see only those type
 +
 +
rake --tasks mx
 +
 +
See [[Rake tasks]] for a description of these tasks.
  
 
== File layout ==
 
== File layout ==
Line 11: Line 32:
 
* just use the shared public controllers
 
* just use the shared public controllers
 
* create a "home" controller
 
* 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 ===
 
=== Shared controllers ===
Line 16: Line 45:
 
Controllers that sit at the base of   
 
Controllers that sit at the base of   
  
  /controllers/public
+
  app/controllers/public
  
are shared by all projects.  
+
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 ===
 
=== 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
 +
 +
== How To Scenarios ==
 +
 +
[[How To Scenarios]] is a place to post specific questions, answers and tips that may be helpful for other developers

Latest revision as of 15:37, 10 November 2009

in progress...

Contents

[edit] Understanding Rails in general

A nice article regarding Rails from the designers standpoint.

[edit] Books, Cheat sheets, etc.

[edit] Rake tasks

There are a lot of rake tasks available for rails in general, and several for mx in particular. To see all the tasks available do

rake --tasks

Rake tasks specific to mx are in the 'mx' namespace ("mx:"). To see only those type

rake --tasks mx

See Rake tasks for a description of these tasks.

[edit] File layout

The application follows the traditional Rails layout.

[edit] 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.

[edit] 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

[edit] 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

[edit] How To Scenarios

How To Scenarios is a place to post specific questions, answers and tips that may be helpful for other developers

Personal tools