Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

initial import

  • Loading branch information...
commit f442560033dde6bf9a07b3bae9147d5ce9a9124b 0 parents
Julien Kernec'h authored
1  .gitignore
... ... @@ -0,0 +1 @@
  1 +/build
6 .zipignore
... ... @@ -0,0 +1,6 @@
  1 +.git/*
  2 +build/*
  3 +releases/*
  4 +.gitignore
  5 +.zipignore
  6 +Makefile
62 License
... ... @@ -0,0 +1,62 @@
  1 +
  2 +Software License Agreement (BSD License)
  3 +
  4 +Copyright (c) 2011, Julien Kernec'h
  5 +
  6 +All rights reserved.
  7 +
  8 +Redistribution and use of this software in source and binary forms, with or without modification,
  9 +are permitted provided that the following conditions are met:
  10 +
  11 +* Redistributions of source code must retain the above
  12 + copyright notice, this list of conditions and the
  13 + following disclaimer.
  14 +
  15 +* Redistributions in binary form must reproduce the above
  16 + copyright notice, this list of conditions and the
  17 + following disclaimer in the documentation and/or other
  18 + materials provided with the distribution.
  19 +
  20 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
  21 +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  22 +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  23 +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  24 +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  26 +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  27 +OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28 +
  29 +
  30 +Based on the FireSass extension :
  31 +
  32 +Software License Agreement (BSD License)
  33 +
  34 +Copyright (c) 2007, Parakey Inc
  35 +
  36 +All rights reserved.
  37 +
  38 +Redistribution and use of this software in source and binary forms, with or without modification,
  39 +are permitted provided that the following conditions are met:
  40 +
  41 +* Redistributions of source code must retain the above
  42 + copyright notice, this list of conditions and the
  43 + following disclaimer.
  44 +
  45 +* Redistributions in binary form must reproduce the above
  46 + copyright notice, this list of conditions and the
  47 + following disclaimer in the documentation and/or other
  48 + materials provided with the distribution.
  49 +
  50 +* Neither the name of Parakey Inc. nor the names of its
  51 + contributors may be used to endorse or promote products
  52 + derived from this software without specific prior
  53 + written permission of Parakey Inc.
  54 +
  55 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
  56 +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  57 +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  58 +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  59 +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  60 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  61 +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  62 +OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15 Makefile
... ... @@ -0,0 +1,15 @@
  1 +
  2 +clean:
  3 + @rm -rf build
  4 +
  5 +package: clean
  6 + @echo "Packaging the FireStylus extension v$(shell cat Version):\n"
  7 + @mkdir build
  8 + @cp -R src/* Version License.txt Readme.md .zipignore build/
  9 + @cd build ; zip -9 -rm firestylus-$(shell cat Version).xpi . -x@.zipignore
  10 + @echo
  11 + @echo " output: build/firestylus-$(shell cat Version).xpi\n"
  12 + @echo " Package done with success !"
  13 + @echo " To install it, just drap and drop the extension to firefox.\n"
  14 +
  15 +.PHONY: clean
75 Readme.md
Source Rendered
... ... @@ -0,0 +1,75 @@
  1 +# FireStylus
  2 +
  3 +FireStylus is a Firebug extension that makes Firebug display
  4 +the Stylus filename and line numbers of the Stylus-generated CSS styles
  5 +rather than those of the generated CSS.
  6 +
  7 +
  8 +## Usage
  9 +
  10 +First, you need to install the [FireStylus extension for firebug](//raw.github.com/parallel/firestylus/master/releases/firestylus-0.0.1.xpi).
  11 +
  12 +Then you need to install a custom version of stylus :
  13 +
  14 + $ sudo npm uninstall stylus -g
  15 + $ git clone git://github.com/parallel/stylus
  16 + $ cd stylus
  17 + $ sudo npm link
  18 +
  19 +Finally, you need to enable the Stylus's `firebug` option
  20 +when generating your CSS.
  21 +
  22 +Command line
  23 +
  24 + $ stylus -f <path>
  25 + $ stylus --firebug <path>
  26 +
  27 +Javascript API
  28 +
  29 + var stylus = require('stylus');
  30 +
  31 + stylus(str)
  32 + .set('firebug', true)
  33 + .render(function(err, css){
  34 + // logic
  35 + });
  36 +
  37 +Connect / Express
  38 +
  39 + var stylus = require('stylus');
  40 +
  41 + var server = connect.createServer(
  42 + stylus.middleware({
  43 + src: __dirname
  44 + , dest: __dirname + '/public'
  45 + , firebug: true
  46 + })
  47 + , connect.static(__dirname + '/public')
  48 + );
  49 +
  50 +
  51 +## Compatibility
  52 +
  53 +FireStylus currently requires a fork of Stylus.
  54 +
  55 +FireStylus should work with all versions of Firefox after and including 3.0,
  56 +and all Firebug versions after and including 1.4
  57 +
  58 +- Firefox 3+ (also works with version 5)
  59 +- Firebug 1.4+
  60 +- [Stylus fork](//github.com/parallel/stylus)
  61 +
  62 +
  63 +## Limitations
  64 +
  65 +FireStylus only works in the html view of firebug, the others views,
  66 +such as the css view won't work due to firebug limitations.
  67 +
  68 +FireStylus and FireSass are incompatible. You cannot enable them
  69 +simultaneously.
  70 +
  71 +
  72 +## Credits
  73 +
  74 +Thanks to [Nathan Weizenbaum](//github.com/nex3) for the [FireSass extension](//github.com/nex3/firesass)
  75 +
1  Version
... ... @@ -0,0 +1 @@
  1 +0.0.1
BIN  releases/firestylus-0.0.1.xpi
Binary file not shown
9 src/chrome.manifest
... ... @@ -0,0 +1,9 @@
  1 +content firestylus chrome/content/
  2 +content firestylus chrome/content/ contentaccessible=yes
  3 +
  4 +overlay chrome://firebug/content/firebugOverlay.xul chrome://firestylus/content/firestylus.xul
  5 +
  6 +locale firestylus en-US chrome/locale/en-US/
  7 +locale firestylus fr-FR chrome/locale/fr-FR/
  8 +
  9 +skin firestylus classic/1.0 chrome/skin/
122 src/chrome/content/extension.js
... ... @@ -0,0 +1,122 @@
  1 +FBL.ns(function() { with (FBL) {
  2 + // A map of editor protocols to their string names.
  3 + // Each of these should work with the format "protocol://open?url=%s&line=%s".
  4 + // They should also each have localized strings.
  5 + const editorProtocols = {
  6 + txmt: "Textmate",
  7 + mvim: "MacVim",
  8 + emacs: "Emacs"
  9 + };
  10 +
  11 + var stringBundle = document.getElementById("firestylus-strings");
  12 +
  13 + var eps = Components
  14 + .classes["@mozilla.org/uriloader/external-protocol-service;1"]
  15 + .getService(Ci.nsIExternalProtocolService);
  16 +
  17 + var sl = Firebug.getRep(new FBL.SourceLink());
  18 +
  19 + function cachestylusDebugInfo(sourceLink) {
  20 + if (sourceLink.type != "css" || sourceLink.stylusDebugInfo) {
  21 + sourceLink.stylusDebugInfo = {};
  22 + return;
  23 + }
  24 +
  25 + var rules = sourceLink.object.parentStyleSheet.cssRules;
  26 + for(var i=0; i<rules.length-1; i++)
  27 + {
  28 + var styleRule = rules[i+1];
  29 + if (styleRule.type != CSSRule.STYLE_RULE) continue;
  30 + styleRule.stylusDebugInfo = {};
  31 +
  32 + var mediaRule = rules[i];
  33 + if (mediaRule.type != CSSRule.MEDIA_RULE) continue;
  34 +
  35 + if (mediaRule.media.mediaText != "-stylus-debug-info") continue;
  36 +
  37 + for (var j=0; j<mediaRule.cssRules.length; j++)
  38 + {
  39 + styleRule.stylusDebugInfo[mediaRule.cssRules[j].selectorText] =
  40 + mediaRule.cssRules[j].style.getPropertyValue("font-family");
  41 + }
  42 + }
  43 +
  44 + sourceLink.stylusDebugInfo = sourceLink.object.stylusDebugInfo || {};
  45 + return;
  46 + }
  47 +
  48 + sl.getSourceLinkTitle = function(sourceLink)
  49 + {
  50 + if (!sourceLink)
  51 + return "";
  52 +
  53 + cachestylusDebugInfo(sourceLink);
  54 +
  55 + try
  56 + {
  57 + var fileName = getFileName(sourceLink.stylusDebugInfo["filename"] || sourceLink.href);
  58 + fileName = decodeURIComponent(fileName);
  59 + fileName = cropString(fileName, 17);
  60 + }
  61 + catch(exc)
  62 + {
  63 + }
  64 +
  65 + return $STRF("Line", [fileName, sourceLink.stylusDebugInfo["line"] || sourceLink.line]);
  66 + };
  67 +
  68 + sl.copyLink = function(sourceLink)
  69 + {
  70 + var filename = sourceLink.stylusDebugInfo["filename"];
  71 + if (filename)
  72 + {
  73 + var url = splitURLTrue(filename);
  74 + copyToClipboard(url.path + "/" + url.name);
  75 + }
  76 + else
  77 + copyToClipboard(sourceLink.href);
  78 + };
  79 +
  80 + sl.getTooltip = function(sourceLink)
  81 + {
  82 + return decodeURI(sourceLink.stylusDebugInfo["filename"] || sourceLink.href);
  83 + };
  84 +
  85 + var contextMenuItems = sl.getContextMenuItems;
  86 + sl.getContextMenuItems = function(sourceLink, target, context) {
  87 + var items = contextMenuItems(sourceLink, target, context);
  88 +
  89 + if (!sourceLink.stylusDebugInfo["filename"])
  90 + return items;
  91 +
  92 + var hasDivider = false;
  93 + for (var protocol in editorProtocols)
  94 + {
  95 + if (!eps.externalProtocolHandlerExists(protocol))
  96 + continue;
  97 +
  98 + if (!hasDivider){
  99 + items.push("-");
  100 + hasDivider = true;
  101 + }
  102 +
  103 + items.push({
  104 + label: stringBundle.getString("OpenIn" + editorProtocols[protocol]),
  105 + command: bindFixed(this.openInEditor, this, protocol, sourceLink)
  106 + });
  107 + }
  108 +
  109 + return items;
  110 + };
  111 +
  112 + sl.openInEditor = function(protocol, sourceLink) {
  113 + var url = protocol + "://open?";
  114 + var filename = sourceLink.stylusDebugInfo["filename"] || sourceLink.href;
  115 + url += "url=" + encodeURIComponent(filename);
  116 +
  117 + if (sourceLink.stylusDebugInfo["line"])
  118 + url += "&line=" + sourceLink.stylusDebugInfo["line"];
  119 +
  120 + window.location = url;
  121 + };
  122 +}});
7 src/chrome/content/firestylus.xul
... ... @@ -0,0 +1,7 @@
  1 +<?xml version="1.0"?>
  2 +<overlay id="firestylus-overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  3 + <script type="application/x-javascript" src="extension.js" />
  4 + <stringbundleset>
  5 + <stringbundle id="firestylus-strings" src="chrome://firestylus/locale/firestylus.properties"/>
  6 + </stringbundleset>
  7 +</overlay>
3  src/chrome/locale/en-US/firestylus.properties
... ... @@ -0,0 +1,3 @@
  1 +OpenInTextmate=Open in Textmate
  2 +OpenInMacVim=Open in MacVim
  3 +OpenInEmacs=Open in Emacs
3  src/chrome/locale/fr-FR/firestylus.properties
... ... @@ -0,0 +1,3 @@
  1 +OpenInTextmate=Ouvrir dans Textmate
  2 +OpenInMacVim=Ouvrir dans MacVim
  3 +OpenInEmacs=Ouvrir dans Emacs
BIN  src/chrome/skin/logo.png
34 src/install.rdf
... ... @@ -0,0 +1,34 @@
  1 +<?xml version="1.0"?>
  2 +<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  3 + xmlns:em="http://www.mozilla.org/2004/em-rdf#">
  4 + <Description about="urn:mozilla:install-manifest">
  5 + <em:id>{3a42f67b-d762-4ec0-b02d-a2aae2c0886a}</em:id>
  6 + <em:type>2</em:type>
  7 + <em:version>0.0.1</em:version>
  8 + <em:creator>Julien Kernec'h</em:creator>
  9 + <em:localized>
  10 + <Description>
  11 + <em:locale>en-US</em:locale>
  12 + <em:name>FireStylus for Firebug</em:name>
  13 + <em:description>FireStylus allows Firebug to display the original Stylus and line number of the generated CSS styles.</em:description>
  14 + </Description>
  15 + </em:localized>
  16 + <em:localized>
  17 + <Description>
  18 + <em:locale>fr-FR</em:locale>
  19 + <em:name>FireStylus pour Firebug</em:name>
  20 + <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>
  21 + </Description>
  22 + </em:localized>
  23 + <em:homepageURL>http://github.com/parallel/firestylus</em:homepageURL>
  24 + <em:iconURL>chrome://firestylus/skin/logo.png</em:iconURL>
  25 + <!-- Firefox -->
  26 + <em:targetApplication>
  27 + <Description>
  28 + <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
  29 + <em:minVersion>3.0</em:minVersion>
  30 + <em:maxVersion>5.*</em:maxVersion>
  31 + </Description>
  32 + </em:targetApplication>
  33 + </Description>
  34 +</RDF>

0 comments on commit f442560

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