lapillus 0.0.2 → 0.0.3

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.
@@ -33,6 +33,7 @@ module REXML
33
33
  end
34
34
  end
35
35
 
36
+ require 'lapillus/html_visitor'
36
37
  module Lapillus
37
38
  class Webpage < Container
38
39
 
@@ -40,15 +41,15 @@ module Lapillus
40
41
  super("")
41
42
  end
42
43
 
43
- def render(html=default_htmlfile)
44
- # @html is al File
45
- # html = @html if !@html.nil?
46
- doc = REXML::Document.new html
44
+ def render_2(template=default_htmlfile)
45
+ doc = REXML::Document.new template
47
46
  root_element = doc.root
48
- new_root_element = render_container(root_element)
49
- return doc.doctype.to_s + new_root_element.to_s.gsub('&apos;',"'").gsub('&quot;','"')
47
+ visitor = HtmlVisitor.new(self)
48
+ root_element.accept(visitor)
49
+ return doc.doctype.to_s + visitor.container_output.root.to_s.gsub('&apos;',"'").gsub('&quot;','"')
50
50
  end
51
-
51
+ alias render render_2
52
+
52
53
  def default_htmlfile
53
54
  htmlfile = "html/" + self.class.to_s + ".html"
54
55
  File.new( htmlfile )
@@ -61,7 +62,7 @@ module Lapillus
61
62
  block = parent.class.block(identifier)
62
63
  raise "listview without a block! #{self.path}" if block.nil?
63
64
  value.each_with_index { |item, index|
64
- new_component = ListItem.new(index, item)
65
+ new_component = ListItem.new("item#{index}".intern, :model => item)
65
66
  new_component.parent = self #NOTE: I could do this in the constructor!
66
67
  new_component.instance_exec(item, &block)
67
68
  @components << new_component
@@ -79,23 +80,17 @@ module Lapillus
79
80
  def size #NOTE: move to container?
80
81
  return components.size
81
82
  end
82
- #TODO: remove duplication
83
+ #NOTE: in theory a user could also give a path as a String instead of an index
83
84
  def [](index)
84
85
  index = index.to_i if index.kind_of?(String)
85
86
  return components[index]
86
87
  end
87
- def component(index)
88
- index = index.to_i if index.kind_of?(String)
89
- return components[index]
90
- end
91
88
 
92
- #TODO: result is a duplicate with super class method!
93
- def render_container(listview_element)
94
- result = REXML::Element.new(listview_element)
89
+ def render_children(visitor, listview_element)
95
90
  components.each {|container|
96
- container.render_children(listview_element,result)
91
+ visitor.current_container = container
92
+ container.render_children(visitor, listview_element)
97
93
  }
98
- return result
99
94
  end
100
95
  end
101
96
 
@@ -111,15 +106,12 @@ module Lapillus
111
106
  raise "Unknown key: #{key}" if key!=:model and key!=:property
112
107
  }
113
108
  raise "no block supplied!" if !block_given?
114
- internal_add_component(id) { ListView.new(id, options[:model], options[:property]) }
109
+ internal_add_component(id) { ListView.new(id, options) }
115
110
  internal_add_block(id, block)
116
111
  end
117
112
  end
118
113
 
119
114
  class Form < Container
120
- def initialize(id, value=nil)
121
- super(id, value)
122
- end
123
115
  def on_submit_handler=function
124
116
  @function=function
125
117
  end
@@ -136,7 +128,7 @@ module Lapillus
136
128
  end
137
129
  def post(values)
138
130
  components.each {|component| component.post(values)}
139
- if values.keys.find {|key| key.include?(identifier)}
131
+ if values.keys.find {|key| key.include?(identifier.to_s)}
140
132
  on_submit(values['submit'].nil? ? nil : values['submit'].string)
141
133
  end
142
134
  end
@@ -146,7 +138,7 @@ module Lapillus
146
138
  class BookmarkablePageLink < Container
147
139
  attr_reader :page_parameters, :page_url
148
140
  def initialize(id, page_url, page_parameters)
