mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-07 19:27:12 +00:00
Added run in browser/refresh browser commands for project level view of run application
This commit is contained in:
committed by
Ross Boucher
parent
0356c6e622
commit
cc90f2e5f0
+65
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>beforeRunningCommand</key>
|
||||
<string>nop</string>
|
||||
<key>command</key>
|
||||
<string>#!/usr/bin/env ruby -wKU
|
||||
#
|
||||
# Open Document in Running Browser(s)
|
||||
# v3 - November 22, 2007
|
||||
#
|
||||
# Now supports multiple running versions of a single browser along
|
||||
# with a range of new/old browsers. Bring back support for Firefox.
|
||||
#
|
||||
# Options: Set TM_PROJECT_SITEURL in your TM Project Window Info Button
|
||||
# in the following form: "http://example.com/"
|
||||
|
||||
require "#{ENV['TM_SUPPORT_PATH']}/lib/escape.rb"
|
||||
|
||||
if ENV['TM_PROJECT_SITEURL']
|
||||
url = "#{ENV['TM_PROJECT_SITEURL']}" + ENV['TM_FILEPATH'].sub(/^#{Regexp.escape(ENV['TM_PROJECT_DIRECTORY'])}\//, '')
|
||||
else
|
||||
url = "file://#{ENV['TM_PROJECT_DIRECTORY']}/index.html"
|
||||
end
|
||||
|
||||
proclist = `ps -x -o command`
|
||||
active = []
|
||||
os = `defaults read /System/Library/CoreServices/SystemVersion ProductVersion`
|
||||
|
||||
browsers = %w[ Safari OmniWeb Camino Shiira firefox-bin Xyle\ scope Opera Internet\ Explorer flock-bin iCab Sunrise seamonkey-bin navigator-bin ].join('|')
|
||||
|
||||
# Build paths to each active browser
|
||||
#
|
||||
# Notes:
|
||||
# - 'WebKit' look ahead is to rule it out so we can use the working
|
||||
# rule below.
|
||||
# - 'LaunchCFMApp' portion is so iCab works.
|
||||
active = proclist.scan(%r{^(?:/.*LaunchCFMApp )?(/.*\.app)(?=/Contents/MacOS/(?:#{browsers})\b(?!\s-WebKit))})
|
||||
|
||||
# Special check for WebKit as it appears as Safari
|
||||
# Note: Only supports one running instance of WebKit, picked at random.
|
||||
if proclist =~ %r{/Contents/MacOS/Safari.*-WebKit(DeveloperExtras|ScriptDebuggerEnabled)}
|
||||
active << "WebKit"
|
||||
end
|
||||
|
||||
# TODO: Change when Leopard Only
|
||||
# On Leopard use the -g option to open in background.
|
||||
if os =~ /^10\.(5|6)/
|
||||
active.each {|p| `open -g -a #{e_sh(p)} #{e_sh(url)}` }
|
||||
else
|
||||
active.each {|p| `open -a #{e_sh(p)} #{e_sh(url)}` }
|
||||
end</string>
|
||||
<key>input</key>
|
||||
<string>none</string>
|
||||
<key>name</key>
|
||||
<string>Open Document in Running Browser(s)</string>
|
||||
<key>output</key>
|
||||
<string>discard</string>
|
||||
<key>scope</key>
|
||||
<string>source.js.objj</string>
|
||||
<key>uuid</key>
|
||||
<string>36FD3695-1051-401E-8536-89FB9CEEEAB4</string>
|
||||
</dict>
|
||||
</plist>
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>beforeRunningCommand</key>
|
||||
<string>nop</string>
|
||||
<key>command</key>
|
||||
<string>### Refresh All Active Browsers - OmniWeb, Safari, Firefox & IE
|
||||
### v1.0. 2005-03-29
|
||||
###
|
||||
|
||||
# Check if Internet Explorer is running, if so refresh
|
||||
ps -xc|grep -sq "Internet Explorer" && osascript -e 'tell app "Internet Explorer"' -e 'activate' -e 'OpenURL "JavaScript:window.location.reload();" toWindow -1' -e 'end tell'
|
||||
|
||||
# Check if OmniWeb is running, if so refresh
|
||||
ps -xc|grep -sq OmniWeb && osascript -e 'tell app "OmniWeb"' -e 'activate' -e 'reload first browser' -e 'end tell'
|
||||
|
||||
# Check if Firefox is running, if so refresh
|
||||
ps -xc|grep -sqi firefox && osascript <<'APPLESCRIPT'
|
||||
tell app "Firefox" to activate
|
||||
tell app "System Events"
|
||||
if UI elements enabled then
|
||||
keystroke "r" using command down
|
||||
-- Fails if System Preferences > Universal access > "Enable access for assistive devices" is not on
|
||||
else
|
||||
tell app "Firefox" to Get URL "JavaScript:window.location.reload();" inside window 1
|
||||
-- Fails if Firefox is set to open URLs from external apps in new tabs.
|
||||
end if
|
||||
end tell
|
||||
APPLESCRIPT
|
||||
|
||||
# Check if Safari is running, if so refresh
|
||||
ps -xc|grep -sq Safari && osascript -e 'tell app "Safari"' -e 'activate' -e 'do JavaScript "window.location.reload();" in first document' -e 'end tell'
|
||||
|
||||
# Check if Camino is running, if so refresh
|
||||
ps -xc|grep -sq Camino && osascript -e 'tell app "Camino"' -e 'activate' -e 'tell app "System Events" to keystroke "r" using {command down}' -e 'end tell'
|
||||
</string>
|
||||
<key>input</key>
|
||||
<string>none</string>
|
||||
<key>keyEquivalent</key>
|
||||
<string>@r</string>
|
||||
<key>name</key>
|
||||
<string>Refresh Running Browser(s)</string>
|
||||
<key>output</key>
|
||||
<string>discard</string>
|
||||
<key>scope</key>
|
||||
<string>source.js.objj</string>
|
||||
<key>uuid</key>
|
||||
<string>033BC36A-97DA-4F48-9ACB-B58C80D1A689</string>
|
||||
</dict>
|
||||
</plist>
|
||||
Reference in New Issue
Block a user