Class: String
Constant Summary
Constants included from Marlene
Marlene::ANCHOR_TEXTNODE, Marlene::BOOKMARKLET_PAGE, Marlene::LOADER_SCRIPT, Marlene::PSEUDOCOL
Instance Method Summary collapse
-
#compress ⇒ Object
use YUI compressor to minimize javascript code.
-
#to_bookmarklet ⇒ Object
transform into bookmarklet.
-
#to_bookmarklet_page ⇒ Object
insert bookmarklet into html code for drag-drop bookmarklet up to linkbar.
-
#to_loader_script ⇒ Object
insert into loader script a javascript URL.
Methods included from Marlene
Instance Method Details
#compress ⇒ Object
use YUI compressor to minimize javascript code
37 38 39 |
# File 'lib/marlene.rb', line 37 def compress yui_compressor.compress(self) end |
#to_bookmarklet ⇒ Object
transform into bookmarklet
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/marlene.rb', line 24 def to_bookmarklet js = self.to_s js.gsub!(/^ +/, '') # remove line-leading whitespace js.gsub!(/ +$/, '') # remove line-ending whitespace js.gsub!(/\t/, ' ') # replace tabs with spaces js.gsub!(/ +/, ' ') # replace multiple spaces with a single space js.gsub!(/^ *\/\/.+\n/, '') # remove comment lines starting with a double slash js.gsub!(/\n/, '') # remove all newlines js = URI.escape(js, %Q(''" )) # URI escape: single- and double-quotes, spaces PSEUDOCOL + js # prefix with 'javascript:' end |
#to_bookmarklet_page ⇒ Object
insert bookmarklet into html code for drag-drop bookmarklet up to linkbar
50 51 52 53 54 55 56 |
# File 'lib/marlene.rb', line 50 def to_bookmarklet_page Mustache.template_file = BOOKMARKLET_PAGE page = Mustache.new page[:bookmarklet] = self page[:anchor] = ANCHOR_TEXTNODE page.render end |
#to_loader_script ⇒ Object
insert into loader script a javascript URL
42 43 44 45 46 47 |
# File 'lib/marlene.rb', line 42 def to_loader_script Mustache.template_file = LOADER_SCRIPT loader = Mustache.new loader[:script] = self loader.render end |