Skip to content
Browse files

initial import

  • Loading branch information...
0 parents commit f442560033dde6bf9a07b3bae9147d5ce9a9124b @parallel committed Aug 6, 2011
1 .gitignore
@@ -0,0 +1 @@
+/build
6 .zipignore
@@ -0,0 +1,6 @@
+.git/*
+build/*
+releases/*
+.gitignore
+.zipignore
+Makefile
62 License
@@ -0,0 +1,62 @@
+
+Software License Agreement (BSD License)
+
+Copyright (c) 2011, Julien Kernec'h
+
+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.
+
+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.
+
+
+Based on the FireSass extension :
+
+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.
15 Makefile
@@ -0,0 +1,15 @@
+
+clean:
+ @rm -rf build
+
+package: clean
+ @echo "Packaging the FireStylus extension v$(shell cat Version):\n"
+ @mkdir build
+ @cp -R src/* Version License.txt Readme.md .zipignore build/
+ @cd build ; zip -9 -rm firestylus-$(shell cat Version).xpi . -x@.zipignore
+ @echo
+ @echo " output: build/firestylus-$(shell cat Version).xpi\n"
+ @echo " Package done with success !"
+ @echo " To install it, just drap and drop the extension to firefox.\n"
+
+.PHONY: clean
75 Readme.md
@@ -0,0 +1,75 @@
+# FireStylus
+
+FireStylus is a Firebug extension that makes Firebug display
+the Stylus filename and line numbers of the Stylus-generated CSS styles
+rather than those of the generated CSS.
+
+
+## Usage
+
+First, you need to install the [FireStylus extension for firebug](//raw.github.com/parallel/firestylus/master/releases/firestylus-0.0.1.xpi).
+
+Then you need to install a custom version of stylus :
+
+ $ sudo npm uninstall stylus -g
+ $ git clone git://github.com/parallel/stylus
+ $ cd stylus
+ $ sudo npm link
+
+Finally, you need to enable the Stylus's `firebug` option
+when generating your CSS.
+
+Command line
+
+ $ stylus -f <path>
+ $ stylus --firebug <path>
+
+Javascript API
+
+ var stylus = require('stylus');
+
+ stylus(str)
+ .set('firebug', true)
+ .render(function(err, css){
+ // logic
+ });
+
+Connect / Express
+
+ var stylus = require('stylus');
+
+ var server = connect.createServer(
+ stylus.middleware({
+ src: __dirname
+ , dest: __dirname + '/public'
+ , firebug: true
+ })
+ , connect.static(__dirname + '/public')
+ );
+
+
+## Compatibility
+
+FireStylus currently requires a fork of Stylus.
+
+FireStylus should work with all versions of Firefox after and including 3.0,
+and all Firebug versions after and including 1.4
+
+- Firefox 3+ (also works with version 5)
+- Firebug 1.4+
+- [Stylus fork](//github.com/parallel/stylus)
+
+
+## Limitations
+
+FireStylus only works in the html view of firebug, the others views,
+such as the css view won't work due to firebug limitations.
+
+FireStylus and FireSass are incompatible. You cannot enable them
+simultaneously.
+
+
+## Credits
+
+Thanks to [Nathan Weizenbaum](//github.com/nex3) for the [FireSass extension](//github.com/nex3/firesass)
+
1 Version
@@ -0,0 +1 @@
+0.0.1
BIN releases/firestylus-0.0.1.xpi
Binary file not shown.
9 src/chrome.manifest
@@ -0,0 +1,9 @@
+content firestylus chrome/content/
+content firestylus chrome/content/ contentaccessible=yes
+
+overlay chrome://firebug/content/firebugOverlay.xul chrome://firestylus/content/firestylus.xul
+
+locale firestylus en-US chrome/locale/en-US/
+locale firestylus fr-FR chrome/locale/fr-FR/
+
+skin firestylus classic/1.0 chrome/skin/
122 src/chrome/content/extension.js
@@ -0,0 +1,122 @@
+FBL.ns(function() { with (FBL) {
+ // A map of editor protocols to their string names.
+ // Each of these should work with the format "protocol://open?url=%s&line=%s".
+ // They should also each have localized strings.
+ const editorProtocols = {
+ txmt: "Textmate",
+ mvim: "MacVim",
+ emacs: "Emacs"
+ };
+
+ var stringBundle = document.getElementById("firestylus-strings");
+
+ var eps = Components
+ .classes["@mozilla.org/uriloader/external-protocol-service;1"]
+ .getService(Ci.nsIExternalProtocolService);
+
+ var sl = Firebug.getRep(new FBL.SourceLink());
+
+ function cachestylusDebugInfo(sourceLink) {
+ if (sourceLink.type != "css" || sourceLink.stylusDebugInfo) {
+ sourceLink.stylusDebugInfo = {};
+ return;
+ }
+
+ var rules = sourceLink.object.parentStyleSheet.cssRules;
+ for(var i=0; i<rules.length-1; i++)
+ {
+ var styleRule = rules[i+1];
+ if (styleRule.type != CSSRule.STYLE_RULE) continue;
+ styleRule.stylusDebugInfo = {};
+
+ var mediaRule = rules[i];
+ if (mediaRule.type != CSSRule.MEDIA_RULE) continue;
+
+ if (mediaRule.media.mediaText != "-stylus-debug-info") continue;
+
+ for (var j=0; j<mediaRule.cssRules.length; j++)
+ {
+ styleRule.stylusDebugInfo[mediaRule.cssRules[j].selectorText] =
+ mediaRule.cssRules[j].style.getPropertyValue("font-family");
+ }
+ }
+
+ sourceLink.stylusDebugInfo = sourceLink.object.stylusDebugInfo || {};
+ return;
+ }
+
+ sl.getSourceLinkTitle = function(sourceLink)
+ {
+ if (!sourceLink)
+ return "";
+
+ cachestylusDebugInfo(sourceLink);
+
+ try
+ {
+ var fileName = getFileName(sourceLink.stylusDebugInfo["filename"] || sourceLink.href);
+ fileName = decodeURIComponent(fileName);
+ fileName = cropString(fileName, 17);
+ }
+ catch(exc)
+ {
+ }
+
+ return $STRF("Line", [fileName, sourceLink.stylusDebugInfo["line"] || sourceLink.line]);
+ };
+
+ sl.copyLink = function(sourceLink)
+ {
+ var filename = sourceLink.stylusDebugInfo["filename"];
+ if (filename)
+ {
+ var url = splitURLTrue(filename);
+ copyToClipboard(url.path + "/" + url.name);
+ }
+ else
+ copyToClipboard(sourceLink.href);
+ };
+
+ sl.getTooltip = function(sourceLink)
+ {
+ return decodeURI(sourceLink.stylusDebugInfo["filename"] || sourceLink.href);
+ };
+
+ var contextMenuItems = sl.getContextMenuItems;
+ sl.getContextMenuItems = function(sourceLink, target, context) {
+ var items = contextMenuItems(sourceLink, target, context);
+
+ if (!sourceLink.stylusDebugInfo["filename"])
+ return items;
+
+ var hasDivider = false;
+ for (var protocol in editorProtocols)
+ {
+ if (!eps.externalProtocolHandlerExists(protocol))
+ continue;
+
+ if (!hasDivider){
+ items.push("-");
+ hasDivider = true;
+ }
+
+ items.push({
+ label: stringBundle.getString("OpenIn" + editorProtocols[protocol]),
+ command: bindFixed(this.openInEditor, this, protocol, sourceLink)
+ });
+ }
+
+ return items;
+ };
+
+ sl.openInEditor = function(protocol, sourceLink) {
+ var url = protocol + "://open?";
+ var filename = sourceLink.stylusDebugInfo["filename"] || sourceLink.href;
+ url += "url=" + encodeURIComponent(filename);
+
+ if (sourceLink.stylusDebugInfo["line"])
+ url += "&line=" + sourceLink.stylusDebugInfo["line"];
+
+ window.location = url;
+ };
+}});
7 src/chrome/content/firestylus.xul
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<overlay id="firestylus-overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <script type="application/x-javascript" src="extension.js" />
+ <stringbundleset>
+ <stringbundle id="firestylus-strings" src="chrome://firestylus/locale/firestylus.properties"/>
+ </stringbundleset>
+</overlay>
3 src/chrome/locale/en-US/firestylus.properties
@@ -0,0 +1,3 @@
+OpenInTextmate=Open in Textmate
+OpenInMacVim=Open in MacVim
+OpenInEmacs=Open in Emacs
3 src/chrome/locale/fr-FR/firestylus.properties
@@ -0,0 +1,3 @@
+OpenInTextmate=Ouvrir dans Textmate
+OpenInMacVim=Ouvrir dans MacVim
+OpenInEmacs=Ouvrir dans Emacs
BIN src/chrome/skin/logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 src/install.rdf
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<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>{3a42f67b-d762-4ec0-b02d-a2aae2c0886a}</em:id>
+ <em:type>2</em:type>
+ <em:version>0.0.1</em:version>
+ <em:creator>Julien Kernec'h</em:creator>
+ <em:localized>
+ <Description>
+ <em:locale>en-US</em:locale>
+ <em:name>FireStylus for Firebug</em:name>
+ <em:description>FireStylus allows Firebug to display the original Stylus and line number of the generated CSS styles.</em:description>
+ </Description>
+ </em:localized>
+ <em:localized>
+ <Description>
+ <em:locale>fr-FR</em:locale>
+ <em:name>FireStylus pour Firebug</em:name>
+ <em:description>FireStylus permet &#224; Firebug d'afficher le nom du fichier et le num&#233;ro de ligne des fichiers Stylus originaux dans les css g&#233;n&#233;r&#233;s.</em:description>
+ </Description>
+ </em:localized>
+ <em:homepageURL>http://github.com/parallel/firestylus</em:homepageURL>
+ <em:iconURL>chrome://firestylus/skin/logo.png</em:iconURL>
+ <!-- Firefox -->
+ <em:targetApplication>
+ <Description>
+ <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
+ <em:minVersion>3.0</em:minVersion>
+ <em:maxVersion>5.*</em:maxVersion>
+ </Description>
+ </em:targetApplication>
+ </Description>
+</RDF>

0 comments on commit f442560

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