Skip to content

Instantly share code, notes, and snippets.

@pdxmph
Created August 4, 2011 20:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pdxmph/1126217 to your computer and use it in GitHub Desktop.
Save pdxmph/1126217 to your computer and use it in GitHub Desktop.
Easy way to open bunches of instances of the same path on multiple sites
#!/usr/bin/env ruby
# notes at the bottom
require "rubygems"
require "appscript"
require "yaml"
include Appscript
browser = app("Safari") # could be "Google Chrome" or "Firefox," too
config_file = File.open(File.expand_path('~') + "/etc/smt_config.yml")
config = YAML.load(config_file)
sites = config["sites"]
paths = config["drupal_paths"]
function = ARGV[0]
qual = ARGV[1]
unless paths.has_key?(function)
puts "Illegal option. Choices: #{paths.map { |f| f[0] += " "}}"
exit
else
fn = paths[function]
end
sites.each do |s|
unless qual == "-s"
url = s[1]['url']
else
url = "staging.#{s[1]['url']}"
end
browser.open_location("http://#{url}#{fn}")
end
browser.activate
=begin
This is for dealing with multiple sites that have individual configuration pages by opening each page in a tab in a browser. One nice thing about the AppleScript dictionaries for Safari, Firefox and Google Chrome: They all take `open location`, and they all open new locations in a new tab.
No fancy option parsing:
ARGV[0] = the configuration path you want to open
ARGV[1] = a "-s" switch that opens the staging versions of the domains instead of the production version by tacking "staging." onto the front of the domain to be opened.
The site list and the available configuration pages come from the "smt_config.yml" file in ~/etc:
The site list looks like this:
sites:
SpumCo Incorporated:
url: spumco.com
abbrev: sco
SuperSite LLC:
url: supersitellc.com
abbrev: ssl
The pages list looks like this:
drupal_paths:
permissions: /admin/user/permissions
cache: /admin/settings/performance/default
status: /admin/reports/status
search: /admin/settings/apachesolr/settings
unpubs: /reports/fixit/auto-unpublished
mollom: /admin/settings/mollom
sitemaps: /admin/settings/xmlsitemap/settings
=end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment