Permalink
Browse files

Improved directory layout and module system

The @mozilla.org/moz/jssubscript-loader;1 class is now used to load
the modules, rather than get_chrome_contents combined with eval.  This
allows the correct line numbers and file names to be associated with
functions for debugging purposes.

The modules are now located in modules/, rather than
conkeror/content/, such that they are better distinguished.  The
subdirectories of the top-level conkeror directory, namely branding,
locale, and content, were moved to be top-level directories themslves.
The contents of modules/ can be accessed as
chrome://conkeror-modules/content/.

The function `load_module' loads the specified file from the modules
directory.  Additionally, it adds the name of the module to the
modules_loaded variable.  The function `require' can be used to ensure
that a module is loaded, and provides a higher-level interface to
`load_module'; if the specified module name is not found in
modules_loaded, load_module is invoked to load it.  This will allow
individual modules to state their dependencies directly.
  • Loading branch information...
1 parent 0ab6795 commit 6ce4c498b78e622d825e54c3c118a383da2acbb9 @jbms jbms committed Nov 12, 2007
Showing with 60 additions and 71 deletions.
  1. 0 {conkeror → }/branding/brand.dtd
  2. 0 {conkeror → }/branding/brand.properties
  3. +4 −14 build.sh
  4. +4 −3 chrome.manifest
  5. +4 −3 chrome.manifest.for-jar
  6. +48 −51 components/application.js
  7. 0 {conkeror → }/content/ChangeLog
  8. 0 {conkeror → }/content/NEWS
  9. 0 {conkeror → }/content/conkeror.css
  10. 0 {conkeror → }/content/conkeror.js
  11. 0 {conkeror → }/content/conkeror.xul
  12. 0 {conkeror → }/content/contents.rdf
  13. 0 {conkeror → }/content/context.js
  14. 0 {conkeror → }/content/contributors
  15. 0 {conkeror → }/content/dom-utils.js
  16. 0 {conkeror → }/content/frame_old.js
  17. 0 {conkeror → }/content/generate_mapping_table.html
  18. 0 {conkeror → }/content/gui_context_menu.js
  19. 0 {conkeror → }/content/gui_context_menu.xul
  20. 0 {conkeror → }/content/help.html
  21. 0 {conkeror → }/content/numbering.css
  22. 0 {conkeror → }/content/numbering.xml
  23. 0 {conkeror → }/content/pixel.png
  24. 0 {conkeror → }/content/tutorial.html
  25. 0 {conkeror → }/locale/en-US/gui_context_menu.properties
  26. 0 {conkeror/content → modules}/bindings.js
  27. 0 {conkeror/content → modules}/buffer.js
  28. 0 {conkeror/content → modules}/commands.js
  29. 0 {conkeror/content → modules}/daemon-mode.js
  30. 0 {conkeror/content → modules}/debug.js
  31. 0 {conkeror/content → modules}/find.js
  32. 0 {conkeror/content → modules}/frame.js
  33. 0 {conkeror/content → modules}/frameset.js
  34. 0 {conkeror/content → modules}/interactive.js
  35. 0 {conkeror/content → modules}/keyboard.js
  36. 0 {conkeror/content → modules}/localfile.js
  37. 0 {conkeror/content → modules}/minibuffer.js
  38. 0 {conkeror/content → modules}/mode-line.js
  39. 0 {conkeror/content → modules}/numberedlinks.js
  40. 0 {conkeror/content → modules}/numbering.js
  41. 0 {conkeror/content → modules}/save.js
  42. 0 {conkeror/content → modules}/utils.js
  43. 0 {conkeror/content → modules}/webjump.js
View
0 conkeror/branding/brand.dtd → branding/brand.dtd
File renamed without changes.
View
0 conkeror/branding/brand.properties → branding/brand.properties
File renamed without changes.
View
18 build.sh
@@ -100,11 +100,9 @@ function copy_tree_sans_boring () {
mkdir -p "$dest"
O=$IFS
IFS=$'\n'
- ( cd "$src"; find . -name CVS -prune -or \( -type d -and \
- \! -name '*[~#]' -print0 \) ) \
+ ( cd "$src"; find . -type d -and \! -name '*[~#]' -print0 ) \
| ( cd "$dest"; xargs -0 mkdir -p )
- files=($( cd "$src"; find . -name CVS -prune -or \( -type f -and \
- \! -name '*[~#]' -print \) ))
+ files=($( cd "$src"; find . -type f -and \! -name '*[~#]' -print ))
for file in "${files[@]}" ; do cp "$src/$file" "$dest/$file" ; done
IFS=$O
}
@@ -169,17 +167,9 @@ function diff_wrapper () {
function do_target_jar () {
echo -n Building JAR...
- get_scratch
- jarbuild="$SCRATCH/jar-build"
- mkdir "$jarbuild"
- cp -r conkeror "$jarbuild/conkeror"
- pushd "$jarbuild" > /dev/null
- FILES=($(find conkeror -name CVS -prune -or \( -type f -and \! -name '*[~#]' -print \)))
- zip conkeror.jar "${FILES[@]}" > /dev/null
- popd > /dev/null
- mv "$jarbuild/conkeror.jar" .
+ FILES=($(find content branding locale modules -type f -and \! -name '*[~#]' -print ))
+ zip "conkeror.jar" "${FILES[@]}" > /dev/null
echo ok
- do_cleanup
}
View
7 chrome.manifest
@@ -1,3 +1,4 @@
-content conkeror file:conkeror/content/
-locale conkeror en-US file:conkeror/conkeror/locale/en-US/
-locale branding en-US file:conkeror/conkeror/branding/
+content conkeror file:content/
+content conkeror-modules file:modules/
+locale conkeror en-US file:locale/en-US/
+locale branding en-US file:branding/
View
7 chrome.manifest.for-jar
@@ -1,3 +1,4 @@
-content conkeror jar:conkeror.jar!/conkeror/content/
-locale conkeror en-US jar:conkeror.jar!/conkeror/locale/en-US/
-locale branding en-US jar:conkeror.jar!/conkeror/branding/
+content conkeror jar:conkeror.jar!/content/
+content conkeror-modules jar:conkeror.jar!/modules/
+locale conkeror en-US jar:conkeror.jar!/locale/en-US/
+locale branding en-US jar:conkeror.jar!/branding/
View
99 components/application.js
@@ -1,64 +1,60 @@
+const Cc = Components.classes;
+const Ci = Components.interfaces;
-
-function get_chrome_contents (chrome_uri_s) {
- try {
- var op = Components.classes["@mozilla.org/network/io-service;1"]
- .getService(Components.interfaces.nsIIOService)
- .newChannel(chrome_uri_s, null, null)
- .open();
- var inputStream = Components.classes["@mozilla.org/scriptableinputstream;1"]
- .createInstance(Components.interfaces.nsIScriptableInputStream);
- inputStream.init (op);
- var buf = "";
- var len = null;
- do {
- len = inputStream.available(); // throws if not available
- buf += inputStream.read (len);
- } while (len != 0);
- inputStream.close();
- return buf;
- } catch (e) {
- inputStream.close();
- dump ('error loading '+chrome_uri_s+"\n "+e+"\n");
- }
-}
-
-
-
+var subscriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
+ .getService(Components.interfaces.mozIJSSubScriptLoader);
function application () {
this.wrappedJSObject = this;
- this.window_watcher = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
- .getService(Components.interfaces.nsIWindowWatcher);
+ this.conkeror = this;
+ this.window_watcher = Cc["@mozilla.org/embedcomp/window-watcher;1"].getService(Ci.nsIWindowWatcher);
+ this.Cc = Cc;
+ this.Ci = Ci;
+ this.subscript_loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader);
+ this.preferences = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
var conkeror = this;
- conkeror.start_time = Date.now ();
- conkeror.url_remoting_fn = conkeror.make_frame;
+ this.modules_loaded = [];
+ function load_module (module_name) {
+ try {
+ conkeror.subscript_loader.loadSubScript("chrome://conkeror-modules/content/" + module_name,
+ conkeror);
+ conkeror.modules_loaded.push(module_name);
+ } catch (e) {
+ dump("Failed to load module: " + module_name + "\n" +
+ e + "\n");
+ }
+ }
+ function require (module) {
+ if (conkeror.modules.indexOf(module) == -1)
+ load_module(module);
+ }
+ this.load_module = load_module;
+ this.require = require;
- conkeror.preferences = Components.classes["@mozilla.org/preferences-service;1"]
- .getService (Components.interfaces.nsIPrefBranch);
+ load_module("debug.js");
+ load_module("localfile.js");
+ load_module("utils.js");
+ load_module("keyboard.js");
+ load_module("buffer.js");
+ load_module("frame.js");
+ load_module("interactive.js");
+ load_module("daemon-mode.js");
+ load_module("mode-line.js");
+ load_module("save.js");
- eval.call (this, get_chrome_contents ("chrome://conkeror/content/debug.js"));
- eval.call (this, get_chrome_contents ("chrome://conkeror/content/localfile.js"));
- eval.call (this, get_chrome_contents ("chrome://conkeror/content/utils.js"));
- eval.call (this, get_chrome_contents ("chrome://conkeror/content/keyboard.js"));
- eval.call (this, get_chrome_contents ("chrome://conkeror/content/buffer.js"));
- eval.call (this, get_chrome_contents ("chrome://conkeror/content/frame.js"));
- eval.call (this, get_chrome_contents ("chrome://conkeror/content/interactive.js"));
- eval.call (this, get_chrome_contents ("chrome://conkeror/content/daemon-mode.js"));
- eval.call (this, get_chrome_contents ("chrome://conkeror/content/mode-line.js"));
- eval.call (this, get_chrome_contents ("chrome://conkeror/content/save.js"));
+ load_module("commands.js"); // depends: interactive.js
+ load_module("frameset.js"); // depends interactive.js
+ load_module("webjump.js"); // depends: interactive.js
+ load_module("minibuffer.js"); // depends: interactive.js
- eval.call (this, get_chrome_contents ("chrome://conkeror/content/commands.js")); // depends: interactive.js
- eval.call (this, get_chrome_contents ("chrome://conkeror/content/frameset.js")); // depends: interactive.js
- eval.call (this, get_chrome_contents ("chrome://conkeror/content/webjump.js")); // depends: interactive.js
- eval.call (this, get_chrome_contents ("chrome://conkeror/content/minibuffer.js")); // depends: interactive.js
+ load_module("bindings.js"); // depends: keyboard.js
- eval.call (this, get_chrome_contents ("chrome://conkeror/content/bindings.js")); // depends: keyboard.js
+ load_module("find.js");
+ load_module("numberedlinks.js");
- // FIXME: This is commented out because it currently does nothing except print numbering_resize messages
- //eval.call (this, get_chrome_contents ("chrome://conkeror/content/numbering.js"));
- eval.call (this, get_chrome_contents ("chrome://conkeror/content/find.js"));
- eval.call (this, get_chrome_contents ("chrome://conkeror/content/numberedlinks.js"));
+ this.start_time = Date.now ();
+
+ conkeror.url_remoting_fn = conkeror.make_frame;
conkeror.set_default_directory ();
@@ -70,6 +66,7 @@ function application () {
application.prototype = {
version: "$CONKEROR_VERSION$", // preprocessor variable
+
start_time: null,
window_watcher: null,
preferences: null,
View
0 conkeror/content/ChangeLog → content/ChangeLog
File renamed without changes.
View
0 conkeror/content/NEWS → content/NEWS
File renamed without changes.
View
0 conkeror/content/conkeror.css → content/conkeror.css
File renamed without changes.
View
0 conkeror/content/conkeror.js → content/conkeror.js
File renamed without changes.
View
0 conkeror/content/conkeror.xul → content/conkeror.xul
File renamed without changes.
View
0 conkeror/content/contents.rdf → content/contents.rdf
File renamed without changes.
View
0 conkeror/content/context.js → content/context.js
File renamed without changes.
View
0 conkeror/content/contributors → content/contributors
File renamed without changes.
View
0 conkeror/content/dom-utils.js → content/dom-utils.js
File renamed without changes.
View
0 conkeror/content/frame_old.js → content/frame_old.js
File renamed without changes.
View
0 conkeror/content/generate_mapping_table.html → content/generate_mapping_table.html
File renamed without changes.
View
0 conkeror/content/gui_context_menu.js → content/gui_context_menu.js
File renamed without changes.
View
0 conkeror/content/gui_context_menu.xul → content/gui_context_menu.xul
File renamed without changes.
View
0 conkeror/content/help.html → content/help.html
File renamed without changes.
View
0 conkeror/content/numbering.css → content/numbering.css
File renamed without changes.
View
0 conkeror/content/numbering.xml → content/numbering.xml
File renamed without changes.
View
0 conkeror/content/pixel.png → content/pixel.png
File renamed without changes
View
0 conkeror/content/tutorial.html → content/tutorial.html
File renamed without changes.
View
0 .../locale/en-US/gui_context_menu.properties → locale/en-US/gui_context_menu.properties
File renamed without changes.
View
0 conkeror/content/bindings.js → modules/bindings.js
File renamed without changes.
View
0 conkeror/content/buffer.js → modules/buffer.js
File renamed without changes.
View
0 conkeror/content/commands.js → modules/commands.js
File renamed without changes.
View
0 conkeror/content/daemon-mode.js → modules/daemon-mode.js
File renamed without changes.
View
0 conkeror/content/debug.js → modules/debug.js
File renamed without changes.
View
0 conkeror/content/find.js → modules/find.js
File renamed without changes.
View
0 conkeror/content/frame.js → modules/frame.js
File renamed without changes.
View
0 conkeror/content/frameset.js → modules/frameset.js
File renamed without changes.
View
0 conkeror/content/interactive.js → modules/interactive.js
File renamed without changes.
View
0 conkeror/content/keyboard.js → modules/keyboard.js
File renamed without changes.
View
0 conkeror/content/localfile.js → modules/localfile.js
File renamed without changes.
View
0 conkeror/content/minibuffer.js → modules/minibuffer.js
File renamed without changes.
View
0 conkeror/content/mode-line.js → modules/mode-line.js
File renamed without changes.
View
0 conkeror/content/numberedlinks.js → modules/numberedlinks.js
File renamed without changes.
View
0 conkeror/content/numbering.js → modules/numbering.js
File renamed without changes.
View
0 conkeror/content/save.js → modules/save.js
File renamed without changes.
View
0 conkeror/content/utils.js → modules/utils.js
File renamed without changes.
View
0 conkeror/content/webjump.js → modules/webjump.js
File renamed without changes.

0 comments on commit 6ce4c49

Please sign in to comment.