-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
190 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,37 @@ | ||
= mozrepl_tools | ||
|
||
Description goes here. | ||
|
||
== Note on Patches/Pull Requests | ||
|
||
* Fork the project. | ||
* Make your feature addition or bug fix. | ||
* Add tests for it. This is important so I don't break it in a | ||
future version unintentionally. | ||
* Commit, do not mess with rakefile, version, or history. | ||
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull) | ||
* Send me a pull request. Bonus points for topic branches. | ||
Reload css or js (and Ext.component) through your editor. Thanks to MozRepl :) | ||
|
||
== Before install | ||
|
||
install MozRepl | ||
http://wiki.github.com/bard/mozrepl/ | ||
|
||
== Install | ||
|
||
gem install mozrepl_tools | ||
|
||
== Reload css (<link /> tag only) | ||
|
||
#> mozrepl 'main.css' | ||
|
||
== Adding a js file to current tab | ||
|
||
#> mozrepl 'my/path/file.js' | ||
|
||
It's works with Sencha(ExtJS) Components!!! | ||
|
||
== Using with Textmate (~/Library/Application Support/TextMate/Bundles/MozRepl.tmbundle) | ||
|
||
#> mozrepl textmate | ||
|
||
And now, use "Command+Shif+R" (like magic) | ||
|
||
== TODO | ||
|
||
#TODO: use watchr to reload automatic | ||
|
||
== Copyright | ||
|
||
Copyright (c) 2010 Jorge Falcão. See LICENSE for details. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
if ARGV[0] == 'textmate' | ||
puts "textmate plugin ok!" | ||
textmate = File.expand_path("~/Library/Application Support/TextMate/Bundles/MozRepl.tmbundle") | ||
|
||
basedir = File.join(File.dirname(File.dirname(__FILE__))) | ||
|
||
bundle = File.join basedir, 'lib', 'textmate' | ||
|
||
File.unlink(textmate) | ||
File.symlink(bundle, textmate) | ||
system %Q{osascript -e 'tell app "TextMate" to reload bundles'} | ||
exit | ||
end | ||
|
||
require 'mozrepl_tools' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
pwd = File.dirname(__FILE__) | ||
|
||
puts "ruby '#{pwd}/textmate/Support/lib/mozrepl_tools.rb' #{ARGV[0]}" | ||
system("ruby '#{pwd}/textmate/Support/lib/mozrepl_tools.rb' #{ARGV[0]}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?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>command</key> | ||
<string>#!/usr/bin/env sh | ||
${TM_RUBY:-ruby} "$TM_BUNDLE_SUPPORT/lib/mozrepl_tools.rb" | ||
</string> | ||
<key>fallbackInput</key> | ||
<string>document</string> | ||
<key>input</key> | ||
<string>none</string> | ||
<key>keyEquivalent</key> | ||
<string>@R</string> | ||
<key>name</key> | ||
<string>Reload Using MozRepl</string> | ||
<key>output</key> | ||
<string>showAsTooltip</string> | ||
<key>uuid</key> | ||
<string>E36D6544-2445-4B6B-82FF-61B233ED7901</string> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
|
||
require 'socket' | ||
|
||
s = TCPSocket.open('localhost', 4242) | ||
|
||
script = DATA.read | ||
|
||
filepath = ENV["TM_FILEPATH"] || ARGV[0] | ||
file = File.basename filepath | ||
ext = File.extname filepath | ||
filename = File.expand_path filepath | ||
# p ext | ||
s.puts(script) | ||
|
||
if ext == ".css" | ||
s.puts("reload.css('#{file}')") | ||
puts "reloaded #{file}" | ||
elsif ext == ".js" | ||
s.puts("reload.js('#{filename}')") | ||
puts "reloaded #{filename}" | ||
end | ||
|
||
# puts script | ||
|
||
# workaround | ||
sleep 1 | ||
|
||
s.close | ||
|
||
__END__ | ||
|
||
|
||
var reload = (function(content, window) { | ||
var window = (function() { | ||
for ( var i = 0; i < window.length; i++ ) { | ||
if ( content.location == window[i].location ) { | ||
return window[i]; | ||
} | ||
} | ||
})(); | ||
|
||
var document = doc = window.document; | ||
var Ext = window.Ext; | ||
|
||
// firebug | ||
var console = window.console || {debug:function(){}}; | ||
|
||
console.debug("loading..."); | ||
|
||
// add development Ext.reg | ||
if ( ! Ext._reg ) { | ||
console.debug('saving original Ext.reg'); | ||
Ext._reg = Ext.reg; | ||
} | ||
|
||
Ext.reg = function(xtype) { | ||
console.debug("Ext.reg:", arguments); | ||
// calling old Ext.reg | ||
Ext._reg.apply(Ext, arguments); | ||
|
||
// reinstance all xtypes | ||
var items = Ext.ComponentMgr.all.filterBy(function(e) { return e.getXType() == xtype }).each(function(item) { | ||
repl.print(item) | ||
var ic = item.initialConfig; | ||
var o = item.ownerCt; | ||
o.remove(item); | ||
var it = o.add(ic) | ||
if ( o.getLayout().setActiveItem ) { | ||
o.getLayout().setActiveItem(it); | ||
}; | ||
o.doLayout(); | ||
}); | ||
}; | ||
|
||
var head = document.getElementsByTagName("head")[0]; | ||
|
||
return { | ||
css:function(file) { | ||
var l = doc.getElementsByTagName('link'); | ||
for ( var i = 0; i < l.length; i++ ) { | ||
var ss = l[i]; | ||
console.debug("reloading:", ss); | ||
if ( ss.href && ss.href.indexOf(file) != -1 ) { | ||
try { | ||
ss.href = (ss.href.split("?")[0]) + "?" + Math.random(); | ||
} catch (e) { | ||
repl.print(e); | ||
} | ||
} | ||
} | ||
}, | ||
js:function(filename) { | ||
var script = document.createElement('script'); | ||
script.type = "text/javascript"; | ||
script.src = filename; | ||
repl.print(filename); | ||
head.appendChild(script); | ||
} | ||
}; | ||
})(content, window); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?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>name</key> | ||
<string>MozRepl</string> | ||
<key>uuid</key> | ||
<string>16A1485C-204A-4160-9B43-541DD45E4386</string> | ||
</dict> | ||
</plist> |