xebec 2.6.0 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -2,4 +2,5 @@
2
2
  */.DS_Store
3
3
  doc/rdoc
4
4
  .yardoc
5
+ .bundle
5
6
  pkg
@@ -4,13 +4,13 @@ task :doc => ['doc:generate']
4
4
  namespace :doc do
5
5
  project_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
6
6
  doc_destination = File.join(project_root, 'doc', 'rdoc')
7
-
7
+
8
8
  begin
9
9
  require 'yard'
10
10
  require 'yard/rake/yardoc_task'
11
11
 
12
12
  YARD::Rake::YardocTask.new(:generate) do |yt|
13
- yt.files = Dir.glob(File.join(project_root, '{lib,doc/example_app}', '**', '*.rb')) +
13
+ yt.files = Dir.glob(File.join(project_root, '{lib,doc/example_app}', '**', '*.rb')) +
14
14
  [ File.join(project_root, 'README.md') ]
15
15
  yt.options = ['--output-dir', doc_destination, '--readme', 'README.md']
16
16
  end
@@ -25,5 +25,5 @@ namespace :doc do
25
25
  task :clean do
26
26
  rm_r doc_dir if File.exists?(doc_destination)
27
27
  end
28
-
28
+
29
29
  end
@@ -6,7 +6,7 @@ lib_directories = FileList.new do |fl|
6
6
  fl.include "#{project_root}/lib"
7
7
  fl.include "#{project_root}/test/lib"
8
8
  end
9
-
9
+
10
10
  test_files = FileList.new do |fl|
11
11
  fl.include "#{project_root}/test/**/*_test.rb"
12
12
  fl.exclude "#{project_root}/test/test_helper.rb"
@@ -1,21 +1,21 @@
1
1
  # Part of an example application showing the
2
2
  # many features of Xebec.
3
3
  class ApplicationController < ActionController::Base
4
-
4
+
5
5
  # If you prefer to declare your navigation in your
6
6
  # controllers, start by including Xebec's controller support:
7
7
  include Xebec::ControllerSupport
8
-
8
+
9
9
  # then declare and populate some navigation bars:
10
10
  nav_bar :area do |nb|
11
11
  nb.nav_item :projects # assumes projects_path
12
12
  end
13
-
13
+
14
14
  nav_bar :footer do |nb|
15
15
  nb.nav_item :about_us, page_path(:about_us)
16
16
  nb.nav_item :faq, page_path(:faq)
17
17
  nb.nav_item :feedback, page_path(:feedback)
18
18
  nb.nav_item :privacy_policy, page_path(:privacy_policy)
19
19
  end
20
-
20
+
21
21
  end
@@ -5,5 +5,5 @@ class PagesController < ApplicationController
5
5
  def show
6
6
  render :action => params[:page]
7
7
  end
8
-
8
+
9
9
  end
@@ -1,11 +1,11 @@
1
1
  # Part of an example application showing the
2
2
  # many features of Xebec.
3
3
  class ProjectsController < ApplicationController
4
-
4
+
5
5
  # set the selected item for the :area navigation bar
6
6
  # for all actions in this controller:
7
7
  nav_bar(:area) { |nb| nb.current = :projects }
8
-
8
+
9
9
  def index
10
10
  params[:sort] ||= 'recent'
11
11
  # set up tabs for the project-list view:
@@ -16,26 +16,26 @@ class ProjectsController < ApplicationController
16
16
  end
17
17
  @projects = Project.ordered_by(params[:sort])
18
18
  end
19
-
19
+
20
20
  def show(selected_tab = :overview)
21
21
  @project = Project.find(params[:id])
22
22
  prepare_project_tabs selected_tab
23
23
  end
24
-
24
+
25
25
  def budget
26
26
  show :budget
27
27
  end
28
-
28
+
29
29
  def history
30
30
  show :history
31
31
  end
32
-
32
+
33
33
  def edit
