| Class | DemosController |
| In: |
app/controllers/demos_controller.rb
|
| Parent: | ApplicationController |
Demonstrates some Hpricot functionality
About action in the layout
# File app/controllers/demos_controller.rb, line 226
226: def about
227: end
Similar to demoout but with the application layout
# File app/controllers/demos_controller.rb, line 230
230: def aboutout
231: @myhtml = "<h1>hello world</h1>"
232: @uurl = params[:uurl]
233: @hpexpr = params[:hpexpr]
234: hpricot_object = get_my_hp_elem(@uurl)
235: @myhtml = hpricot_object.search(@hpexpr).to_html
236: render(:layout => "application")
237: end
Wraps hpricot_object.at(atexpr).to_html
# File app/controllers/demos_controller.rb, line 41
41: def at
42: @uurl = params[:uurl]
43: atexpr = params[:atexpr]
44: hpricot_object = get_my_hp_elem(@uurl)
45: @hpexpr = 'hpricot_object.at(' + '"' + atexpr + '"' + ').to_html'
46: @myhtml = hpricot_object.at(atexpr).to_html
47: render(:layout => "nada", :action => "demoout")
48: end
Wraps hpricot_object.search().map{}.to_s
# File app/controllers/demos_controller.rb, line 156
156: def disp_comments
157: @uurl = params[:uurl]
158: searchexpr = params[:searchexpr]
159: @hpexpr = 'hpricot_object.search(' + '"' + searchexpr + '"' + ').map......'
160: @hpexpr = h(@hpexpr)
161: hpricot_object = get_my_hp_elem(@uurl)
162: @myhtml = hpricot_object.search(searchexpr).search("*").map{|e| "<hr />#{e}" if e.comment?}.to_s
163: render(:layout => "nada", :action => "demoout")
164: end
Wraps hpricot_object.search().map{}.to_s
# File app/controllers/demos_controller.rb, line 131
131: def disp_enum
132: @uurl = params[:uurl]
133: searchexpr = params[:searchexpr]
134: @hpexpr = 'i = -1; hpricot_object.search(' + '"' + searchexpr + '"' + ').map{|e| i+=1;"<hr />#{i}#{e}"}.to_s'
135: @hpexpr = h(@hpexpr)
136: hpricot_object = get_my_hp_elem(@uurl)
137: i = -1; @myhtml = hpricot_object.search(searchexpr).map{|e| i+=1;"<hr />#{i} #{e}"}.to_s
138: render(:layout => "nada", :action => "demoout")
139: end
Wraps hpricot_object.search().map{}.slice().to_s
# File app/controllers/demos_controller.rb, line 142
142: def disp_enum_slice
143: @uurl = params[:uurl]
144: searchexpr = params[:searchexpr]
145: arg1= params[:arg1].to_i
146: arg2= params[:arg2].to_i
147: @hpexpr = 'i = -1; hpricot_object.search(' + '"' + searchexpr + '"' + ').map{|e| i+=1;"<hr />#{i}#{e}"}[' + params[:arg1] + ',' + params[:arg2] + '].to_s'
148: @hpexpr = h(@hpexpr)
149: hpricot_object = get_my_hp_elem(@uurl)
150: i = -1; @myhtml = hpricot_object.search(searchexpr).map{|e| i+=1;"<hr />#{i} #{e}"}[arg1, arg2].to_s
151: render(:layout => "nada", :action => "demoout")
152: end
Allows user to see a page full of demo forms
# File app/controllers/demos_controller.rb, line 222
222: def index
223: end
Wraps hpricot_object.search(innerhtmlexpr).inner_html
# File app/controllers/demos_controller.rb, line 51
51: def innerhtml
52: @uurl = params[:uurl]
53: innerhtmlexpr = params[:innerhtmlexpr]
54: hpricot_object = get_my_hp_elem(@uurl)
55: @hpexpr = 'hpricot_object.at(' + '"' + innerhtmlexpr + '"' + ').inner_html'
56: @myhtml = hpricot_object.at(innerhtmlexpr).inner_html
57: render(:layout => "nada", :action => "demoout")
58: end
Wraps hpricot_object.search(searchexpr).remove_attr(attr_name)
# File app/controllers/demos_controller.rb, line 202
202: def remove_attr
203: @uurl = params[:uurl]
204: searchexpr = params[:searchexpr]
205: attr_name = params[:attr_name]
206: @hpexpr = 'hpricot_object.search(' + '"' + searchexpr + '"' + ').remove_attr(' + '"' + attr_name + '"' + ')'
207: hpricot_object = get_my_hp_elem(@uurl)
208: hpricot_object.search(searchexpr).remove_attr(attr_name)
209: @myhtml = hpricot_object.to_html
210: render(:layout => "nada", :action => "demoout")
211: end
Wraps hpricot_object.search().to_html after comments removed
# File app/controllers/demos_controller.rb, line 167
167: def remove_comments
168: @uurl = params[:uurl]
169: searchexpr = params[:searchexpr]
170: @hpexpr = 'hpricot_object.search(' + '"' + searchexpr + '"' + ').search("*").each{|e| (lst=e.parent.children;e.parent=nil;lst.delete(e)) if e.comment?}'
171: @hpexpr = h(@hpexpr)
172: hpricot_object = get_my_hp_elem(@uurl)
173: hpricot_object.search(searchexpr).search("*").each{|e| (lst=e.parent.children;e.parent=nil;lst.delete(e)) if e.comment?}
174: @myhtml = hpricot_object.search(searchexpr).to_html
175: render(:layout => "nada", :action => "demoout")
176: end
Wraps hpricot_object.search(searchexpr).to_html
# File app/controllers/demos_controller.rb, line 9
9: def search
10: @uurl = params[:uurl]
11: searchexpr = params[:searchexpr]
12: @hpexpr = 'hpricot_object.search(' + '"' + searchexpr + '"' + ').to_html'
13: hpricot_object = get_my_hp_elem(@uurl)
14: @myhtml = hpricot_object.search(searchexpr).to_html
15: render(:layout => "nada", :action => "demoout")
16: end
Wraps hpricot_object.search().map {|e| ’<hr />’ + e.get_attribute(#{attrname}) }.sort.to_s
# File app/controllers/demos_controller.rb, line 119
119: def search_attributes
120: @uurl = params[:uurl]
121: searchexpr = params[:searchexpr]
122: attrname = params[:attrname]
123: @hpexpr = "hpricot_object.search(#{searchexpr}).map {|e| '<hr />' + e.get_attribute(#{attrname}) }.sort.to_s"
124: @hpexpr = h(@hpexpr)
125: hpricot_object = get_my_hp_elem(@uurl)
126: @myhtml = hpricot_object.search(searchexpr).map {|e| "<hr />" + e.get_attribute(attrname) }.sort.to_s
127: render(:layout => "nada", :action => "demoout")
128: end
Wraps hpricot_object.search(searchexpr).first.to_html
# File app/controllers/demos_controller.rb, line 61
61: def search_first
62: @uurl = params[:uurl]
63: searchexpr = params[:searchexpr]
64: @hpexpr = 'hpricot_object.search(' + '"' + searchexpr + '"' + ').first.to_html'
65: hpricot_object = get_my_hp_elem(@uurl)
66: @myhtml = hpricot_object.search(searchexpr).first.to_html
67: render(:layout => "nada", :action => "demoout")
68: end
Wraps hpricot_object.search(searchexpr).map {|e| "<hr />#{e.to_html}" }.sort.to_s
# File app/controllers/demos_controller.rb, line 72
72: def search_map
73: @uurl = params[:uurl]
74: searchexpr = params[:searchexpr]
75: @hpexpr = 'hpricot_object.search(' + '"' + searchexpr + '"' + ').map {|e| "<hr />#{e.to_html}" }.sort.to_s'
76: @hpexpr = h(@hpexpr)
77: hpricot_object = get_my_hp_elem(@uurl)
78: @myhtml = hpricot_object.search(searchexpr).map {|e| "<hr />#{e.to_html}" }.sort.to_s
79: render(:layout => "nada", :action => "demoout")
80: end
Wraps hpricot_object.search(searchexpr).prepend("<hr />")
# File app/controllers/demos_controller.rb, line 83
83: def search_prepend
84: @uurl = params[:uurl]
85: searchexpr = params[:searchexpr]
86: @hpexpr = 'hpricot_object.search(' + '"' + searchexpr + '"' + ').prepend("<hr />").to_html'
87: @hpexpr = h(@hpexpr)
88: hpricot_object = get_my_hp_elem(@uurl)
89: @myhtml = hpricot_object.search(searchexpr).prepend("<hr />").to_html
90: render(:layout => "nada", :action => "demoout")
91: end
Wraps hpricot_object.to_html after hpricot_object.search(searchexpr).remove
# File app/controllers/demos_controller.rb, line 19
19: def search_remove
20: @uurl = params[:uurl]
21: searchexpr = params[:hpexpr]
22: @hpexpr = 'hpricot_object.search(' + '"' + searchexpr + '"' + ').remove'
23: hpricot_object = get_my_hp_elem(@uurl)
24: hpricot_object.search(searchexpr).remove
25: @myhtml = hpricot_object.to_html
26: render(:layout => "nada", :action => "demoout")
27: end
Wraps hpricot_object.search(s1expr).search(s2expr).to_html
# File app/controllers/demos_controller.rb, line 30
30: def search_search
31: @uurl = params[:uurl]
32: s1expr = params[:s1expr]
33: s2expr = params[:s2expr]
34: @hpexpr = 'hpricot_object.search(' + '"' + s1expr + '"' + ').search(' + '"' + s2expr + '"' + ').to_html'
35: hpricot_object = get_my_hp_elem(@uurl)
36: @myhtml = hpricot_object.search(s1expr).search(s2expr)
37: render(:layout => "nada", :action => "demoout")
38: end
Wraps hpricot_object.at().swap()
# File app/controllers/demos_controller.rb, line 106
106: def search_swap
107: @uurl = params[:uurl]
108: searchexpr = params[:searchexpr]
109: parentsearchexpr = params[:parentsearchexpr]
110: @hpexpr = 'hpricot_object.at(' + '"' + searchexpr + '"' + ').swap("<h1>hpricot.com</h1>")'
111: @hpexpr = h(@hpexpr)
112: hpricot_object = get_my_hp_elem(@uurl)
113: hpricot_object.at(searchexpr).swap("<h1>hpricot.com</h1>")
114: @myhtml = hpricot_object.search(parentsearchexpr).to_html
115: render(:layout => "nada", :action => "demoout")
116: end
Wraps hpricot_object.search(searchexpr).wrap("<h1>")
# File app/controllers/demos_controller.rb, line 94
94: def search_wrap
95: @uurl = params[:uurl]
96: searchexpr = params[:searchexpr]
97: @hpexpr = 'hpricot_object.search(' + '"' + searchexpr + '"' + ').search("..").to_html'
98: @hpexpr = h(@hpexpr)
99: hpricot_object = get_my_hp_elem(@uurl)
100: hpricot_object.search(searchexpr).wrap("<h1>")
101: @myhtml = hpricot_object.search(searchexpr).search("..").to_html
102: render(:layout => "nada", :action => "demoout")
103: end
# File app/controllers/demos_controller.rb, line 189
189: def text_node_alter
190: @uurl = params[:uurl]
191: old = params[:oldtext]
192: new = params[:newtext]
193: @hpexpr = 'hpricot_object.search("*")' + ".each {|e| e.content=e.content().gsub(Regexp.new('#{old}'), '#{new}') if e.text? }"
194: @hpexpr = h(@hpexpr)
195: hpricot_object = get_my_hp_elem(@uurl)
196: hpricot_object.search("*").each {|e| e.content=e.content().gsub(Regexp.new(old), new) if e.text? }
197: @myhtml = hpricot_object.to_html
198: render(:layout => "nada", :action => "demoout")
199: end
Wraps hpricot_object.search().…
# File app/controllers/demos_controller.rb, line 179
179: def text_search_loose
180: @uurl = params[:uurl]
181: searchexpr = params[:searchexpr]
182: @hpexpr = 'hpricot_object.search(' + '"' + searchexpr + '"' + ').to_html'
183: @hpexpr = h(@hpexpr)
184: hpricot_object = get_my_hp_elem(@uurl)
185: @myhtml = hpricot_object.search(searchexpr).to_html
186: render(:layout => "nada", :action => "demoout")
187: end