149
- super(id, nil)
141
+ super(id)
150
142
  @page_url = page_url
151
143
  @page_parameters = page_parameters
152
144
  end
@@ -168,18 +160,16 @@ module Lapillus
168
160
  end
169
161
 
170
162
  class Fragment < Container
171
- def initialize(id, fragment_id, model=nil)
172
- super(id, model)
163
+ def initialize(id, fragment_id, options={})
164
+ super(id, options)
173
165
  @fragment_id = fragment_id
174
166
  end
175
167
 
176
- def render_container(container_element)
177
- root_node=container_element.root
168
+ def render_children(visitor, template_element)
169
+ root_node = template_element.root
178
170
  fragment = REXML::XPath.first( root_node, "//*[@lapillus:id=\"#{@fragment_id}\"]" )
179
171
  raise "Fragment with identifier "+@fragment_id+" not found!" if fragment == nil
180
- new_element = REXML::Element.new(container_element)
181
- render_children(fragment, new_element)
182
- return new_element
172
+ super(visitor, fragment)
183
173
  end
184
174
  end
185
175
 
@@ -200,35 +190,28 @@ module Lapillus
200
190
 
201
191
  #TODO: whats in a name
202
192
  class RemotePanel < Container
203
- def render_container(container_element)
204
- #NOTE: duplicated in Webpage class above
193
+ def render_children(visitor, template_element)
205
194
  doc = REXML::Document.new default_htmlfile
206
195
  root_node = doc.root
207
196
  fragment = REXML::XPath.first( root_node, "//body")
208
197
  raise "Body element not found!" if fragment == nil
209
- new_element = REXML::Element.new(container_element)
210
- render_children(fragment, new_element)
211
- render_to_element(new_element)
212
- render_behaviours(new_element)
213
- return new_element
198
+ super(visitor, fragment)
214
199
  end
215
-
216
- #NOTE: duplicate between render and render_container
217
- def render(html=default_htmlfile)
218
- # @html is al File
219
- # html = @html if !@html.nil?
220
- doc = REXML::Document.new html
200
+
201
+ #duplicate with webpage!
202
+ def render_2(template=default_htmlfile)
203
+ doc = REXML::Document.new template
221
204
  root_element = doc.root
222
- new_element = REXML::Element.new(root_element)
223
- render_children(root_element, new_element)
224
- return doc.doctype.to_s + new_element.to_s
205
+ visitor = HtmlVisitor.new(self)
206
+ root_element.accept(visitor)
207
+ return doc.doctype.to_s + visitor.container_output.root.to_s.gsub('&apos;',"'").gsub('&quot;','"')
225
208
  end
226
-
209
+ alias render render_2
210
+
227
211
  #duplicate with methods in webpage!
228
212
  def default_htmlfile
229
213
  htmlfile = "html/" + self.class.to_s + ".html"
230
214
  File.new( htmlfile )
231
215
  end
232
-
233
216
  end
234
217
  end
@@ -11,6 +11,8 @@ class Dispatcher
11
11
  def Dispatcher.dispatch(cgi, application)
12
12
  # @@guard.synchronize do
13
13
  request_method = cgi.env_table['REQUEST_METHOD']
14
+ # puts "Dispatcher.dispatch(#{cgi},#{application}): request_method=#{request_method}"
15
+ # puts "cgi=#{cgi.to_yaml}"
14
16
  case request_method
15
17
  when "GET"
16
18
  Dispatcher.get(cgi, application)
@@ -29,7 +31,7 @@ class Dispatcher
29
31
  # log = WEBrick::Log.new
30
32
  # log.info("URI path= #{cgi.env_table['PATH_INFO']}")
31
33
 
32
- # puts;puts cgi.env_table.each {|k,v| puts k.to_s+":"+v.to_s};puts
34
+ #puts;puts cgi.env_table.each {|k,v| puts k.to_s+":"+v.to_s};puts
33
35
 
34
36
  session = Dispatcher.get_session(cgi)
35
37
 
