Class: LayoutInterpreter

Inherits:
DslContext show all
Defined in:
lib/LayoutInterpreter.rb

Instance Method Summary collapse

Methods inherited from DslContext

bubble, execute, polish_text

Instance Method Details

#column(*args) ⇒ Object



52
53
54
# File 'lib/LayoutInterpreter.rb', line 52

def column(*args)
  @erb << "\t\t<td style=\"vertical-align: top;\">\n"
end

#columnsObject



60
61
62
# File 'lib/LayoutInterpreter.rb', line 60

def columns
  @erb << "\t\t<table class=\"columnWrapper\"><tr>\n"
end

#coverage(*args) ⇒ Object



147
148
149
# File 'lib/LayoutInterpreter.rb', line 147

def coverage(*args)
  interpret(COVERAGE_DSL_ROOT, *args)
end

#endcolumnObject



56
57
58
# File 'lib/LayoutInterpreter.rb', line 56

def endcolumn
  @erb << "\t\t</td>\n"
end

#endcolumnsObject



64
65
66
# File 'lib/LayoutInterpreter.rb', line 64

def endcolumns
  @erb << "\t\t</tr></table>\n"
end

#endfooter(*args) ⇒ Object



72
73
74
# File 'lib/LayoutInterpreter.rb', line 72

def endfooter(*args)
  @erb << "\t\t</div>\n"
end

#endheader(*args) ⇒ Object



40
41
42
# File 'lib/LayoutInterpreter.rb', line 40

def endheader(*args)
  @erb << "\t\t</div>\n"
end

#endlayout(*args) ⇒ Object



32
33
34
# File 'lib/LayoutInterpreter.rb', line 32

def endlayout(*args)
   @erb << "</body>"
end

#endminiheader(*args) ⇒ Object



48
49
50
# File 'lib/LayoutInterpreter.rb', line 48

def endminiheader(*args)
  @erb << "\t\t</div>\n"
end

#endpanelObject



84
85
86
# File 'lib/LayoutInterpreter.rb', line 84

def endpanel
  @erb << "\t\t\t</div>\n"
end

#endwidgetObject



139
140
141
# File 'lib/LayoutInterpreter.rb', line 139

def endwidget
  @erb << "\t\t\t <% end %>\n"
end

#entity(*args) ⇒ Object



143
144
145
# File 'lib/LayoutInterpreter.rb', line 143

def entity(*args)
  interpret(ENTITY_DSL_ROOT, *args)
end


68
69
70
# File 'lib/LayoutInterpreter.rb', line 68

def footer(*args)
  @erb << "\t\t<div class=\"footer\">\n"
end

#getResultObject



8
9
10
11
12
13
14
15
# File 'lib/LayoutInterpreter.rb', line 8

def getResult
  widgets = ""
  @widgets.each do |k,v|
    widgets << ",'#{k}'"
  end
  @erb = "<head>\n <%= widgets(#{widgets[1..-1]}) %>\n" +  @erb unless widgets.length == 0
  @erb
end

#header(*args) ⇒ Object



36
37
38
# File 'lib/LayoutInterpreter.rb', line 36

def header(*args)
  @erb << "\t\t<div class=\"header\">\n"
end

#layout(*args) ⇒ Object



25
26
27
28
29
30
# File 'lib/LayoutInterpreter.rb', line 25

def layout(*args)
  @widgets = Hash.new
  @erb = "<%= getCSS('#{args[0]}.css') %>\n"
  @erb << "</head>\n"
  @erb << "<body>\n"
end

#miniheader(*args) ⇒ Object



44
45
46
# File 'lib/LayoutInterpreter.rb', line 44

def miniheader(*args)
  @erb << "\t\t<div class=\"mini-header\">#{args[0]}\n"
end


21
22
23
# File 'lib/LayoutInterpreter.rb', line 21

def navigation(steps)
  @navigationSteps = steps
end

#panel(*args) ⇒ Object



76
77
78
79
80
81
82
# File 'lib/LayoutInterpreter.rb', line 76

def panel(*args)
  if args.length > 0
    @erb << "\t\t\t<div class=\"#{args[0]}\">\n"
  else
    @erb << "\t\t\t<div>\n"
  end
end

#product(*args) ⇒ Object



17
18
19
# File 'lib/LayoutInterpreter.rb', line 17

def product(*args)
  @product = args[0]
end

#product_menu(*args) ⇒ Object



88
89
90
91
92
93
94
95
96
# File 'lib/LayoutInterpreter.rb', line 88

def product_menu(*args)
  #TODO:slidingMenu needs implementing as a single item menu construct
  #that is repeated for each of theargs
  @erb << "\t\t\t"
  @erb << '<%= render :partial => "#{widgetROOT}/sliding_menu/sliding_menu", :locals => { :menuitems => %w('
  @erb << args.join(' ')
  @erb << ') } %>'
  @erb << "\n"
end

#teaser(*args) ⇒ Object



98
99
100
# File 'lib/LayoutInterpreter.rb', line 98

def teaser(*args)
  @erb << "\t\t\t<%= render :partial => \"#\{teaserROOT}/#{args[0]}\" %>\n"
end

#widget(*args) ⇒ Object



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/LayoutInterpreter.rb', line 102

def widget(*args)
  @widgets["#{args[0]}"] = 1

  @erb << "\t\t\t<% #{args[0]} \"#\{widgetROOT}/#{args[0]}\""

  widget_args_hash = args[1]

  if (@navigationSteps.length > 0)
    if (args[0].to_sym == :submit_panel)
      widget_args_hash = {:nextLayout => @navigationSteps[0].to_sym}
    elsif (args[0].to_sym == :button_panel)
      str = "{:button1 => :#{@navigationSteps.first}"
      i = 1
      @navigationSteps.each do |step|
        str << ",:button#{i += 1} => :#{step}" unless step == @navigationSteps.first
      end
      str << "}"
      widget_args_hash = eval(str)
    end
  end


  if (widget_args_hash and widget_args_hash.class.name == "Hash")
    sHash = "{"
    comma = ""
    widget_args_hash.each do |n,v|
      sHash << "#{comma}:#{n} => '#{v}'"
      comma = ","
    end
    sHash << "}"

    @erb << ",\"#{sHash}\" do %>\n"
  else
    @erb << " do %>\n"
  end
end