bookmarklet_generator
ruby
last edit: Dec, 31st 2011 | jump to bottom
require 'fileutils' linked_content = "js file linked from bookmarklet" host_content = "host file for bookmarklet" puts "Enter a title for the bookmarklet" title = gets title = title.gsub("\n", "") puts "enter your dropbox user number" user_number = gets puts "enter your computer username" username = gets dir_name = "bookmarklet_#{title}" Dir.mkdir(dir_name) fh_name = "host_#{title}.html" fl_name = "linked_#{title}.js" fh =File.new(fh_name, "w") fl =File.new(fl_name, "w") fh_path = File.absolute_path(fh) fl_path = File.absolute_path(fl) d_path = File.dirname(fh_path) d_path += "/#{dir_name}" new_fh_path = d_path +"/#{fh_name}" new_fl_path = d_path +"/#{fl_name}" host_content = host_content.gsub("titleHere", title) dbp_path = "/Users/#{username}/Dropbox/Public/" linkUrl = new_fl_path.gsub(dbp_path, "") link = "http://dl.dropbox.com/u/#{user_number}/" + linkUrl host_content = host_content.gsub("linkHere", link) fh.write host_content fl.write linked_content FileUtils.mv(fh_path, new_fh_path) FileUtils.mv(fl_path, new_fl_path) # FileUtils.rm_rf(dir_name)
85 views