@@ -59,27 +61,28 @@ class Dispatcher
59
61
  #NOTICE: non existing cgi variables are return as empty string
60
62
  if cgi.has_key?'menuitem'
61
63
  listener.on_menu(cgi['menuitem'])
62
- store_page_in_session(page,path_info,session)
63
- path_to_redirect_to = cgi.env_table['REQUEST_URI']
64
- path_to_redirect_to = path_to_redirect_to.split("?")[0]
65
- puts "!!"+path_to_redirect_to
66
- cgi.out({"status" => "302", "Location" => path_to_redirect_to}) do
67
- ""
68
- end
69
- # cgi.header("Location" => path_to_redirect_to)
70
- # cgi.out(HTTPHEADER) { page.render }
64
+ render_page_and_store_in_session(request_cycle, page, session, cgi, path_info)
71
65
  return
72
-
73
66
  else
74
67
  if path_to_component!=""
75
68
  component = page[path_to_component]
76
69
  listener.on_drop(component)
70
+ elsif cgi.has_key? 'event'
71
+ parameters=Hash.new
72
+ unnecessary_keys=['listener','event']
73
+ cgi.keys.each{|key|
74
+ parameters[key]=cgi[key] unless unnecessary_keys.include? key
75
+ }
76
+ listener.send(cgi['event'], parameters)
77
+ elsif cgi.has_key? 'periodic_update'
78
+ #puts "[#{Time.new}] has it changed yet?"
77
79
  else
78
80
  listener.on_click
79
81
  end
80
82
  store_page_in_session(page,path_info,session)
81
83
 
82
84
  cgi.out(HTTPHEADER) { listener.render_component }
85
+ #puts "Dispatcher.get: listener.render_component=#{listener.render_component}"
83
86
  return
84
87
  end
85
88
  end
@@ -92,14 +95,6 @@ class Dispatcher
92
95
  page_identifier = application.bookmarkable_pages[pagepath].to_s
93
96
  end
94
97
 
95
- # attribute = "pagemap_#{page_identifier}"
96
- # page = session[attribute][1] if !session[attribute].nil?
97
- page = session[path_info]
98
- if !page.nil? #&& path_info == session[attribute][0]
99
- render_page_and_store_in_session(request_cycle, page, session, cgi, path_info)
100
- return
101
- end
102
-
103
98
  pathparts=path_info.split('/')
104
99
  # puts "pathparts.length #{pathparts.length}"
105
100
  # puts pathparts.join("::")
@@ -116,11 +111,12 @@ class Dispatcher
116
111
  render_page_and_store_in_session(request_cycle, page, session, cgi, path_info)
117
112
  end
118
113
 
114
+ #TODO: add test!
119
115
  def Dispatcher.post(cgi, application)
120
116
  session = Dispatcher.get_session(cgi)
121
117
 
122
118
  request_cycle = RequestCycle.new(session)
123
- RequestCycle.set=request_cycle
119
+ RequestCycle.set(request_cycle)
124
120
  # puts "cgi_page=#{cgi['page'].string}"
125
121
  page = restore_page_from_session(cgi['page'].string, cgi.env_table['PATH_INFO'], session)
126
122
 
@@ -155,6 +151,7 @@ class Dispatcher
155
151
  # page_info = [path_info, page] #value
156
152
  # puts "Storing: "+pagename
157
153
  # puts "STORING path_info: "+path_info
154
+ # puts page.to_yaml
158
155
  session[path_info] = page
159
156
  # NOTE: We need to close the session before we can start streaming the output
160
157
  session.close
@@ -162,18 +159,32 @@ class Dispatcher
162
159
 
163
160
  #TODO: restrict the number of pages remembered
164
161
  def Dispatcher.restore_page_from_session(page_identifier, path_info, session)
165
- #puts "Restoring: "+page_identifier
162
+ # puts "Restoring: "+page_identifier
166
163
  # attribute = "pagemap_#{page_identifier}"
167
- # puts "RESTORING path_info: "+path_info
168
164
  # page_info = session[attribute]
