[Ovirt-devel] [PATCH] integrate 'using ovirt' doc into a wui help section
Mohammed Morsi
mmorsi at redhat.com
Wed Oct 1 18:14:50 UTC 2008
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 | 7 ++++++-
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 | 4 ++++
src/app/views/layouts/redux.rhtml | 4 ++++
src/app/views/layouts/tabs-and-content.rhtml | 6 +++++-
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, 57 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 6dcf6f8..0d5521a 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 is_logged_in
redirect_to(:controller => "login", :action => "login") unless get_login_user
@@ -40,6 +40,11 @@ class ApplicationController < ActionController::Base
def get_login_user
(ENV["RAILS_ENV"] == "production") ? session[:user] : "ovirtadmin"
end
+
+ def get_help_section
+ help = HelpSection.find(:first, :conditions => [ "controller = ? AND action = ?", controller_name, action_name ])
+ @help_section = help ? help.section : ""
+ end
def set_perms(hwpool)
@user = get_login_user
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..67989b7
--- /dev/null
+++ b/src/app/views/layouts/help-and-content.rhtml
@@ -0,0 +1,4 @@
+<div id="help-div">
+ <a id="help-link" href="help/<%= @help_section %>" ><%= image_tag "icon_help.png" %></a>
+</div>
+<%= yield %>
diff --git a/src/app/views/layouts/redux.rhtml b/src/app/views/layouts/redux.rhtml
index 01540d4..f6b4657 100644
--- a/src/app/views/layouts/redux.rhtml
+++ b/src/app/views/layouts/redux.rhtml
@@ -109,11 +109,15 @@
</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">
+ <a id="help-link" href="help/<%= @help_section %>" ><%= image_tag "icon_help.png" %></a>
+ </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..e55b5ea 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,8 @@
</div>
<div id="main">
<div id="content_area">
+ <div id="help-div">
+ <a id="help-link" href="help/<%= @help_section %>" ><%= image_tag "icon_help.png" %></a>
+ </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
--
1.5.4.1
More information about the ovirt-devel
mailing list