34
34
  show :edit
35
35
  end
36
-
36
+
37
37
  protected
38
-
38
+
39
39
  # Extract navigation bar setup that is common to
40
40
  # multiple methods:
41
41
  def prepare_project_tabs(selected)
@@ -47,5 +47,5 @@ class ProjectsController < ApplicationController
47
47
  nb.current = selected
48
48
  end
49
49
  end
50
-
50
+
51
51
  end
@@ -1,4 +1,4 @@
1
- <%=
1
+ <%=
2
2
  # If you want to keep your navigation code in your views, you might
3
3
  # want to use partials like this one. Notice that this tag is an
4
4
  # "output" tag (%= as opposed to %). That means that the
@@ -3,7 +3,7 @@
3
3
  <nav> is an HTML5 tag that browsers except IE suppor. By default,
4
4
  Xebec will generate a <div class='navbar'> instead of a <nav>
5
5
  element if it detects IE.
6
-
6
+
7
7
  @see Xebec::HTML5 for more information
8
8
  */
9
9
 
@@ -22,12 +22,12 @@ div.navbar :hover, div.navbar .current {
22
22
  nav.<%= bar -%>, div.navbar.<%= bar -%> {
23
23
  /* styles specific to the <%= bar -%> navigation bar here */
24
24
  }
25
-
25
+
26
26
  nav.<%= bar -%> .current, div.navbar.<%= bar -%> .current {
27
27
  /* styles specific to the currently-selected element in
28
28
  the <%= bar -%> navigation bar here */
29
29
  }
30
-
30
+
31
31
  nav.<%= bar -%> :hover, div.navbar.<%= bar -%> :hover {
32
32
  /* styles specific to a hovered-over element in
33
33
  the <%= bar -%> navigation bar here */
data/lib/xebec.rb CHANGED
@@ -1,25 +1,25 @@
1
1
  require 'xebec/nav_bar_renderer'
2
2
 
3
3
  module Xebec
4
-
4
+
5
5
  class <<self
6
-
6
+
7
7
  # The CSS class that is added to navigation items that are
8
8
  # "active." Defaults to "current."
9
9
  attr_accessor :currently_selected_nav_item_class
10
-
10
+
11
11
  # The navigation bar renderer class. Defaults to
12
12
  # Xebec::NavBarRenderer
13
13
  #
14
14
  # @see Xebec::NavBarRenderer
15
15
  attr_accessor :renderer_class
16
-
16
+
17
17
  end
18
18
  self.currently_selected_nav_item_class = :current
19
19
  self.renderer_class = Xebec::NavBarRenderer
20
-
20
+
21
21
  autoload :NavBarHelper, 'xebec/nav_bar_helper'
22
22
  autoload :ControllerSupport, 'xebec/controller_support'
23
23
  autoload :StylesheetGenerator, 'xebec/stylesheet_generator'
24
-
24
+
25
25
  end
@@ -1,20 +1,20 @@
1
1
  require 'xebec/has_nav_bars'
2
2
 
3
3
  module Xebec
4
-
4
+
5
5
  # Include this module in Rails controllers if you want to declare
6
6
  # navigation bars in your controllers instead of or in addition to
7
7
  # in your views.
8
8
  module ControllerSupport
9
-
9
+
10
10
  def self.included(base)
11
11
  base.extend Xebec::ControllerSupport::ClassMethods
12
12
  base.send :include, Xebec::ControllerSupport::InstanceMethods
13
13
  base.send :include, Xebec::HasNavBars
14
14
  end
15
-
15
+
16
16
  module ClassMethods
17
-
17
+
18
18
  # Declare and populate a navigation bar. This method
19
19
  # is a shorthand for creating a +before_filter+ that looks
20
20
  # up and populates a navigation bar.
@@ -45,11 +45,11 @@ module Xebec
45
45
  end
46
46
  nil
47
47
  end
48
-
48
+
49
49
  end
50
-
50
+
51
51
  module InstanceMethods
52
-
52
+
53
53
  # Declare and populate a navigation bar.
54
54
  #
55
55
  # @param [String, Symbol] name the name of the navigation bar
@@ -57,7 +57,7 @@ module Xebec
57
57
  # @yield [Xebec::NavBar] nav_bar the navigation bar. The block
58
58
  # is evaluated in the scope of the
59
59
  # controller instance.
60
- #
60
+ #
61
61
  # @return [Xebec::NavBar]
62
62
  #
63
63
  # @example
@@ -69,9 +69,9 @@ module Xebec
69
69
  def nav_bar(name = Xebec::NavBar::DEFAULT_NAME, &block)
70
70
  look_up_nav_bar_and_eval name, &block
71
71
  end
72
-
72
+
73
73
  end
74
-
74
+
75
75
  end
76
-
76
+
77
77
  end
@@ -1,13 +1,13 @@
1
1
  require 'xebec/nav_bar'
2
2
 
3
3
  module Xebec
4
-
4
+
5
5
  # A supporting mixin for NavBarHelper and ControllerSupport.
6
6
  # Looks up navigation bars by name.
7
7
  module HasNavBars #:nodoc:
8
-
8
+
9
9
  protected
10
-
10
+
11
11
  # Looks up the named nav bar, creates it if it
12
12
  # doesn't exist, and evaluates the the block, if
13
13
  # given, in the scope of +self+, yielding the nav bar.
@@ -21,17 +21,17 @@ module Xebec
21
21
  block.bind(self).call(bar) if block_given?
22
22
  end
23
23
  end
24
-
24
+
25
25
  def look_up_nav_bar(name, html_attributes, options = {})
26
26
  (nav_bars[name] ||= NavBar.new(name, html_attributes)).tap do |bar|
27
27
  bar.html_attributes.merge!(html_attributes)
28
28
  end
29
29
  end
30
-
30
+
31
31
  def nav_bars
32
32
  @nav_bars ||= HashWithIndifferentAccess.new
33
33
  end
34
-
34
+
35
35
  end
36
-
36
+
37
37
  end
data/lib/xebec/html5.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  module Xebec
2
-
2
+
3
3
  def self.html5_for_all_browsers!
4
4
  Xebec::HTML5.force = true
5
5
  end
6
-
6
+
7
7
  # Xebec will help you transition your site to HTML 5
8
8
  # by using the <tt>&lt;nav></tt> element like so:
9
9
  #
@@ -29,7 +29,7 @@ module Xebec
29
29
  # That, unfortunately messes with your CSS selectors. Xebec,
30
30
  # therefore, has a slightly more intelligent default behavior.
31
31
  # If it detects a browser that does not support HTML5 elements,
32
- # it will replace the <tt>&lt;nav></tt> element with a
32
+ # it will replace the <tt>&lt;nav></tt> element with a
33
33
  # <tt>&lt;div class='navbar'></tt>.
34
34
  #
35
35
  # Some enterprising folks have found a workaround for IE, however.
@@ -45,19 +45,19 @@ module Xebec
45
45
  # @see Xebec::NavBarHelper.add_html5_dom_elements_to_ie
46
46
  # See also the example application.
47
47
  module HTML5
48
-
48
+
49
49
  class <<self
50
50
  attr_accessor :force
51
51
  end
52
52
  self.force = false
53
-
53
+
54
54
  NON_HTML_5_USER_AGENTS = /msie/i
55
-
55
+
56
56
  def user_agent_supports_html5?
57
57
  return true if Xebec::HTML5.force
58
58
  return !(NON_HTML_5_USER_AGENTS === request.user_agent)
59
59
  end
60
-
60
+
61
61
  end
62
-
62
+
63
63
  end
data/lib/xebec/nav_bar.rb CHANGED
@@ -1,16 +1,16 @@
1
1
  require 'xebec/nav_item'
2
2
 
3
3
  module Xebec
4
-
4
+
5
5
  class NavBar
6
-
6
+
7
7
  DEFAULT_NAME = :default
8
-
8
+
9
9
  attr_reader :name
10
10
  attr_reader :items
11
11
  attr_reader :html_attributes
12
12
  attr_accessor :current
13
-
13
+
14
14
  # Create a new NavBar object.
15
15
  #
16
16
  # @param [String] name the name of the navigation bar; defaults to :default
@@ -22,7 +22,7 @@ module Xebec
22
22
  @items = []
23
23
  @current = nil
24
24
  end
25
-
25
+
26
26
  # Add a navigation item to this bar.
27
27
  #
28
28
  # @param [String, Symbol] name the name of the item
@@ -36,19 +36,19 @@ module Xebec
36
36
  def nav_item(name, href = nil)
37
37
  items << Xebec::NavItem.new(name, href)
38
38
  end
39
-
39
+
40
40
  def empty?
41
41
  items.empty?
42
42
  end
43
-
43
+
44
44
  def to_s
45
45
  "<NavBar #{name}>"
46
46
  end
47
-
47
+
48
48
  def inspect
49
49
  "<NavBar #{name}: #{items.map(&:name).join('|')}>"
50
50
  end
51
-
51
+
52
52
  end
53
-
53
+
54
54
  end
@@ -3,12 +3,12 @@ require 'xebec/nav_bar_renderer'
3
3
  require 'xebec/has_nav_bars'
4
4
 
5
5
  module Xebec
6
-
6
+
7
7
  module NavBarHelper
8
-
8
+
9
9
  include Xebec::HasNavBars
10
10
  include Xebec::HTML5
11
-
11
+
12
12
  # If called in an output expression ("<%= navbar %>" in ERB
13
13
  # or "=navbar" in HAML), renders the navigation bar.
14
14
  #
@@ -17,7 +17,7 @@ module Xebec
17
17
  # # => <ul class="navbar tabs">...</ul>
18
18
  #
19
19
  # @see Xebec::NavBarRenderer#to_s
20
- #
20
+ #
21
21
  # If called with a block, yields the underlying NavBar for
22
22
  # modification.
23
23
  #
@@ -34,7 +34,7 @@ module Xebec
34
34
  def nav_bar(name = nil, html_attributes = {}, options = {}, &block)
35
35
  look_up_nav_bar_and_eval name, html_attributes, options, &block
36
36
  end
37
-
37
+
38
38
  # Renders a navigation bar if and only if it contains any
39
39
  # navigation items. Unlike +nav_bar+, this method does not
40
40
  # accept a block.
@@ -44,7 +44,7 @@ module Xebec
44
44
  bar = look_up_nav_bar name, html_attributes
45
45
  bar.empty? ? '' : bar
46
46
  end
47
-
47
+
48
48
  # Renders a <tt>&lt;script></tt> tag that preloads HTML5
49
49
  # tags in IE. Useful if you called
50
50
  # <tt>Xebec.html5_for_all_browsers!</tt> in your
@@ -53,14 +53,14 @@ module Xebec
53
53
  # @see Xebec::HTML5
54
54
  def add_html5_dom_elements_to_ie
55
55
  return <<-EOS
56
- <!--[if IE]>
56
+ <!--[if lt IE 9]>
57
57
  <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
58
58
  <![endif]-->
59
59
  EOS
60
60
  end
61
-
61
+
62
62
  protected
63
-
63
+
64
64
  # Override HasNavBars#look_up_nav_bar to replace with a
65
65
  # renderer if necessary.
66
66
  def look_up_nav_bar(name, html_attributes, options = {})
@@ -71,7 +71,7 @@ EOS
71
71
  end
72
72
  bar
73
73
  end
74
-
74
+
75
75
  end
76
-
76
+
77
77
  end