[Ovirt-devel] [PATCH server] integrate 'using ovirt' doc into a wui help section

Jason Guiditta jguiditt at redhat.com
Wed Oct 8 22:13:01 UTC 2008


On Wed, 2008-10-08 at 18:00 -0400, Mohammed Morsi wrote:
> this will work as is, but until help_sections table is populated
> all pages will link to main document body (and not particular
> sections)
> ---
>  src/app/controllers/application.rb           |   15 ++++++++++++++-
>  src/app/controllers/pool_controller.rb       |    2 +-
>  src/app/models/help_section.rb               |    2 ++
>  src/app/views/layouts/_header_redux.rhtml    |    1 -
>  src/app/views/layouts/help-and-content.rhtml |    6 ++++++
>  src/app/views/layouts/redux.rhtml            |    6 ++++++
>  src/app/views/layouts/tabs-and-content.rhtml |    8 +++++++-
>  src/db/migrate/023_create_help_sections.rb   |   13 +++++++++++++
>  src/public/stylesheets/layout.css            |    8 +++++++-
>  src/test/fixtures/help_sections.yml          |    7 +++++++
>  src/test/unit/help_section_test.rb           |    8 ++++++++
>  11 files changed, 71 insertions(+), 5 deletions(-)
>  create mode 100644 src/app/models/help_section.rb
>  create mode 100644 src/app/views/layouts/help-and-content.rhtml
>  create mode 100644 src/db/migrate/023_create_help_sections.rb
>  create mode 100644 src/test/fixtures/help_sections.yml
>  create mode 100644 src/test/unit/help_section_test.rb
> 
> diff --git a/src/app/controllers/application.rb b/src/app/controllers/application.rb
> index a751768..187adc6 100644
> --- a/src/app/controllers/application.rb
> +++ b/src/app/controllers/application.rb
> @@ -31,7 +31,7 @@ class ApplicationController < ActionController::Base
>    before_filter :pre_edit, :only => [:edit, :update, :destroy]
>    before_filter :pre_show, :only => [:show]
>    before_filter :authorize_admin, :only => [:new, :create, :edit, :update, :destroy]
> -  before_filter :is_logged_in
> +  before_filter :is_logged_in, :get_help_section
>  
>    def choose_layout
>      if(params[:component_layout])
> @@ -44,6 +44,19 @@ class ApplicationController < ActionController::Base
>      redirect_to(:controller => "login", :action => "login") unless get_login_user
>    end
>  
> +  def get_help_section
> +      help = HelpSection.find(:first, :conditions => [ "controller = ? AND action = ?", controller_name, action_name ])
> +      @help_section = help ? help.section : ""
> +      if @help_section.index('#')
> +        help_sections = @help_section.split('#')
> +        @help_section = help_sections[0]
> +        @anchor = help_sections[1]
> +      else
> +        @help_section = @help_section
> +        @anchor = ""
> +      end
> +  end
> +
>    def get_login_user
>      (ENV["RAILS_ENV"] == "production") ? session[:user] : "ovirtadmin"
>    end
> diff --git a/src/app/controllers/pool_controller.rb b/src/app/controllers/pool_controller.rb
> index 02ef290..1a574b1 100644
> --- a/src/app/controllers/pool_controller.rb
> +++ b/src/app/controllers/pool_controller.rb
> @@ -35,7 +35,7 @@ class PoolController < ApplicationController
>      respond_to do |format|
>        format.html {
>          render :layout => 'tabs-and-content' if params[:ajax]
> -        render :layout => false if params[:nolayout]
> +        render :layout => 'help-and-content' if params[:nolayout]
>        }
>        format.xml {
>          render :xml => @pool.to_xml(XML_OPTS)
> diff --git a/src/app/models/help_section.rb b/src/app/models/help_section.rb
> new file mode 100644
> index 0000000..a891383
> --- /dev/null
> +++ b/src/app/models/help_section.rb
> @@ -0,0 +1,2 @@
> +class HelpSection < ActiveRecord::Base
> +end
> diff --git a/src/app/views/layouts/_header_redux.rhtml b/src/app/views/layouts/_header_redux.rhtml
> index 18014ab..a12d567 100644
> --- a/src/app/views/layouts/_header_redux.rhtml
> +++ b/src/app/views/layouts/_header_redux.rhtml
> @@ -6,7 +6,6 @@
>      <input id="textfield_effect" name="terms" value="Search" onkeypress="" onfocus="if( this.value == this.defaultValue ) this.value='';" type="text">
>      <input id="searchbox-button" src="<%= image_path "icon_search.png"%>" title="Search" type="image">  |
>    </form>
> -  <a id="help-link" href="#" ><%= image_tag "icon_help.png" %></a> <!-- FIXME wire link correctly -->
>  </div>
>  
>  <div class="header_titlebar">Resource Pools</div>
> diff --git a/src/app/views/layouts/help-and-content.rhtml b/src/app/views/layouts/help-and-content.rhtml
> new file mode 100644
> index 0000000..0542418
> --- /dev/null
> +++ b/src/app/views/layouts/help-and-content.rhtml
> @@ -0,0 +1,6 @@
> +<div id="help-div">
> +  <%= link_to image_tag("icon_help.png"),
> +      {:controller => 'help', :action => @help_section, :anchor => @anchor},
> +      :id=>"help-link", :popup => true %>
> +</div>
> +<%= yield %>
> diff --git a/src/app/views/layouts/redux.rhtml b/src/app/views/layouts/redux.rhtml
> index a985cdd..0918dce 100644
> --- a/src/app/views/layouts/redux.rhtml
> +++ b/src/app/views/layouts/redux.rhtml
> @@ -79,11 +79,17 @@
>     </div>
>  
>     <div id="tabs-and-content-container">
> +
>       <div id="navigation-tabs" style="position:absolute; top:40px; left:250px;">
>         <%= render :partial => '/layouts/navigation_tabs' %>
>       </div> 
>       <div id="main">
>          <div id="content_area">
> +          <div id="help-div">
> +                <%= link_to image_tag("icon_help.png"),
> +                {:controller => 'help', :action => @help_section, :anchor => @anchor},
> +                :id=>"help-link", :popup => true %>
> +          </div>
>            <%= yield  %> <%# the rest of the center and right hand side %>
>          </div>
>       </div>
> diff --git a/src/app/views/layouts/tabs-and-content.rhtml b/src/app/views/layouts/tabs-and-content.rhtml
> index 8aa4183..92eafd2 100644
> --- a/src/app/views/layouts/tabs-and-content.rhtml
> +++ b/src/app/views/layouts/tabs-and-content.rhtml
> @@ -1,3 +1,4 @@
> +
>  <div id="side-toolbar" class="header_menu_wrapper">
>    <%= render :partial => '/layouts/side_toolbar' %>
>  </div>
> @@ -6,5 +7,10 @@
>  </div> 
>  <div id="main">
>    <div id="content_area">
> +   <div id="help-div">
> +    <%= link_to image_tag("icon_help.png"),
> +        {:controller => 'help', :action => @help_section, :anchor => @anchor},
> +        :id=>"help-link", :popup => true %>
> +   </div>
>    </div>
> -</div>
> \ No newline at end of file
> +</div>
> diff --git a/src/db/migrate/023_create_help_sections.rb b/src/db/migrate/023_create_help_sections.rb
> new file mode 100644
> index 0000000..963e8bd
> --- /dev/null
> +++ b/src/db/migrate/023_create_help_sections.rb
> @@ -0,0 +1,13 @@
> +class CreateHelpSections < ActiveRecord::Migration
> +  def self.up
> +    create_table :help_sections do |t|
> +      t.string :controller, :null => false, :limit => 25
> +      t.string :action, :null => false, :limit => 25
> +      t.string :section, :null => false, :limit => 100
> +    end
> +  end
> +
> +  def self.down
> +    drop_table :help_sections
> +  end
> +end
> diff --git a/src/public/stylesheets/layout.css b/src/public/stylesheets/layout.css
> index 9471cdc..013c959 100644
> --- a/src/public/stylesheets/layout.css
> +++ b/src/public/stylesheets/layout.css
> @@ -128,7 +128,7 @@ a { color:#000000; text-decoration: none;}
>  /*  ----- Right side of Header --------  */
>  
>  .header_info {
> -  padding: 10px 20px 0px 10px;
> +  padding: 10px 30px 0px 10px;
>    margin: 0;
>    float: right;
>    text-align: right;
> @@ -140,6 +140,12 @@ a { color:#000000; text-decoration: none;}
>  .header_info a:visited { color: #B5B5B5; text-decoration: none; }
>  .header_info a:hover   { color: #FFFFFF; text-decoration: none; }
>  
> +#help-div {
> +  position: fixed;
> +  top: 10px;
> +  right: -1px;
> +}
> +
>  #textfield_effect {
>      border-width: 1px;
>      border-style: solid;
> diff --git a/src/test/fixtures/help_sections.yml b/src/test/fixtures/help_sections.yml
> new file mode 100644
> index 0000000..5bf0293
> --- /dev/null
> +++ b/src/test/fixtures/help_sections.yml
> @@ -0,0 +1,7 @@
> +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
> +
> +# one:
> +#   column: value
> +#
> +# two:
> +#   column: value
> diff --git a/src/test/unit/help_section_test.rb b/src/test/unit/help_section_test.rb
> new file mode 100644
> index 0000000..a0e6a08
> --- /dev/null
> +++ b/src/test/unit/help_section_test.rb
> @@ -0,0 +1,8 @@
> +require 'test_helper'
> +
> +class HelpSectionTest < ActiveSupport::TestCase
> +  # Replace this with your real tests.
> +  def test_truth
> +    assert true
> +  end
> +end

ACK, this now works for me.

-j




More information about the ovirt-devel mailing list