165
+ # puts "RESTORING path_info: "+path_info
169
166
  # page = page_info[1]
170
- # puts "session=#{session.to_yaml}"
171
- # puts "path_info=[#{path_info}]"
167
+ # puts "session=<#{session.to_yaml}>"
168
+ # puts "path_info=[#{path_info}]"
172
169
  page = session[path_info]
173
170
  raise "page expired!" if (page==nil)
174
171
  return page #if path_info == page_info[0]
175
172
  # return nil
176
173
  end
174
+ def dump_cookies(cgi)
175
+ puts cgi.cookies.each_value { |cookie|
176
+ puts "name #{cookie.name}"
177
+ puts "values #{ cookie.value }"
178
+ puts "valuesize #{ cookie.value.size }"
179
+ # if cookie.value.size == 2
180
+ # cookie.value = cookie.values[1]
181
+ # end
182
+ puts "path #{ cookie.path }"
183
+ puts "domain #{ cookie.domain }"
184
+ puts "expires #{ cookie.expires }"
185
+ puts "secure #{ cookie.secure }"
186
+ }
187
+ end
177
188
  end
178
189
 
179
190
 
@@ -9,6 +9,7 @@ module Lapillus
9
9
  def render_to_element(element)
10
10
  element.attributes['name'] = path
11
11
  end
12
+
12
13
  def value
13
14
  return super if has_model?
14
15
  return parent.model.send(identifier) if parent.has_model?
@@ -22,14 +23,17 @@ module Lapillus
22
23
  model.send(property.to_s+"=", new_value)
23
24
  end
24
25
  end
25
-
26
26
  end
27
27
 
28
28
  class FormTextComponent < FormComponent
29
+ def initialize(id, options={})
30
+ options[:model] = '' if options[:model].nil?
31
+ super(id, options)
32
+ end
33
+
29
34
  def render_to_element(element)
30
35
  super
31
36
  text = value
32
- text = '' if text.nil? # TODO: should this be done here, or is this the responsibility of the model ?
33
37
  render_text(element, text)
34
38
  end
35
39
 
@@ -51,7 +55,7 @@ module Lapillus
51
55
  options.keys.each {|key|
52
56
  raise "Unknown key: #{key}" if key!=:model and key!=:property
53
57
  }
54
- internal_add_component(id) { TextField.new(id, options[:model]||"", options[:property]) }
58
+ internal_add_component(id) { TextField.new(id, options)}
55
59
  end
56
60
 
57
61
  class TextArea < FormTextComponent
@@ -64,7 +68,7 @@ module Lapillus
64
68
  options.keys.each {|key|
65
69
  raise "Unknown key: #{key}" if key!=:model and key!=:property
66
70
  }
67
- internal_add_component(id) { TextArea.new(id, options[:model]||"", options[:property]) }
71
+ internal_add_component(id) { TextArea.new(id, options) }
68
72
  end
69
73
 
70
74
  class FileUploadField < FormComponent
@@ -74,7 +78,7 @@ module Lapillus
74
78
  options.keys.each {|key|
75
79
  raise "Unknown key: #{key}" if key!=:model and key!=:property
76
80
  }
77
- internal_add_component(id) { FileUploadField.new(id, options[:model]||"", options[:property]) }
81
+ internal_add_component(id) { FileUploadField.new(id, options) }
78
82
  end
79
83
 
80
84
  class PasswordTextField < TextField
@@ -82,7 +86,7 @@ module Lapillus
82
86
  end
83
87
  end
84
88
 
85
- def Container.password_textfield(id, model="", options={})
86
- internal_add_component(id) { PasswordTextField.new(id, model, options[:property]) }
89
+ def Container.password_textfield(id, options={})
90
+ internal_add_component(id) { PasswordTextField.new(id, options) }
87
91
  end
88
92
  end
