From 9559104e5e77ec24c4effde82bac1724fcf1e94e Mon Sep 17 00:00:00 2001 From: Nathan Rijksen Date: Mon, 6 Apr 2015 11:50:05 -0400 Subject: [PATCH] Initial commit on github --- .gitignore | 2 + chrome.manifest | 15 + components/component.manifest | 3 + components/moz2/pyIShell.xpt | Bin 0 -> 401 bytes components/pyIShell.xpt | Bin 0 -> 231 bytes components/pyShell.py | 132 ++++ content/chromeShellExtras.js | 97 +++ content/extensionbuilder.js | 1206 +++++++++++++++++++++++++++++++ content/extensionbuilder.xul | 41 ++ content/extensiondevOverlay.js | 128 ++++ content/firefoxOverlay.xul | 84 +++ content/htmledit.xul | 40 + content/htmledit/editbox.html | 46 ++ content/htmledit/index.html | 13 + content/injector.js | 48 ++ content/injector.xul | 23 + content/install-edit.js | 402 +++++++++++ content/install-edit.xul | 159 ++++ content/jrx.html | 725 +++++++++++++++++++ content/jrx.xul | 10 + content/jsenv.js | 62 ++ content/jsenv.xul | 28 + content/jsenv/blank.html | 1 + content/jsenv/index.html | 21 + content/jsenv/input.html | 31 + content/jsenv/jsenv.diff | 36 + content/jsenv/toolbar.html | 196 +++++ content/komodoOverlay.xul | 75 ++ content/loadsaveutils.js | 110 +++ content/options.xul | 58 ++ content/pyshell.html | 559 ++++++++++++++ content/pyshell.xul | 50 ++ content/rdfhistory.js | 150 ++++ content/read-install-rdf.js | 128 ++++ content/seamonkeyOverlay.xul | 59 ++ content/shell.html | 751 +++++++++++++++++++ content/shell.xul | 11 + content/thunderbirdOverlay.xul | 82 +++ content/xpath.js | 131 ++++ content/xpath.xul | 38 + content/xpathblank.html | 33 + content/xuledit.js | 82 +++ content/xuledit.xul | 17 + idl/pyIShell.idl | 49 ++ install.rdf | 34 + locale/en-US/contents.rdf | 22 + locale/en-US/extensiondev.dtd | 97 +++ locale/en-US/prefwindow.dtd | 9 + skin/contents.rdf | 32 + skin/extensionbuilder-large.png | Bin 0 -> 1066 bytes skin/extensionbuilder-small.png | Bin 0 -> 653 bytes skin/extensiondev.css | 100 +++ skin/extensiondev.png | Bin 0 -> 1230 bytes skin/htmledit-large.png | Bin 0 -> 349 bytes skin/htmledit-small.png | Bin 0 -> 298 bytes skin/jrx-large.png | Bin 0 -> 398 bytes skin/jrx-small.png | Bin 0 -> 183 bytes skin/jsenv-large.png | Bin 0 -> 394 bytes skin/jsenv-small.png | Bin 0 -> 318 bytes skin/jsinj-large.png | Bin 0 -> 291 bytes skin/jsinj-small.png | Bin 0 -> 334 bytes skin/jsshell-large.png | Bin 0 -> 165 bytes skin/jsshell-small.png | Bin 0 -> 134 bytes skin/reloadchrome-large.png | Bin 0 -> 1893 bytes skin/reloadchrome-small.png | Bin 0 -> 983 bytes skin/xpath-large.png | Bin 0 -> 187 bytes skin/xpath-small.png | Bin 0 -> 161 bytes skin/xpath.css | 6 + skin/xuledit-large.png | Bin 0 -> 258 bytes skin/xuledit-small.png | Bin 0 -> 246 bytes 70 files changed, 6232 insertions(+) create mode 100644 .gitignore create mode 100644 chrome.manifest create mode 100644 components/component.manifest create mode 100644 components/moz2/pyIShell.xpt create mode 100644 components/pyIShell.xpt create mode 100644 components/pyShell.py create mode 100644 content/chromeShellExtras.js create mode 100644 content/extensionbuilder.js create mode 100644 content/extensionbuilder.xul create mode 100644 content/extensiondevOverlay.js create mode 100644 content/firefoxOverlay.xul create mode 100644 content/htmledit.xul create mode 100755 content/htmledit/editbox.html create mode 100755 content/htmledit/index.html create mode 100644 content/injector.js create mode 100644 content/injector.xul create mode 100644 content/install-edit.js create mode 100644 content/install-edit.xul create mode 100644 content/jrx.html create mode 100644 content/jrx.xul create mode 100644 content/jsenv.js create mode 100644 content/jsenv.xul create mode 100755 content/jsenv/blank.html create mode 100755 content/jsenv/index.html create mode 100644 content/jsenv/input.html create mode 100644 content/jsenv/jsenv.diff create mode 100755 content/jsenv/toolbar.html create mode 100644 content/komodoOverlay.xul create mode 100644 content/loadsaveutils.js create mode 100644 content/options.xul create mode 100644 content/pyshell.html create mode 100644 content/pyshell.xul create mode 100644 content/rdfhistory.js create mode 100644 content/read-install-rdf.js create mode 100644 content/seamonkeyOverlay.xul create mode 100644 content/shell.html create mode 100644 content/shell.xul create mode 100644 content/thunderbirdOverlay.xul create mode 100644 content/xpath.js create mode 100644 content/xpath.xul create mode 100644 content/xpathblank.html create mode 100644 content/xuledit.js create mode 100644 content/xuledit.xul create mode 100644 idl/pyIShell.idl create mode 100644 install.rdf create mode 100755 locale/en-US/contents.rdf create mode 100755 locale/en-US/extensiondev.dtd create mode 100755 locale/en-US/prefwindow.dtd create mode 100755 skin/contents.rdf create mode 100755 skin/extensionbuilder-large.png create mode 100755 skin/extensionbuilder-small.png create mode 100755 skin/extensiondev.css create mode 100644 skin/extensiondev.png create mode 100755 skin/htmledit-large.png create mode 100755 skin/htmledit-small.png create mode 100755 skin/jrx-large.png create mode 100755 skin/jrx-small.png create mode 100755 skin/jsenv-large.png create mode 100755 skin/jsenv-small.png create mode 100755 skin/jsinj-large.png create mode 100755 skin/jsinj-small.png create mode 100755 skin/jsshell-large.png create mode 100755 skin/jsshell-small.png create mode 100755 skin/reloadchrome-large.png create mode 100755 skin/reloadchrome-small.png create mode 100755 skin/xpath-large.png create mode 100755 skin/xpath-small.png create mode 100755 skin/xpath.css create mode 100755 skin/xuledit-large.png create mode 100755 skin/xuledit-small.png diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b18d902 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/*.xpi +/build diff --git a/chrome.manifest b/chrome.manifest new file mode 100644 index 0000000..eb5bff8 --- /dev/null +++ b/chrome.manifest @@ -0,0 +1,15 @@ +content extensiondev jar:koextensiondev.jar!/content/ +locale extensiondev en-US jar:koextensiondev.jar!/locale/en-US/ +skin extensiondev classic/1.0 jar:koextensiondev.jar!/skin/ +overlay chrome://browser/content/browser.xul chrome://extensiondev/content/firefoxOverlay.xul +overlay chrome://messenger/content/messenger.xul chrome://extensiondev/content/thunderbirdOverlay.xul +overlay chrome://navigator/content/navigatorOverlay.xul chrome://extensiondev/content/seamonkeyOverlay.xul +overlay chrome://komodo/content/komodo.xul chrome://extensiondev/content/komodoOverlay.xul +style chrome://global/content/customizeToolbar.xul chrome://extensiondev/skin/extensiondev.css + +# Need to specify alternative xpt file - as nsIVairant changed from 1.9.x +interfaces components/moz2/pyIShell.xpt +component {4e5c9764-d465-4fef-ae24-8032f257d174} components/pyShell.py +contract @twhiteman.netfirms.com/pyShell;1 {4e5c9764-d465-4fef-ae24-8032f257d174} + +manifest components/component.manifest diff --git a/components/component.manifest b/components/component.manifest new file mode 100644 index 0000000..9a486d7 --- /dev/null +++ b/components/component.manifest @@ -0,0 +1,3 @@ +contract @twhiteman.netfirms.com/pyShell;1 {4e5c9764-d465-4fef-ae24-8032f257d174} +component {4e5c9764-d465-4fef-ae24-8032f257d174} pyShell.py +interfaces pyIShell.xpt diff --git a/components/moz2/pyIShell.xpt b/components/moz2/pyIShell.xpt new file mode 100644 index 0000000000000000000000000000000000000000..823f24116b1136bf51513eed3e3302e52a953c50 GIT binary patch literal 401 zcmazDaQ64*3aKne^~p@)<&t7#VqjrlV4TRnz@P-g6B~d87#x65Za|6=!en5OVwO9> z(CNCpf9kVdo`03of#SSSIT_V|=3noe^=(~ohrviuXodw)+!ZS4*ZAbny)|pRu1%2I z`dhkH3Z&;7RE{C9*fY4apdi1fq?n{uP-;nO5dldgKcuIYIOpdUnV46?0090bagYE2 literal 0 HcmV?d00001 diff --git a/components/pyIShell.xpt b/components/pyIShell.xpt new file mode 100644 index 0000000000000000000000000000000000000000..45ed91032f2f0e12380ae1757ff1730ef0697737 GIT binary patch literal 231 zcmazDaQ64*3aKne^~p@)<&t7#Vqj)qV0aG1DnMM(032sga^h_{b&C5&RO5q z6?Yhn6oqD30L3MsavltM#hzh_MVX0tB_L*SX+c4LQAsgFL8WJKMruwDLuy%KPC#Wz zMt)v!Nl|8AIzxJDiF1B#K~8E(W`16=TYiyWVs0t}0}~Jefg)4G#Dqx 0) ? histList.length-1 : 0; +} + +function saveHistory() +{ + var num = min(histList.length, 20 + 1); + var start = histList.length - num; + + saveHistoryItems(histList.slice(start, histList.length), "http://ted.mielczarek.org/code/mozilla/extensiondev#jsshell_history", "http://ted.mielczarek.org/code/mozilla/extensiondev#jsshell_historyitem"); +} + +function onChromeShellExtrasUnload() +{ + saveHistory(); + releaseRDFService(); +} + +shellCommands.propsPlus = function(o) { + for(var x in o) { + try { + var v = o[x]; + if(v instanceof Function) { + println(x + ": Function"); + } + else { + println(x + ": " + v); + } + } + catch(ex) {} + } +} + +window.addEventListener("load", onChromeShellExtrasLoad, true); +window.addEventListener("unload", onChromeShellExtrasUnload, true); diff --git a/content/extensionbuilder.js b/content/extensionbuilder.js new file mode 100644 index 0000000..da7d51e --- /dev/null +++ b/content/extensionbuilder.js @@ -0,0 +1,1206 @@ +//constants etc. +// Files that can be in the XPI +var optionalXPIFiles = ["chrome", "install.rdf", "install.js", "chrome.manifest", "components", "defaults"]; +// The filename to save extension-specific data to +const EXTENSIONBUILDER_DATA = "extensiondev-data.rdf"; +var ED_ID = "{75739dec-72db-4020-aa9a-6afa6744759b}"; + +// global variables +var currentWorkingDirectory = null; +var gZipUtil = null; + +/* + * Set the statusbar text + */ +function setStatus(s) +{ + var st = document.getElementById("status"); + st.label = s; +} + +/* + * Open a "browse for folder" dialog to locate an extension directory + * Add the the selected directory to the dropdown list and set it as + * the current working directory. + */ +function browseForExtension() +{ + var nsIFilePicker = Components.interfaces.nsIFilePicker; + var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker); + fp.init(window, "Choose Extension Directory", nsIFilePicker.modeGetFolder); + if(fp.show() == nsIFilePicker.returnOK) { + var wd = document.getElementById("workingdir"); + var item = wd.insertItemAt(0,fp.file.path); + wd.selectedItem = item; + dirSelectionChanged(); + } +} + +/* + * Get the current working directory as an nsILocalFile + */ +function getWorkingDirectory() +{ + try { + var s = document.getElementById("workingdir").selectedItem; + if(s) { + var f = fileFromPath(s.getAttribute("label")); + if(f) + return f; + } + } + catch(ex) { + dump(ex); + } + + return null; +} + +/* + * Reveal the current working directory in the system file browser. + */ +function showWorkingDir() +{ + var f = getWorkingDirectory(); + if(f) + f.reveal(); +} + +/* + * Get the directory this extension is installed in. + */ +function getInstalledDir() +{ + var mf = getInstallManifestFromDir(getWorkingDirectory()); + if(!mf || !mf['id']) + return null; + + var id = mf['id']; + if('@mozilla.org/extensions/manager;1' in Components.classes) { + // Firefox 1.5+ or similar + var em = Components.classes['@mozilla.org/extensions/manager;1'] + .getService(Components.interfaces.nsIExtensionManager); + var il = em.getInstallLocation(id); + if(il == null) + return null; + + return il.getItemLocation(id); + } + // FF1.0 or something similar + var directoryService=Components.classes['@mozilla.org/file/directory_service;1'].getService(Components.interfaces.nsIProperties); + var profDir = directoryService.get('ProfD', Components.interfaces.nsILocalFile); + var extDir = profDir.clone(); + extDir.append("extensions"); + if(extDir.exists()) { + extDir.append(id); + return extDir; + } + // probably SeaMonkey or something + extDir = profDir.clone(); + extDir.append("chrome"); + return extDir; +} + +/* + * Reveal the installed directory in the system file browser. + */ +function showInstalledDir() +{ + var extDir = getInstalledDir(); + if(extDir && extDir.exists()) { + try { + extDir.reveal(); + } catch(ex) { dump('Reveal not supported on this platform\n'); } + } +} + +/* + * Edit install.rdf from the current working directory in the + * install.rdf editor window. + */ +function editInstallManifest() +{ + var f = getWorkingDirectory(); + if(f) { + f.append("install.rdf"); + var w = window.openDialog("chrome://extensiondev/content/install-edit.xul", "installedit", "all=no,dialog=yes,width=450,height=525", f.path); + } +} + +/* + * Given a directory, make dirname as a subdirectory if it doesn't exist. + * Return the subdirectory as an nsILocalFile. + */ +function maybeMkDir(indir, dirname) +{ + var subDir = indir.clone(); + subDir.append(dirname); + if(!subDir.exists()) { + subDir.create(subDir.DIRECTORY_TYPE, 0755); + } + return subDir; +} + +/* + * Return the filename of the first XPI located in dir. + * Return null if there is no XPI. + */ +function findExistingXPI(dir) +{ + var en = dir.directoryEntries; + while(en.hasMoreElements()) { + var f = en.getNext(); + f.QueryInterface(Components.interfaces.nsILocalFile); + if(f.isFile() && f.leafName.match(/\.xpi$/i)) + return f.leafName; + } + return null; +} + +/* + * Get the XPI filename for this extension, either from + * the textbox or by using the heuristics. If the latter, + * set the textbox value to the determined filename. + */ +function getXPIFilename(wd, mf, cm, cb) +{ + var xf = document.getElementById("xpi-filename"); + if(xf.value == "") + xf.value = determineXPIFilename(wd, mf, cm, cb); + + return xf.value; +} + +/* + * Determine the proper XPI filename for this extension + * using a few heuristics: + * + * 1) If a config_build.sh exists, use APP_NAME from there. + * 2) If an XPI file exists in the directory, use that filename. + * 3) If there's a chrome.manifest, use the chrome path from there + * 4) If there is only one jar file, in the install.rdf, + * use that filename with '.jar' replaced by '.xpi'. + * 5) Otherwise just use the directory name with '.xpi' appended. + */ +function determineXPIFilename(wd, mf, cm, cb) +{ + if(!wd) + wd = getWorkingDirectory(); + + if(!mf) + mf = getInstallManifestFromDir(wd); + + if(!cm) + cm = getChromeManifestFromDir(wd); + + if(!cb) + cb = getConfigBuildFromDir(wd); + + if(cb && ("APP_NAME" in cb)) + return cb["APP_NAME"] + ".xpi"; + + // easy, if an xpi file exists then use that name + xpiFilename = findExistingXPI(wd); + if(!xpiFilename) { + // see if we have a chrome.manifest + if(cm) { + for(var i=0; i pt) ? 4 : sl + 1; + var jarFile = dir.substring(sl, pt); + var provider = dir.substring(pt + 1); + provider = provider.replace(/^\//, ''); + provider = provider.replace(/\/.*/, ''); + if(!inArray(jarFile, jarfiles)) + jarfiles.push(jarFile); + if(jarFile in jardirs) { + if(!inArray(provider, jardirs[jarFile])) + jardirs[jarFile].push(provider); + } + else + jardirs[jarFile] = [provider]; + + // write to output file unchanged + if(ostream) { + var data = cm[i] + "\n"; + ostream.write(data, data.length); + } + } + else { + // fixup line, make jar file name + var jarFile = items[1] + '.jar'; + var provider = dir; + provider = provider.replace(/^\//, ''); + provider = provider.replace(/\/.*/, ''); + + if(dir[0] != '/') + dir = '/' + dir; + var fixedprovider = 'jar:chrome/' + jarFile + '!' + dir; + if(!inArray(jarFile, jarfiles)) + jarfiles.push(jarFile); + if(jarFile in jardirs) { + if(!inArray(provider, jardirs[jarFile])) + jardirs[jarFile].push(provider); + } + else + jardirs[jarFile] = [provider]; + + if(ostream) { + if(items[0] == 'content') + items[2] = fixedprovider; + else + items[3] = fixedprovider; + + // write out changed version + var data = items.join(' ') + "\n"; + ostream.write(data, data.length); + } + } + } + else { + if(ostream) { + // not a chrome provider, just echo it + var data = cm[i] + "\n"; + ostream.write(data, data.length); + } + } + } + if(ostream) + ostream.close(); + } + // otherwise use install.rdf + else if(mf && mf.files) { + var providers = ["package", "locale", "skin"]; + for(var i=0; i