Class: TagCloudPageMaker

Inherits:
TagCloudMaker show all
Defined in:
lib/tRuTag_full.rb

Instance Method Summary collapse

Methods inherited from TagCloudMaker

about, addStyle, all_tags_rails_href, find_level, space_to_plus, tag

Instance Method Details

#body(cloud, sitename_array) ⇒ Object



213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/tRuTag_full.rb', line 213

def body(cloud, sitename_array)
		
	# This adds the option box with the listing of sites		
	output = %{<div id="site_select">\n<H2>Target Site</H2><FORM>\n<SELECT SIZE=10 NAME="sites" WIDTH=200>}
	
	sitename_array.each_index {|x| 
		output << %{<OPTION VALUE="#{String(x)}">#{sitename_array[x]}</OPTION>}}

	output << %{</SELECT></FORM>}

	# Since I use this as my new homepage I would like a google searchbar.  Hopefully others with find this usefull as well. I've removed the google image
	# because i'm not always online, and it makes the page laod a little faster.
	
	output << TagCloudPageMaker.tag("DIV", %{ ID = "google"} ) {%{<H2>Search</H2><FORM method=GET action="http://www.google.com/search"><input type=hidden name=ie value=UTF-8><input type=hidden name=oe value=UTF-8><TABLE bgcolor="#FFFFFF"><tr><td><A HREF="http://www.google.com/"><strong style="color:#0000ff">G</strong><strong style="color:#ff0000">o</strong><strong style="color:#ffff00">o</strong><strong style="color:#0000ff">g</strong><strong style="color:#00ff00">l</strong><strong style="color:#ff0000">e</strong> Search</A><br><INPUT TYPE=text name=q size=25 maxlength=255 value=""><INPUT type=submit name=btnG VALUE="Google Search"></td></tr></TABLE></FORM>}} 
	 
	output << TagCloudPageMaker.about(%{about}) 
	
	output << %{</div>}

	output << %{<div id="cloud">} << cloud << %{</div>}
end

#jscript(space_replacement_array, tag_url_array, tag_url_array_post) ⇒ Object



192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/tRuTag_full.rb', line 192

def jscript(space_replacement_array, tag_url_array, tag_url_array_post)
	# Here is the beginning of the output page Javascript
	output = %{var targets = new Array();}
	
	tag_url_array.each_index {|x| 
		output << %{\ntargets[#{String(x)}] = '#{tag_url_array[x]}';}}
		
	output << %{\nvar space = new Array();}

	space_replacement_array.each_index {|x| 
		output << %{\nspace[#{String(x)}] = '#{space_replacement_array[x]}';}}
		
	output << %{\nvar post_tag = new Array();}

	tag_url_array_post.each_index {|x| 
		output << %{\npost_tag[#{String(x)}] = '#{tag_url_array_post[x]}';}}

	
	output << %{\nfunction go(tag_name) {\nvar site = document.forms[0].sites;\nvar number = site.options[site.selectedIndex].value;\nif (!number) return;\n	var url = targets[number] + tag_name.replace(/ /, space[number]) + post_tag[number]; \ntop.location.href = url;}}
end

#make(cloud, space_replacement_array, tag_url_array, tag_url_array_post, sitename_array) ⇒ Object



175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/tRuTag_full.rb', line 175

def make(cloud, space_replacement_array, tag_url_array, tag_url_array_post, sitename_array)
	css = File.dirname(__FILE__) + '/../css/tRuTag.css'

	CGI::pretty(
		TagCloudPageMaker.tag("HTML", "") {
			TagCloudPageMaker.tag("HEAD", "") { 
				TagCloudPageMaker.tag("TITLE", "") {"tRuTag Cloud"} + %{<link rel="Stylesheet" href=#{css} type="text/css" media="screen" />\n<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">\n<!--\n#{jscript(space_replacement_array, tag_url_array, tag_url_array_post)}\n// -->\n</SCRIPT>
				} +
				TagCloudPageMaker.tag("BODY", "") {
					body(cloud, sitename_array)
					}
			}
		}
	)

end