Module: Rapid::Web::Bootstrap

Defined in:
lib/rapid/web/bootstrap.rb

Instance Method Summary collapse

Instance Method Details

#bootstrap_body(&block) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/rapid/web/bootstrap.rb', line 23

def bootstrap_body &block
  tags = bootstrap_topnav
  tags << capture_html(&block)
  tags << bootstrap_scripts

  body = tag :body, :content => tags, "data-spy" => "scroll", "data-target" => ".subnav", "data-offset" => "50"
  
  concat_content body
end

#bootstrap_flashObject



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/rapid/web/bootstrap.rb', line 79

def bootstrap_flash
  tags = ""
  
  notice = session.delete :notice
  if notice
    tags << tag(:div, :content => notice, :class => 'alert alert-success')
  end
  
  error = session.delete :error
  if error
    tags << tag(:div, :content => error, :class => 'alert alert-error')
  end
  
  tags
end

#bootstrap_headObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/rapid/web/bootstrap.rb', line 6

def bootstrap_head
  tags = ""
  tags << tag(:meta, :charset => "UTF-8")
  tags << tag(:meta, :name => "description", :content => @description) if @description
  tags << tag(:meta, :name => "author", :content => @author) if @author
  tags << tag(:title, :content => (@title.to_s if @title) || "Rapid Development")
  
  tags << bootstrap_stylesheets
  
  tags << %(<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
  <script src='http://html5shim.googlecode.com/svn/trunk/html5.js'></script>
<![endif]-->)
  
  tag :head, :content => tags
end

#bootstrap_scriptsObject



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/rapid/web/bootstrap.rb', line 47

def bootstrap_scripts
  tags = ""
  
  tags << tag(:script, :content => "", :src => '/rapid/core/jquery-1.7.1.js')
  tags << tag(:script, :content => "", :src => '/rapid/core/prettify.js')
  tags << tag(:script, :content => "", :src => '/rapid/core/bootstrap-collapse.js')
  
  if public_path && File.exists?(File.join(public_path, 'application.js'))
    tags << tag(:script, :content => "", :src => "/rapid/#{rapid_name}/application.js")
  end
  
  tags
end

#bootstrap_stylesheetsObject



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/rapid/web/bootstrap.rb', line 33

def bootstrap_stylesheets
  tags = ""
  
  tags << tag(:link, :href => "/rapid/core/bootstrap.min.css", :rel => "stylesheet")
  tags << tag(:link, :href => "/rapid/core/bootstrap-responsive.min.css", :rel => "stylesheet")
  tags << tag(:link, :href => "/rapid/core/prettify.css", :rel => "stylesheet")
  
  if public_path && File.exists?(File.join(public_path, 'application.css'))
    tags << tag(:link, :href => "/rapid/#{rapid_name}/application.css", :rel => "stylesheet")
  end
  
  tags
end

#bootstrap_topnavObject



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/rapid/web/bootstrap.rb', line 61

def bootstrap_topnav
  %(<div class="navbar">
  <div class="navbar-inner">
    <div class="container">
<a href="#" class="brand">Rapid</a>
<div class="nav-collapse">
  <ul class="nav pull-right">
    <li>
      <a href="#">Link</a>
    </li>
    <li class="divider-vertical"></li>
  </ul>
</div>
    </div>
  </div>
</div>)
end