[ranch] 25: Change layout.

https://svn.lrde.epita.fr/svn/ranch/trunk Index: ChangeLog from Nicolas Despr�s <nicolas.despres@gmail.com> Change layout. * web/ranch/test/functional/ranch_controller_test.rb: New. Controller of the main layout. * web/ranch/test/functional/graph_form_controller_test.rb: Add session fixtures. * web/ranch/test/functional/projects_controller_test.rb: Test the show request. * web/ranch/app/helpers/ranch_helper.rb: New. * web/ranch/app/controllers/ranch_controller.rb: New. Init the session variable. * web/ranch/app/controllers/graph_form_controller.rb: Use the ranch_benches_list layout. * web/ranch/app/controllers/projects_controller.rb: Add the show request and remove index and list. * web/ranch/app/views/layouts/ranch.rhtml: Layout without the the left margin. * web/ranch/app/views/layouts/ranch_benches_list.rhtml: New. Layout with the left margin. * web/ranch/app/views/layouts/_head.rhtml, * web/ranch/app/views/layouts/_banner.rhtml, * web/ranch/app/views/layouts/_left_margin.rhtml, * web/ranch/app/views/layouts/_top_banner.rhtml, * web/ranch/app/views/layouts/_menubar.rhtml, * web/ranch/app/views/layouts/_bottom_banner.rhtml: New. Part of the layout. * web/ranch/app/views/graph_form/index.rhtml: Update to the new layout. * web/ranch/app/views/projects/list.rhtml: Remove. Useless since the list is available in the main layout. * web/ranch/app/views/projects/show.rhtml: New. Display project's properties. * web/ranch/app/views/ranch: New. * web/ranch/app/views/ranch/_welcome.rhtml: New. The home page. * web/ranch/app/views/ranch/index.rhtml: New. Main page. * web/ranch/config/routes.rb: First page is RanchController#index. * web/ranch/test/functional/benches_controller_test.rb, * web/ranch/app/helpers/benches_helper.rb, * web/ranch/app/controllers/benches_controller.rb, * web/ranch/app/views/benches, * web/ranch/app/views/benches/list.rhtml: Remove. Useless since this list is available in the layout. app/controllers/graph_form_controller.rb | 2 - app/controllers/projects_controller.rb | 11 +----- app/controllers/ranch_controller.rb | 17 +++++++++ app/helpers/ranch_helper.rb | 2 + app/views/graph_form/index.rhtml | 46 +++++++++++--------------- app/views/layouts/_banner.rhtml | 5 ++ app/views/layouts/_bottom_banner.rhtml | 6 +++ app/views/layouts/_head.rhtml | 6 +++ app/views/layouts/_left_margin.rhtml | 28 +++++++++++++++ app/views/layouts/_menubar.rhtml | 12 ++++++ app/views/layouts/_top_banner.rhtml | 5 ++ app/views/layouts/ranch.rhtml | 16 ++------- app/views/layouts/ranch_benches_list.rhtml | 28 +++++++++++++++ app/views/projects/show.rhtml | 12 ++++++ app/views/ranch/_welcome.rhtml | 6 +++ app/views/ranch/index.rhtml | 3 + config/routes.rb | 2 - test/functional/graph_form_controller_test.rb | 10 +++++ test/functional/projects_controller_test.rb | 24 +++++++------ test/functional/ranch_controller_test.rb | 18 ++++++++++ 20 files changed, 201 insertions(+), 58 deletions(-) Index: web/ranch/test/functional/ranch_controller_test.rb --- web/ranch/test/functional/ranch_controller_test.rb (revision 0) +++ web/ranch/test/functional/ranch_controller_test.rb (revision 0) @@ -0,0 +1,18 @@ +require File.dirname(__FILE__) + '/../test_helper' +require 'ranch_controller' + +# Re-raise errors caught by the controller. +class RanchController; def rescue_action(e) raise e end; end + +class RanchControllerTest < Test::Unit::TestCase + def setup + @controller = RanchController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + end + + # Replace this with your real tests. + def test_truth + assert true + end +end Index: web/ranch/test/functional/graph_form_controller_test.rb --- web/ranch/test/functional/graph_form_controller_test.rb (revision 24) +++ web/ranch/test/functional/graph_form_controller_test.rb (working copy) @@ -11,6 +11,16 @@ @controller = GraphFormController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new + + @request.session[:projects] = Project.find_by_sql "SELECT id, name " + + "FROM projects " + + "WHERE 1 " + + "ORDER BY name" + @request.session[:benches] = Bench.find_by_sql "SELECT id, name, project_id " + + "FROM benches " + + "WHERE 1 " + + "GROUP BY name " + + "ORDER BY project_id, name" end def test_index Index: web/ranch/test/functional/projects_controller_test.rb --- web/ranch/test/functional/projects_controller_test.rb (revision 24) +++ web/ranch/test/functional/projects_controller_test.rb (working copy) @@ -11,21 +11,23 @@ @controller = ProjectsController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new - end - def test_index - get :index - assert_response :success - assert_template 'list' + @request.session[:projects] = Project.find_by_sql "SELECT id, name " + + "FROM projects " + + "WHERE 1 " + + "ORDER BY name" + @request.session[:benches] = Bench.find_by_sql "SELECT id, name, project_id " + + "FROM benches " + + "WHERE 1 " + + "GROUP BY name " + + "ORDER BY project_id, name" end - def test_list - get :list - + def test_show + get :show, { :project_id => 1 } assert_response :success - assert_template 'list' - - assert_not_nil assigns(:projects) + assert_template 'show' + assert_not_nil assigns(:project) end end Index: web/ranch/app/helpers/ranch_helper.rb --- web/ranch/app/helpers/ranch_helper.rb (revision 0) +++ web/ranch/app/helpers/ranch_helper.rb (revision 0) @@ -0,0 +1,2 @@ +module RanchHelper +end Index: web/ranch/app/controllers/ranch_controller.rb --- web/ranch/app/controllers/ranch_controller.rb (revision 0) +++ web/ranch/app/controllers/ranch_controller.rb (revision 0) @@ -0,0 +1,17 @@ +class RanchController < ApplicationController + + layout 'ranch_benches_list' + + def index + session[:projects] = Project.find_by_sql "SELECT id, name " + + "FROM projects " + + "WHERE 1 " + + "ORDER BY name" + session[:benches] = Bench.find_by_sql "SELECT id, name, project_id " + + "FROM benches " + + "WHERE 1 " + + "GROUP BY name " + + "ORDER BY project_id, name" + end + +end Index: web/ranch/app/controllers/graph_form_controller.rb --- web/ranch/app/controllers/graph_form_controller.rb (revision 24) +++ web/ranch/app/controllers/graph_form_controller.rb (working copy) @@ -1,7 +1,7 @@ class GraphFormController < ApplicationController helper :graph, :graph_form - layout 'ranch' + layout 'ranch_benches_list' DEFAULT_REVISION_RANGE = 100 Index: web/ranch/app/controllers/projects_controller.rb --- web/ranch/app/controllers/projects_controller.rb (revision 24) +++ web/ranch/app/controllers/projects_controller.rb (working copy) @@ -1,14 +1,9 @@ class ProjectsController < ApplicationController - layout 'ranch' + layout 'ranch_benches_list' - def index - list - render :action => 'list' - end - - def list - @projects = Project.find_all + def show + @project = Project.find_by_id params[:project_id] end end Index: web/ranch/app/views/layouts/ranch.rhtml --- web/ranch/app/views/layouts/ranch.rhtml (revision 24) +++ web/ranch/app/views/layouts/ranch.rhtml (working copy) @@ -1,21 +1,13 @@ <!-- -*- html -*- --> <html> - <head> - <title>Ranch: regression benchmark system</title> - <%= stylesheet_link_tag 'scaffold' %> - </head> + <%= render :partial => "layouts/head" %> <body> - <div style="text-align: center;"> - <h1>Ranch</h1> - <hr> - </div> + <%= render :partial => "layouts/top_banner" %> + <%= render :partial => "layouts/menubar" %> <%= @content_for_layout %> - <div style="text-align: center;"> - <hr> - Powered by RubyOnRails - </div> + <%= render :partial => "layouts/bottom_banner" %> </body> </html> Index: web/ranch/app/views/layouts/ranch_benches_list.rhtml --- web/ranch/app/views/layouts/ranch_benches_list.rhtml (revision 0) +++ web/ranch/app/views/layouts/ranch_benches_list.rhtml (revision 0) @@ -0,0 +1,28 @@ + <!-- -*- html -*- --> + +<html> + <%= render :partial => "layouts/head" %> + <body> + <%= render :partial => "layouts/top_banner" %> + <%= render :partial => "layouts/menubar" %> + + <p> + <table cellspacing=0 cellpadding=0 border=0 width='100%' height="80%" cols=2> + <tr> + <td class=left_margin valign=top width="15%"> + <%= render :partial => "layouts/left_margin" %> + </td> + <td class=content align=left valign=top width="80%"> + + <%= @content_for_layout %> + + </td> + </tr> + </table> + </p> + + <%= render :partial => "layouts/bottom_banner" %> + </body> +</html> + + Index: web/ranch/app/views/layouts/_head.rhtml --- web/ranch/app/views/layouts/_head.rhtml (revision 0) +++ web/ranch/app/views/layouts/_head.rhtml (revision 0) @@ -0,0 +1,6 @@ + <!-- -*- html -*- --> + +<head> + <title>Ranch: regression benchmark system</title> + <%= stylesheet_link_tag 'scaffold' %> +</head> Index: web/ranch/app/views/layouts/_banner.rhtml --- web/ranch/app/views/layouts/_banner.rhtml (revision 0) +++ web/ranch/app/views/layouts/_banner.rhtml (revision 0) @@ -0,0 +1,5 @@ + <!-- -*- html -*- --> +<div style="text-align: center;"> + <h1>Ranch</h1> + <hr> +</div> Index: web/ranch/app/views/layouts/_left_margin.rhtml --- web/ranch/app/views/layouts/_left_margin.rhtml (revision 0) +++ web/ranch/app/views/layouts/_left_margin.rhtml (revision 0) @@ -0,0 +1,28 @@ + <!-- -*- html -*- --> +<table> + <% for project in session[:projects] %> + <tr> + <td><%= link_to project.name, :controller => "projects", + :action => "show", + :project_id => project.id %></td> + </tr> + <tr> + <td> + <table> + <% for bench in session[:benches] %> + <% if bench.project_id == project.id %> + <tr> + <td width=10> + </td> + <td> + <%= link_to bench.name, :controller => "graph_form", + :action => "index", + :project_id => project.id, + :bench_name => bench.name %> + </td> + </tr> + <% end %> + <% end %> + </table> + <% end %> +</table> Index: web/ranch/app/views/layouts/_top_banner.rhtml --- web/ranch/app/views/layouts/_top_banner.rhtml (revision 0) +++ web/ranch/app/views/layouts/_top_banner.rhtml (revision 0) @@ -0,0 +1,5 @@ + <!-- -*- html -*- --> +<div style="text-align: center;"> + <h1>Ranch</h1> + <hr> +</div> Index: web/ranch/app/views/layouts/_menubar.rhtml --- web/ranch/app/views/layouts/_menubar.rhtml (revision 0) +++ web/ranch/app/views/layouts/_menubar.rhtml (revision 0) @@ -0,0 +1,12 @@ + <!-- -*- html -*- --> + +<div style="text-align: center;"> +<table class=menubar align=center valign=top> + <tr> + <td> + <%= link_to "Home", :controller => "ranch", :action => "index" %> + </td> + </tr> +</table> +<hr> +</div> Index: web/ranch/app/views/layouts/_bottom_banner.rhtml --- web/ranch/app/views/layouts/_bottom_banner.rhtml (revision 0) +++ web/ranch/app/views/layouts/_bottom_banner.rhtml (revision 0) @@ -0,0 +1,6 @@ + <!-- -*- html -*- --> + +<div style="text-align: center;"> + <hr> + Powered by RubyOnRails +</div> Index: web/ranch/app/views/graph_form/index.rhtml --- web/ranch/app/views/graph_form/index.rhtml (revision 24) +++ web/ranch/app/views/graph_form/index.rhtml (working copy) @@ -1,39 +1,36 @@ <!-- -*- html -*- --> -<div style="text-align: center;"> -<%= content_tag "h2", "#{@project.name}: #{@bench_name}" %> +<%= content_tag "h3", "#{@project.name}: #{@bench_name}" %> <%= start_form_tag :action => "draw", :project_id => @project.id, :bench_name => @bench_name %> -</div> -<p> -<center> -<p> + +<table cellspacing=10> <!-- REVISION --> -<p> -<table> - <tr> - <td></td> - <td>Start</td> - <td>Stop</td> - </tr> <tr> <td>Revision:</td> + <td> + <table> + <tr> + <td>from</td> <td><%= text_field "revision", "start", "size" => 8, "value" => @revision[:start] %></td> + <td>to</td> <td><%= text_field "revision", "stop", "size" => 8, "value" => @revision[:stop] %></td> </tr> </table> -</p> + </td> +</tr> <!-- INPUTS --> -<p> +<tr> + <td>Inputs:</td> + <td> <table> <tr> - <td>Inputs</td> <td> <select id="input_set_num" name="input_set_num"> <% i = 0 @@ -53,21 +50,25 @@ </td> </tr> </table> -</p> + </td> +</tr> <!-- OUTPUTS --> -<p> -<table> <tr> <td>Output:</td> + <td> + <table> + <tr> <td><%= outputs_tag "output_arg_num", @bench_name, @output_arg_num %></td> </tr> + </td> </table> -</p> +</tr> <!-- SUBMIT BUTTON --> +</table> </p> <p style="color: red;"><%= flash[:error] %></p> <p><%= submit_tag "Draw" %></p> @@ -94,9 +95,4 @@ <% else %> <%= content_tag "p", "No chart to display - click on Draw" %> <% end %> -</p> -</center></p> -<p><%= link_to "Back", :controller => "benches", - :action => "list", - :project_id => @project.id %></p> Index: web/ranch/app/views/projects/show.rhtml --- web/ranch/app/views/projects/show.rhtml (revision 0) +++ web/ranch/app/views/projects/show.rhtml (revision 0) @@ -0,0 +1,12 @@ + <!-- -*- html -*- --> + +<%= content_tag "h3", "#{@project.name}" %> + +<p> +<table> + <tr> + <td>Head revision:</td> + <td><%= @project.head_revision %></td> + </tr> +</table> +</p> Index: web/ranch/app/views/ranch/_welcome.rhtml --- web/ranch/app/views/ranch/_welcome.rhtml (revision 0) +++ web/ranch/app/views/ranch/_welcome.rhtml (revision 0) @@ -0,0 +1,6 @@ + <!-- -*- html -*- --> + +<h1>Welcome</h1> +<p> +Ranch is a regression benchmark system. +</p> Index: web/ranch/app/views/ranch/index.rhtml --- web/ranch/app/views/ranch/index.rhtml (revision 0) +++ web/ranch/app/views/ranch/index.rhtml (revision 0) @@ -0,0 +1,3 @@ + <!-- -*- html -*- --> + +<%= render :partial => "welcome" %> Index: web/ranch/config/routes.rb --- web/ranch/config/routes.rb (revision 24) +++ web/ranch/config/routes.rb (working copy) @@ -8,7 +8,7 @@ # You can have the root of your site routed by hooking up '' # -- just remember to delete public/index.html. - map.connect '', :controller => "projects" + map.connect '', :controller => "ranch" # Allow downloading Web Service WSDL as a file with an extension # instead of a file named 'wsdl'
participants (1)
-
Nicolas Despr�s