Skip to content
Browse files

Initial commit. Basic structure for bootstrapped Firebug extension

  • Loading branch information...
1 parent 4658e3e commit 83088feef3ce714a77d53194de1afb519d7944ea @janodvarko janodvarko committed Oct 4, 2012
View
32 .gitignore
@@ -0,0 +1,32 @@
+
+# Junk that could exist anywhere:
+.DS_Store
+*.swp
+*.tmp
+.*.gz
+*.patch
+
+# Temporary files created by Eclipse
+.tmp*
+
+# Editor junk
+*.project
+/.pydevproject
+/.settings/
+/.settings.xml
+/.settings.xml.old
+/.idea/
+
+# Build Files
+/extension/build/
+/extension/release/
+/tests/FBTest/release/
+*.graphml
+/extension/bz-locale/
+
+# Files from NPM
+/extension/node_modules/
+
+# Extensions
+/extension/firebug@software.joehewitt.com
+
View
3 ant.properties
@@ -0,0 +1,3 @@
+# DO NOT MERGE INTO TRUNK
+RELEASE=.1
+VERSION=0.5
View
148 bootstrap.js
@@ -0,0 +1,148 @@
+/* See license.txt for terms of usage */
+
+// ********************************************************************************************* //
+// XPCOM
+
+var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
+
+// ********************************************************************************************* //
+// Constants
+
+// Extension installation path. Set within startup callback.
+var installPath;
+
+// ********************************************************************************************* //
+// Firefox Bootstrap API
+
+function install(data, reason) {}
+function uninstall(data, reason) {}
+
+function startup(data, reason)
+{
+ // Remember so, we can use later within firebugStartup callback.
+ installPath = data.installPath;
+
+ // Firebug extension start-up callback. Since extension load order isn't guaranteed
+ // the code needs to be ready for two alternatives:
+ // 1) Firebug is already loaded - good, let's just execute firebugStartup() callback
+ // that will ensure proper Firebug related initialization for this extension.
+ // 2) Firebug is not loaded yet - as soon as Firebug is loaded it'll execute this
+ // method automatially.
+ firebugStartup();
+}
+
+function shutdown(data, reason)
+{
+ firebugShutdown();
+}
+
+function isFirebugLoaded()
+{
+ try
+ {
+ // Import Firebug modules into this scope. It fails if Firebug isn't loaded yet.
+ Cu.import("resource://firebug/loader.js");
+ Cu.import("resource://firebug/prefLoader.js");
+
+ return true;
+ }
+ catch (e)
+ {
+ }
+
+ return true;
+}
+
+// ********************************************************************************************* //
+// Firebug Bootstrap API
+
+/**
+ * Executed by Firebug framework when Firebug is started. Since the order of Firebug
+ * and its bootstrapped extensions is not guaranteed this function is executed twice.
+ * 1) When Firebug is loaded
+ * 2) When this extension is loaded
+ */
+function firebugStartup()
+{
+ // If Firebu isn't loade just bail out, Firebug will execute this method
+ // as soon as it loads.
+ if (!isFirebugLoaded())
+ return;
+
+ FirebugLoader.registerBootstrapScope(this);
+
+ // Load default preferences
+ PrefLoader.loadDefaultPrefs(installPath, "prefs.js");
+}
+
+/**
+ * Executed by Firefox when this extension shutdowns.
+ */
+function firebugShutdown()
+{
+ try
+ {
+ FirebugLoader.unregisterBootstrapScope(this);
+ }
+ catch (e)
+ {
+ Cu.reportError(e);
+ }
+}
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+/**
+ * Executed by Firebug framework for every browser window. Use this function to append
+ * any new elements into the browser window (browser.xul). Don't forget to remove
+ * these elements in topWindowUnload.
+ *
+ * @param {Window} win The browser window
+ */
+function topWindowLoad(win)
+{
+ // TODO: overlay global browser window
+}
+
+/**
+ * Executed by Firebug framework when this extension
+ * @param {Object} win
+ */
+function topWindowUnload(win)
+{
+ // TODO: remove global browser window overlays
+}
+
+/**
+ * Entire Firebug UI is running inside an iframe (firebugFrame.xul). This function
+ * is executed by Firebug framework when the frame is loaded. This happens when
+ * the user requires Firebug for the first time (doesn't have to happen during the
+ * Firefox session at all)
+ *
+ * @param {Window} win The Firebug window
+ */
+function firebugFrameLoad(Firebug)
+{
+ // Register trace listener the customizes trace logs coming from this extension
+ // * fireless; is unique prefix of all messages that should be customized.
+ // * DBG_FIRELESS is a class name with style defined in the specified stylesheet.
+ Firebug.registerTracePrefix("fireless;", "DBG_FIRELESS", true,
+ "chrome://fireless/skin/fireless.css");
+
+ // The registration process will automatically look for 'main' module and load it.
+ // The is the same what happens in a XUL overlay applied on:
+ // chrome://firebug/content/firebugOverlay.xul
+ var config = {id: "fireless@getfirebug.com"};
+ Firebug.registerExtension("fireless", config);
+}
+
+function firebugFrameUnload(Firebug)
+{
+ if (!Firebug.isInitialized)
+ return;
+
+ Firebug.unregisterExtension("fireless");
+ Firebug.unregisterTracePrefix("fireless;");
+}
+
+// ********************************************************************************************* //
View
44 build.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" ?>
+
+<!-- Run ant in the extension's directory and look for: fireless-0.5.1.xpi -->
+<project name="fireless" basedir="." default="build">
+
+ <!-- Properties -->
+ <property file="ant.properties"/>
+ <property name="build.dir" value="./release"/>
+ <property name="file-name" value="fireless-${VERSION}${RELEASE}.xpi"/>
+
+ <!-- Clean -->
+ <target name="clean">
+ <delete dir="${build.dir}"/>
+ </target>
+
+ <!-- Build -->
+ <target name="build" depends="clean">
+
+ <!-- Copy files -->
+ <copy todir="${build.dir}">
+ <fileset dir=".">
+ <include name="**/*.js"/>
+ <include name="**/*.xul"/>
+ <include name="**/*.properties"/>
+ <include name="**/*.css"/>
+ <include name="**/*.manifest"/>
+ <include name="**/*.rdf"/>
+ <include name="**/*.txt"/>
+ </fileset>
+ </copy>
+
+ <!-- Copy install.rdf with updated release version info -->
+ <replace file="${build.dir}/install.rdf" propertyFile="ant.properties">
+ <replacefilter token="@VERSION@" property="VERSION"/>
+ <replacefilter token="@RELEASE@" property="RELEASE"/>
+ </replace>
+
+ <!-- Compress files (ZIP) -->
+ <zip destfile="${file-name}" basedir="${build.dir}" update="true" />
+
+ <echo message="FireLess version: ${VERSION}${RELEASE} created!"/>
+ </target>
+
+</project>
View
3 chrome.manifest
@@ -0,0 +1,3 @@
+content fireless chrome/content/
+skin fireless classic/1.0 chrome/skin/classic/
+locale fireless en-US chrome/locale/en-US/
View
66 chrome/content/lessModule.js
@@ -0,0 +1,66 @@
+/* See license.txt for terms of usage */
+
+define([
+ "firebug/lib/object",
+ "firebug/lib/trace",
+ "firebug/css/stylePanel",
+],
+function(Obj, FBTrace, CSSStylePanel) {
+
+// ********************************************************************************************* //
+// Custom Module Implementation
+
+Firebug.LessModule = Obj.extend(Firebug.Module,
+{
+ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+ // Initialization
+
+ initialize: function(owner)
+ {
+ Firebug.Module.initialize.apply(this, arguments);
+
+ // TODO: Module initialization (there is one module instance per browser window)
+
+ if (FBTrace.DBG_FIRELESS)
+ FBTrace.sysout("fireless; LessModule.initialize");
+ },
+
+ shutdown: function()
+ {
+ Firebug.Module.shutdown.apply(this, arguments);
+
+ if (FBTrace.DBG_FIRELESS)
+ FBTrace.sysout("fireless; LessModule.shutdown");
+ },
+
+ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+ // CSSStylePanel Patch
+
+ onCreatePanel: function(context, panel, panelType)
+ {
+ // Monkey patch the Style side panel.
+ if (panel instanceof CSSStylePanel)
+ {
+ this.styleGetSourceLink = panel.getSourceLink;
+ panel.getSourceLink = this.getSourceLink;
+ }
+ },
+
+ getSourceLink: function(target, rule)
+ {
+ if (FBTrace.DBG_FIRELESS)
+ FBTrace.sysout("fireless; LessModule.getSourceLink");
+
+ Firebug.LessModule.styleGetSourceLink.apply(this, arguments);
+ }
+});
+
+// ********************************************************************************************* //
+// Registration
+
+Firebug.registerModule(Firebug.LessModule);
+
+return Firebug.LessModule;
+
+// ********************************************************************************************* //
+});
View
44 chrome/content/main.js
@@ -0,0 +1,44 @@
+/* See license.txt for terms of usage */
+
+define([
+ "firebug/lib/trace",
+ "fireless/lessModule",
+],
+function(FBTrace, LessModule) {
+
+// ********************************************************************************************* //
+// The application/extension object
+
+var theExtension =
+{
+ initialize: function()
+ {
+ if (FBTrace.DBG_FIRELESS)
+ FBTrace.sysout("fireless; FireLess extension initialize");
+
+ // Registration of Firebug panels and modules is made within appropriate files,
+ // but it could be also done here.
+
+ // TODO: Extension initialization
+ },
+
+ shutdown: function()
+ {
+ if (FBTrace.DBG_FIRELESS)
+ FBTrace.sysout("fireless; FireLess extension shutdown");
+
+ // Unregister all registered Firebug components
+ Firebug.unregisterModule(Firebug.LessModule);
+ Firebug.unregisterStylesheet("chrome://fireless/skin/fireless.css");
+ Firebug.unregisterStringBundle("chrome://fireless/locale/fireless.properties");
+
+ // TODO: Extension shutdown
+ }
+}
+
+// ********************************************************************************************* //
+
+return theExtension;
+
+// ********************************************************************************************* //
+});
View
4 chrome/locale/en-US/fireless.properties
@@ -0,0 +1,4 @@
+# All UI should be here
+# Example:
+# fireless.label.cssError=CSS Error
+
View
11 chrome/skin/classic/fireless.css
@@ -0,0 +1,11 @@
+/* See license.txt for terms of usage */
+
+/*************************************************************************************************/
+
+/* Firebug Tracing Console customization. All messages from this example use this color.
+ This helps to distinguish logs from those coming from Firebug
+ Rule syntax: .DBG_<ext-id>
+ See: http://getfirebug.com/wiki/index.php/FBTrace for more details */
+.DBG_FIRELESS {
+ color: rgb(101, 0, 114);
+}
View
1 defaults/preferences/prefs.js
@@ -0,0 +1 @@
+pref("extensions.firebug.DBG_FIRELESS", true);
View
26 install.rdf
@@ -0,0 +1,26 @@
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+
+ <Description about="urn:mozilla:install-manifest">
+ <em:id>fireless@getfirebug.com</em:id>
+ <em:version>0.5</em:version>
+ <em:type>2</em:type>
+ <em:bootstrap>true</em:bootstrap>
+
+ <!-- Target Application this extension can install into,
+ with minimum and maximum supported versions. -->
+ <em:targetApplication>
+ <Description>
+ <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
+ <em:minVersion>10.0</em:minVersion>
+ <em:maxVersion>20.*</em:maxVersion>
+ </Description>
+ </em:targetApplication>
+
+ <!-- Front End MetaData -->
+ <em:name>FireLess</em:name>
+ <em:description>Support for LESS CSS in Firebug</em:description>
+ <em:creator>Jan Odvarko</em:creator>
+ <em:homepageURL>http://getfirebug.com</em:homepageURL>
+ </Description>
+</RDF>
View
30 license.txt
@@ -0,0 +1,30 @@
+Software License Agreement (BSD License)
+
+Copyright (c) 2007, Parakey Inc.
+All rights reserved.
+
+Redistribution and use of this software in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above
+ copyright notice, this list of conditions and the
+ following disclaimer.
+
+* Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the
+ following disclaimer in the documentation and/or other
+ materials provided with the distribution.
+
+* Neither the name of Parakey Inc. nor the names of its
+ contributors may be used to endorse or promote products
+ derived from this software without specific prior
+ written permission of Parakey Inc.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

0 comments on commit 83088fe

Please sign in to comment.
Something went wrong with that request. Please try again.