Module: Platformx::LayoutHelpers

Defined in:
lib/platformx/layout.rb

Overview

Layout helpers

Instance Method Summary collapse

Instance Method Details

#x_card_bottomString

Card (bottom) view helper

Returns:

  • (String)

    rendered card bottom html



64
65
66
67
68
69
70
# File 'lib/platformx/layout.rb', line 64

def x_card_bottom
panel ="  </div>\n</div>\n"
  return panel
end

#x_card_top(title: "", subtitle: "", card_class: "", header_css: "", buttons: "") ⇒ String

Card (top) view helper

Parameters:

  • title (String) (defaults to: "")

    title of the card

  • subtitle (String) (defaults to: "")

    subtitle of the card

  • card_class (String) (defaults to: "")

    card html classes

  • header_css (String) (defaults to: "")

    header css of the card

  • buttons (String) (defaults to: "")

    card buttons

Returns:

  • (String)

    rendered card top html



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/platformx/layout.rb', line 43

def x_card_top(title: "",subtitle: "", card_class: "", header_css: "", buttons: "")
if title != ""
title="<div class=\"header \#{header_css}\">\n  <h4 class=\"title pull-left\">\#{title}</h4>\n  <div class=\"pull-right title_right\">\#{buttons}</div>\n  <div class=\"clearfix\"></div>\n  <p class=\"category\">\#{subtitle}</p>\n</div>\n"
end
panel ="<div class=\"card \#{card_class}\">\n  \#{title}\n  <div class=\"content\">\n"
  return panel
end

#x_gravitar(email: "") ⇒ String

Gravitar view helper

Parameters:

  • email (String) (defaults to: "")

    email of the user to show the garvitar

Returns:

  • (String)

    gravitar image uri



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/platformx/layout.rb', line 75

def x_gravitar(email: "")
  hash = ""
  
    if !email.nil?
    # get the email from URL-parameters or what have you and make lowercase
    email_address = email.downcase

    # create the md5 hash
    hash = Digest::MD5.hexdigest(email_address)
    end
  # compile URL which can be used in <img src="RIGHT_HERE"...
  image_src = "https://www.gravatar.com/avatar/#{hash}?d=mm"

  return image_src
end

#x_number_widget(label: "", value: "", icon: "") ⇒ String

Dashboard Number Widget

Parameters:

  • label (String) (defaults to: "")

    number widget label

  • value (String) (defaults to: "")

    number widget value

  • icon (String) (defaults to: "")

    number widget icon

Returns:

  • (String)

    rendered number widget



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/platformx/layout.rb', line 131

def x_number_widget(label: "", value: "", icon: "")

icon_html = ""
unless icon == ""
  icon_html = "<i class='fa #{icon}'></i> "
end

widget ="<div class=\"x_number_widget_wrapper\">\n  <div class=\"x_number_widget_value\">\#{value}</div>\n  <div class=\"x_number_widget_label\">\#{icon_html}\#{label}</div>\n</div>\n"

return widget

end

#x_panel_bottomString

Panel bttom view helper

Returns:

  • (String)

    rendered panel bottom html



28
29
30
31
32
33
34
# File 'lib/platformx/layout.rb', line 28

def x_panel_bottom
panel ="  </div>\n  </div>\n"
  return panel
end

#x_panel_top(title: "", panel_class: "") ⇒ String

Panel top view helper

Parameters:

  • title (String) (defaults to: "")

    the title of the panel

  • panel_class (String) (defaults to: "")

    the panel html classes

Returns:

  • (String)

    rendered panel top html



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/platformx/layout.rb', line 10

def x_panel_top(title: "", panel_class: "")
if title != ""
title="  <div class=\"panel-heading\">\n    <h3 class=\"panel-title\">\#{title}</h3>\n  </div>\n"
end
panel ="  <div class=\"panel \#{panel_class}\">\n     \#{title}\n  <div class=\"panel-body\">\n"
  return panel
end

#x_tabs(active: "", tabs: array) ⇒ String

Student Tabs Nav

Parameters:

  • active (String) (defaults to: "")

    tab active

  • tabs (Array) (defaults to: array)

    array of tabs

Returns:

  • (String)

    rendered tabs navigation



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/platformx/layout.rb', line 95

def x_tabs(active: "", tabs: array)

tab_builder = ""

tabs.each do |t|
s = ""
if t[:name] == active
  active_s = "active"
else
  active_s = ""
end
s ="<li class=\"\#{active_s}\">\n  <a href=\"\#{t[:url]}\"><i class=\"fa \#{t[:icon]}\"></i> \#{t[:name]}</a>\n</li>\n"
tab_builder  << s
end

tab_wrapper ="<div class=\"tabs_wrapper\">\n<ul class=\"nav nav-tabs\" role=\"tablist\">\n\#{tab_builder}\n</ul>\n</div>\n"

return tab_wrapper
end