@@ -0,0 +1,68 @@
1
+ module Lapillus
2
+ class NullComponent < RenderableComponent
3
+ #TODO: move to standard container class?
4
+ def render_children(visitor, element)
5
+ element.children.each do |child|
6
+ # puts child.class
7
+ child.accept(visitor)
8
+ end
9
+ end
10
+ end
11
+
12
+ class HtmlVisitor
13
+ #INFO: there are 4 elements to remember
14
+ #INFO: 1 current template html element
15
+ #INFO: 2 current output html element
16
+ #INFO: 3 current component to render
17
+ #INFO: 4 current container to get components from
18
+ attr_accessor :container_output #TODO: rename!
19
+ attr_accessor :current_container
20
+
21
+ def initialize(webpage)
22
+ @container_output = REXML::Document.new
23
+ @current_container = webpage
24
+ end
25
+
26
+ def visit_element(element)
27
+ return if element.name=="fragment"
28
+ #puts "rendering: #{element.name}"
29
+ component_id = element.attributes['lapillus:id']
30
+ if !component_id.nil?
31
+ child_component = current_container[component_id]
32
+ else
33
+ child_component = NullComponent.new
34
+ end
35
+
36
+ child_component.render_container(self, element)
37
+ end
38
+ def visit_text(text)
39
+ container_output.add_text(text.value)
40
+ end
41
+ def visit_comment(comment)
42
+ new_comment = REXML::Comment.new(comment)
43
+ container_output.add(new_comment)
44
+ end
45
+ end
46
+ end
47
+
48
+
49
+
50
+
51
+ require 'rexml/document'
52
+ module REXML
53
+ class Element
54
+ def accept(visitor)
55
+ visitor.visit_element(self)
56
+ end
57
+ end
58
+ class Text
59
+ def accept(visitor)
60
+ visitor.visit_text(self)
61
+ end
62
+ end
63
+ class Comment
64
+ def accept(visitor)
65
+ visitor.visit_comment(self)
66
+ end
67
+ end
68
+ end
@@ -12,12 +12,12 @@ module Lapillus
12
12
  @pages = pages
13
13
  @current = 1
14
14
  @block = block
15
- @navigation = Lapillus::Container.new("navigation")
16
- @first_button = FirstButton.new("first", self)
17
- @previous_button = PreviousButton.new("previous", self)
18
- @next_button = NextButton.new("next", self)
19
- @last_button = LastButton.new("last", self)
20
- @position = Label.new("position")
15
+ @navigation = Lapillus::Container.new(:navigation)
16
+ @first_button = FirstButton.new(:first, self)
17
+ @previous_button = PreviousButton.new(:previous, self)
18
+ @next_button = NextButton.new(:next, self)
19
+ @last_button = LastButton.new(:last, self)
20
+ @position = Label.new(:position)
21
21
  navigation.add(first_button)
22
22
  navigation.add(previous_button)
23
23
  navigation.add(next_button)
@@ -30,7 +30,7 @@ module Lapillus
30
30
  #components are recreated and stuff; split in constructor/on_render
31
31
  #also parent and path do not work
32
32
  def build_hierarchy
33
- @page_container = ListItem.new("page")
33
+ @page_container = ListItem.new(:page)
34
34
  @page_container.parent = self #NOTE: I could do this in the constructor!
35
35
  if !@pages.empty?
36
36
  @page_container.instance_exec(page_content, &@block)
@@ -52,7 +52,7 @@ module Lapillus
52
52
  #TODO: rewrite using closures
53
53
  class PagerButton < Lapillus::AjaxLink
54
54
  def initialize(id, pager)
55
- super(id, pager) #pager is the container to be refreshed!
55
+ super(id, :model => pager) #pager is the container to be refreshed!
56
56
  @pager = pager
57
57
  end
58
58
  end
data/test/tc_base.rb CHANGED
@@ -25,7 +25,7 @@ class TC_Base < Test::Unit::TestCase
25
25
  #TODO assert exception raised when model is not set!
26
26
  def test_component_model_without_symbol
27
27
  model = Object.new
28
- component = Component.new(:identifier, model)
28
+ component = Component.new(:identifier, :model => model)
29
29
  assert_equal(model, component.model)
30
30
  assert_equal(model, component.value)
31
31
  end
@@ -42,7 +42,7 @@ class TC_Base < Test::Unit::TestCase
42
42
  #Note: value test without property is already done in test_component_model_without_symbol
43
43
  def test_component_value_with_property
44
44
  person = Person.new("Jantje")
45
- component = Component.new(:id, person, :name)
45
+ component = Component.new(:id, :model => person, :property => :name)
46
46
  assert_equal(person, component.model)
47
47
  assert_equal(person.name, component.value)
48
48
  end
@@ -2,25 +2,27 @@ require 'test/unit'
2
2
  require 'rexml/document'
3
3
  require 'lapillus'
4
4
 
5
+ include Lapillus
6
+
5
7
  class TC_Behaviours < Test::Unit::TestCase
6
8
  def setup
7
9
  super()
8
10
  @html = "<html><span lapillus:id='component'/></html>"
9
- @component = Label.new("component", "")
11
+ @component = Label.new(:component, :model => "")
10
12
  @webpage = Webpage.new
11
13
  end
12
14
 
13
15
  attr_reader :html, :component, :webpage
14
16
 
15
17
  def test_attribute_modifier
16
- component.add_behaviour(AttributeModifier.new("title", "hover"))
18
+ component.add_behaviour(AttributeModifier.new(:title, :model => "hover"))
17
19
  webpage.add(component)
18
20
  output = webpage.render(html)
19
21
  assert_equal("<html><span title=\"hover\" lapillus:id=\"component\"></span></html>", output)
20
22
  end
21
23
 
22
24
  def test_fade_in
23
- component.add_behaviour(FadeIn.new("onmouseover", "id_of_component_to_fade_in"))
25
+ component.add_behaviour(FadeIn.new(:onmouseover, :model => "id_of_component_to_fade_in"))
24
26
  webpage.add(component)
25
27
  output = webpage.render(html)
26
28
  assert_equal("<html><span onmouseover=\"new Effect.Appear('id_of_component_to_fade_in');\" lapillus:id=\"component\"></span></html>", output)
@@ -44,7 +46,7 @@ class TC_Behaviours < Test::Unit::TestCase
44
46
  html="<html><div id='parent'><span lapillus:id='component'/></div></html>"
45
47
  webpage.add(component)
46
48
  output = webpage.render(html)
47
- path=component.path
49
+ # path=component.path
48
50
  expected = "<html><div id=\"parent\"><span id=\"component\" lapillus:id=\"component\"><script language=\"javascript\" type=\"text/javascript\">\n// <![CDATA[\n Droppables.add('component', {\n onDrop: function(element) { \n new Ajax.Updater('component', '', { \n method:'get', parameters: { \n listener:'component',\n component:element.id\n }\n }); return false;\n }\n });\n// ]]>\n</script></span></div></html>"
49
51
  assert_equal(expected, output)
50
52
  end
@@ -73,7 +75,7 @@ class TC_Behaviours < Test::Unit::TestCase
73
75
  end
74
76
 
75
77
  def test_ajax_link_rendering
76
- link = AjaxLink.new("ajaxlink")
78
+ link = AjaxLink.new(:ajaxlink)
77
79
  webpage.add(link)
78
80
  output = webpage.render("<html><a lapillus:id='ajaxlink'>de link text</a></html>")
79
81
  javascript = "new Ajax.Request('', { method: 'get', parameters: { listener:'#{link.path}' }}); return false;"
@@ -96,11 +98,31 @@ class TC_Behaviours < Test::Unit::TestCase
96
98
  def webpage.default_htmlfile
97
99
  return "<html><span lapillus:id='panel'></span><lapillus:fragment lapillus:id='fragment'>expected result</lapillus:fragment></html>"
98
100
  end
99
- fragment = Fragment.new("panel", "fragment")
100
- link = MyAjaxLink.new("link", fragment)
101
+ fragment = Fragment.new(:panel, "fragment")
102
+ link = MyAjaxLink.new(:link, fragment)
101
103
  webpage.add(fragment)
102
104
  webpage.add(link)
103
105
  assert_equal("expected result", link.on_click)
104
106
 
105
107
  end
108
+
109
+ class AjaxFormPage < Webpage
110
+ def initialize()
111
+ super()
112
+ form = Form.new(:form)
113
+ form.add_behaviour(PostWithAjax.new(form))
114
+ add(form)
115
+ end
116
+ end
117
+
118
+ def test_form_with_ajax_post
119
+ page = AjaxFormPage.new
120
+ result = page.render("<html><form lapillus:id='form'></form></html>")
121
+ expected = <<END
122
+ <html><form enctype=\"multipart/form-data\" onsubmit=\"new Ajax.Updater('form', '', { evalScripts: true, method: 'post', parameters:Form.serialize(this)}); return false;\" method=\"post\" id=\"form\" lapillus:id=\"form\"><input name=\"page\" type=\"hidden\" value=\"TC_Behaviours::AjaxFormPage\"/></form></html>
123
+ END
124
+ assert_equal(expected.strip, result)
125
+
126
+ end
127
+
106
128
  end
@@ -15,19 +15,19 @@ class TC_BookmarkablePageLink < Test::Unit::TestCase
15
15
 
16
16
  def test_bookmarkablepagelink
17
17
  webpage = Webpage.new
18
- webpage.add(BookmarkablePageLink.new("myLink", "", Hash[:key => 'value']))
18
+ webpage.add(BookmarkablePageLink.new(:myLink, "", Hash[:key => 'value']))
19
19
  html = html_template('<a href="#" lapillus:id="myLink">click here</a>')
20
20
  result = webpage.render(html)
21
21
  assert_equal(expected_html('<a href="/key/value" lapillus:id="myLink">click here</a>'), result)
22
22
  end
23
23
 
24
24
  class MyLink < BookmarkablePageLink
25
- label 'text', :model => "this text should be visible"
25
+ label :text, :model => "this text should be visible"
26
26
  end
27
27
 
28
28
  def test_bookmarkablepagelink_with_label
29
29
  webpage = Webpage.new
30
- webpage.add(MyLink.new("myLink", "", Hash[:key => 'value']))
30
+ webpage.add(MyLink.new(:myLink, "", Hash[:key => 'value']))
31
31
  html = html_template('<a href="#" lapillus:id="myLink"><span lapillus:id="text">link_text</span></a>')
32
32
  expected = expected_html('<a href="/key/value" lapillus:id="myLink"><span lapillus:id="text">this text should be visible</span></a>')
33
33
  result = webpage.render(html)
@@ -36,7 +36,7 @@ class TC_BookmarkablePageLink < Test::Unit::TestCase
36
36
 
37
37
  def test_bookmarkablepagelink_with_baseurl
38
38
  webpage = Webpage.new
39
- webpage.add(BookmarkablePageLink.new("myLink", "/base/page", Hash[:key => 'value']))
39
+ webpage.add(BookmarkablePageLink.new(:myLink, "/base/page", Hash[:key => 'value']))
40
40
  html = html_template('<a href="#" lapillus:id="myLink">text</a>')
41
41
  expected = expected_html('<a href="/base/page/key/value" lapillus:id="myLink">text</a>')
42
42
  result = webpage.render(html)
@@ -47,7 +47,7 @@ class TC_BookmarkablePageLink < Test::Unit::TestCase
47
47
 
48
48
  def test_bookmarkablepagelink_with_multiple_page_parameters
49
49
  webpage = Webpage.new
50
- webpage.add(BookmarkablePageLink.new("myLink", "", Hash["key" => 'value', "sleutel" => 'waarde']))
50
+ webpage.add(BookmarkablePageLink.new(:myLink, "", Hash["key" => 'value', "sleutel" => 'waarde']))
51
51
  html = html_template('<a href="#" lapillus:id="myLink">click here</a>')
52
52
  result = webpage.render(html)
53
53
  expected = expected_html('<a href="/key/value/sleutel/waarde" lapillus:id="myLink">click here</a>')